本文整理汇总了C++中NodeFactory::add方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeFactory::add方法的具体用法?C++ NodeFactory::add怎么用?C++ NodeFactory::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeFactory
的用法示例。
在下文中一共展示了NodeFactory::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: predicate
static void predicate( TokType sense, NodeFactory & ifunless, Node pred ) {
if ( sense == tokty_if ) {
ifunless.add( pred );
} else {
// TODO: This is a bug?
ifunless.start( "sysval" );
ifunless.put( "name", "not" );
ifunless.add( pred );
ifunless.end();
}
}
示例2: readVarVal
Node ReadStateClass::readVarVal( TokType fnc ) {
NodeFactory bind;
bind.start( BIND );
Node lhs = this->readExprPrec( prec_assign );
updateAsPattern( lhs, fnc == tokty_val );
bind.add( lhs );
this->checkToken( this->cstyle_mode ? tokty_equal : tokty_bind );
Node x = this->readExpr();
bind.add( x );
bind.end();
return bind.build();
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: 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();
}
示例11: squash
void squash( NodeFactory acc, Node rhs ) {
const std::string
name = rhs->name();
if ( name == SEQ ) {
int n = rhs->size();
for ( int i = 0; i < n; i++ ) {
squash( acc, rhs->getChild( i ) );
}
} else {
acc.add( rhs );
}
}
示例12: 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();
}
}
示例13: 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();
}
}
示例14: readTry
Node ReadStateClass::readTry( const bool try_vs_transaction ) {
NodeFactory ftry;
ftry.start( try_vs_transaction ? "try" : "transaction" );
Node app = this->readExpr();
ftry.add( app );
while ( this->tryToken( tokty_catch ) ) {
if ( this->tryPeekToken( tokty_oparen ) ) {
ftry.start( "catch.return" );
} else {
ftry.start( "catch.then" );
ftry.put( "event", this->readIdName() );
}
ReadStateClass pattern( *this );
pattern.setPatternMode();
Node catch_patt = pattern.readExpr();
ftry.add( catch_patt );
this->checkToken( tokty_then );
Node e = this->readExpr();
ftry.add( e );
ftry.end();
}
if ( this->tryToken( tokty_else ) ) {
ftry.start( "catch.else" );
Node else_stmnts = this->readStmnts();
ftry.add( else_stmnts );
ftry.end();
}
this->checkToken( try_vs_transaction? tokty_endtry : tokty_endtransaction );
ftry.end();
return ftry.build();
}
示例15: readLambda
Node ReadStateClass::readLambda() {
#ifdef DBG_COMMON2GNX
cerr << "LAMBDA" << endl;
#endif
Node ap = this->readCanonicalLambdaLHS( false );
#ifdef DBG_COMMON2GNX
cerr << "Now check =>> is next token" << endl;
#endif
if ( not this->cstyle_mode ) this->checkToken( tokty_fnarrow );
Node body = this->readCompoundStmnts();
if ( not this->cstyle_mode ) this->checkToken( tokty_endfn );
Uncurry components( ap, body );
components.uncurry();
Node fun = components.getFun();
NodeFactory fn;
fn.start( FN );
if ( fun && fun->hasAttribute( "name" ) ) {
fn.put( FN_NAME, fun->attribute( "name" ) );
}
{
Node a = components.getArgs();
fn.add( a );
Node b = components.getBody();
fn.add( b );
}
fn.end();
Node lambda = fn.build();
#ifdef DBG_COMMON2GNX
cerr << "Built lambda: ";
lambda->render( cerr );
cerr << endl;
#endif
return lambda;
}