本文整理汇总了C++中NodeFactory::build方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeFactory::build方法的具体用法?C++ NodeFactory::build怎么用?C++ NodeFactory::build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeFactory
的用法示例。
在下文中一共展示了NodeFactory::build方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readImport
Node ReadStateClass::readImport() {
NodeFactory imp;
imp.start( "import" );
bool pervasive, qualified;
readImportQualifiers( *this, pervasive, qualified );
imp.put( "pervasive", pervasive ? "true" : "false" );
imp.put( "qualified", qualified ? "true" : "false" );
readImportMatch( *this, imp );
this->checkToken( tokty_from );
string url = this->readPkgName();
imp.put( "from", url );
if ( this->tryName( "alias" ) ) {
imp.put( "alias", this->readIdName() );
}
if ( this->tryName( "into" ) ) {
readImportInto( *this, imp );
}
imp.end();
return imp.build();
}
示例2: canonise
Node canonise( const int level, Node fn ) {
const bool is_var = fn->hasName( VAR );
if ( is_var ) {
if ( level == 0 ) {
if ( this->name_needed ) this->badHeader();
return this->anon( fn );
} else if ( this->assume_no_name ) {
return this->anon( fn );
} else {
return fn;
}
} else if ( fn->hasName( SEQ ) && not this->name_needed ) {
return this->anon( fn );
} else if ( fn->hasName( APP ) && fn->size() == 2 ) {
NodeFactory b;
b.start( APP );
Node n = this->canonise( level + 1, fn->getChild( 0 ) );
b.add( n );
b.start( SEQ );
squash( b, fn->getChild( 1 ) );
b.end();
b.end();
return b.build();
} else {
throw this->badHeader();
}
}
示例3: readQueryPrec
Node ReadStateClass::readQueryPrec( const int prec ) {
Node e = this->readExprPrec( prec );
const std::string name = e->name();
if (
name == BIND ||
name == IN ||
name == FROM ||
name == WHERE ||
name == WHILE ||
name == ZIP ||
name == CROSS ||
name == OK ||
name == FINALLY ||
name == DO
) {
return e;
} else {
NodeFactory where;
where.start( WHERE );
where.start( OK );
where.end();
where.add( e );
where.end();
return where.build();
}
}
示例4: makeSymbol
static Node makeSymbol( const std::string & name ) {
NodeFactory sym;
sym.start( "constant" );
sym.put( "type", "symbol" );
sym.put( "value", name );
sym.end();
return sym.build();
}
示例5: readId
Node ReadStateClass::readId( const std::string name ) {
SysConst * sysc = lookupSysConst( name );
if ( sysc != NULL ) {
NodeFactory constant;
constant.start( "constant" );
constant.put( "type", sysc->tag );
constant.put( "value", sysc->value );
constant.end();
return constant.build();
} else {
NodeFactory id;
id.start( this->pattern_mode ? "var" : "id" );
id.put( "name", name );
id.end();
return id.build();
}
}
示例6: getArgs
Node getArgs() const {
Node args = this->lhs->getChild( 1 );
if ( args->hasName( SEQ ) ) return args;
NodeFactory b;
b.start( SEQ );
b.add( args );
b.end();
return b.build();
}
示例7: readMap
Node ReadStateClass::readMap( TokType closer ) {
NodeFactory list;
list.start( SYSAPP );
list.put( SYSAPP_NAME, "newMap" );
Node x = this->readStmntsCheck( closer );
list.add( x );
list.end();
return list.build();
}
示例8: makeApp
static Node makeApp( Node lhs, Node rhs ) {
if ( lhs->name() == GNX_SYSFN ) {
NodeFactory sysapp;
sysapp.start( SYSAPP );
std::string name = lhs->attribute( GNX_SYSFN_VALUE );
sysapp.put( SYSAPP_NAME, name );
sysapp.add( rhs );
sysapp.end();
return sysapp.build();
} else {
NodeFactory app;
app.start( APP );
app.add( lhs );
app.add( rhs );
app.end();
return app.build();
}
}
示例9: makeIndex
static Node makeIndex( Node lhs, Node rhs ) {
NodeFactory index;
index.start( SYSAPP );
index.put( SYSAPP_NAME, "index" );
index.add( rhs );
index.add( lhs );
index.end();
return index.build();
}
示例10: readReturn
Node ReadStateClass::readReturn() {
NodeFactory ret;
ret.start( ASSERT );
ret.put( ASSERT_TAILCALL, "true" );
Node n = this->readExpr();
ret.add( n );
ret.end();
return ret.build();
}
示例11: anon
Node anon( Node fn ) {
NodeFactory b;
b.start( APP );
b.start( VAR ); // But no name - anonymous.
b.end();
b.start( SEQ );
squash( b, fn );
b.end();
b.end();
return b.build();
}
示例12: readPackage
Node ReadStateClass::readPackage() {
NodeFactory pkg;
pkg.start( "package" );
string url = this->readPkgName();
pkg.put( "url", url );
this->checkToken( tokty_semi );
Node body = this->readStmntsCheck( tokty_endpackage );
pkg.add( body );
pkg.end();
return pkg.build();
}
示例13: readIf
Node ReadStateClass::readIf( TokType sense, TokType closer ) {
if ( this->cstyle_mode ) this->checkToken( tokty_oparen );
Node pred = this->readExpr();
this->checkToken( this->cstyle_mode ? tokty_cparen : tokty_then );
Node then_part = this->readStmnts();
if ( this->tryToken( tokty_else ) ) {
NodeFactory ifunless;
ifunless.start( IF );
predicate( sense, ifunless, pred );
ifunless.add( then_part );
Node x = this->readStmnts();
if ( not this->cstyle_mode ) this->checkToken( closer );
ifunless.add( x );
ifunless.end();
return ifunless.build();
} else if ( this->cstyle_mode || this->tryToken( closer ) ) {
NodeFactory ifunless;
ifunless.start( IF );
predicate( sense, ifunless, pred );
ifunless.add( then_part );
ifunless.end();
return ifunless.build();
} else {
TokType new_sense;
if ( this->tryToken( tokty_elseif ) ) {
new_sense = tokty_if;
} else {
this->checkToken( tokty_elseunless );
new_sense = tokty_unless;
}
NodeFactory ifunless;
ifunless.start( IF );
predicate( sense, ifunless, pred );
ifunless.add( then_part );
Node x = this->readIf( new_sense, closer );
ifunless.add( x );
ifunless.end();
return ifunless.build();
}
}
示例14: readEnvVar
Node ReadStateClass::readEnvVar() {
this->checkToken( tokty_obrace );
NodeFactory envvar;
envvar.start( SYSAPP );
envvar.put( "name", "sysGetEnv" );
envvar.start( "constant" );
envvar.put( "type", "string" );
envvar.put( "value", this->item_factory->read()->nameString() );
envvar.end();
this->checkToken( tokty_cbrace );
envvar.end();
return envvar.build();
}
示例15: readListOrVector
Node ReadStateClass::readListOrVector( bool vector_vs_list, TokType closer ) {
NodeFactory list;
list.start( vector_vs_list ? VECTOR : LIST );
Node stmnts = this->readCompoundCore();
if ( not vector_vs_list && this->tryToken( tokty_bar ) ) {
list.add( stmnts );
list.end();
Node L = list.build();
NodeFactory append;
append.start( LIST_APPEND );
append.add( L );
Node x = this->readCompoundCoreCheck( closer );
append.add( x );
append.end();
return append.build();
} else {
this->checkToken( closer );
list.add( stmnts );
list.end();
return list.build();
}
}