本文整理汇总了C#中Antlr.Runtime.Tree.RewriteRuleSubtreeStream.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# RewriteRuleSubtreeStream.Reset方法的具体用法?C# RewriteRuleSubtreeStream.Reset怎么用?C# RewriteRuleSubtreeStream.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr.Runtime.Tree.RewriteRuleSubtreeStream
的用法示例。
在下文中一共展示了RewriteRuleSubtreeStream.Reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: match_expr
//.........这里部分代码省略.........
loop429:
;
} finally { DebugExitSubRule(429); }
DebugLocation(561, 111);
DEDENT661=(IToken)Match(input,DEDENT,Follow._DEDENT_in_match_expr5981); if (state.failed) return retval;
if (state.backtracking == 0) stream_DEDENT.Add(DEDENT661);
{
// AST REWRITE
// elements: expr, type_name, match_item
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 561:118: -> ^( Match_Expr ( expr )? ( type_name )? ( match_item )+ )
{
DebugLocation(561, 121);
// SugarCpp.g:561:121: ^( Match_Expr ( expr )? ( type_name )? ( match_item )+ )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(561, 123);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Match_Expr, "Match_Expr"), root_1);
DebugLocation(561, 134);
// SugarCpp.g:561:134: ( expr )?
if (stream_expr.HasNext)
{
DebugLocation(561, 134);
adaptor.AddChild(root_1, stream_expr.NextTree());
}
stream_expr.Reset();
DebugLocation(561, 140);
// SugarCpp.g:561:140: ( type_name )?
if (stream_type_name.HasNext)
{
DebugLocation(561, 140);
adaptor.AddChild(root_1, stream_type_name.NextTree());
}
stream_type_name.Reset();
DebugLocation(561, 151);
if (!(stream_match_item.HasNext))
{
throw new RewriteEarlyExitException();
}
while ( stream_match_item.HasNext )
{
DebugLocation(561, 151);
adaptor.AddChild(root_1, stream_match_item.NextTree());
}
stream_match_item.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("match_expr", 62);
LeaveRule("match_expr", 62);
LeaveRule_match_expr();
}
DebugLocation(562, 1);
} finally { DebugExitRule(GrammarFileName, "match_expr"); }
return retval;
}
示例2: classDeclaration
// $ANTLR start "classDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:79:1: classDeclaration : 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) ;
public classDeclaration_return classDeclaration() // throws RecognitionException [1]
{
var retval = new classDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken string_literal4 = null;
name_return name5 = default( name_return );
baseClassDeclaration_return baseClassDeclaration6 = default( baseClassDeclaration_return );
classStatementBlock_return classStatementBlock7 = default( classStatementBlock_return );
CommonTree string_literal4_tree = null;
var stream_57 = new RewriteRuleTokenStream( adaptor, "token 57" );
var stream_classStatementBlock = new RewriteRuleSubtreeStream( adaptor, "rule classStatementBlock" );
var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
var stream_baseClassDeclaration = new RewriteRuleSubtreeStream( adaptor, "rule baseClassDeclaration" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:2: ( 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:4: 'class' name ( baseClassDeclaration )? classStatementBlock
{
string_literal4 = (IToken)Match( input, 57, FOLLOW_57_in_classDeclaration262 );
stream_57.Add( string_literal4 );
PushFollow( FOLLOW_name_in_classDeclaration264 );
name5 = name();
state.followingStackPointer--;
stream_name.Add( name5.Tree );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: ( baseClassDeclaration )?
int alt3 = 2;
int LA3_0 = input.LA( 1 );
if ( ( LA3_0 == 58 ) )
alt3 = 1;
switch ( alt3 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: baseClassDeclaration
{
PushFollow( FOLLOW_baseClassDeclaration_in_classDeclaration266 );
baseClassDeclaration6 = baseClassDeclaration();
state.followingStackPointer--;
stream_baseClassDeclaration.Add( baseClassDeclaration6.Tree );
}
break;
}
PushFollow( FOLLOW_classStatementBlock_in_classDeclaration269 );
classStatementBlock7 = classStatementBlock();
state.followingStackPointer--;
stream_classStatementBlock.Add( classStatementBlock7.Tree );
// AST REWRITE
// elements: name, classStatementBlock, baseClassDeclaration
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 80:59: -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:62: ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CLASS, "CLASS" ), root_1 );
adaptor.AddChild( root_1, stream_name.NextTree() );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:76: ( baseClassDeclaration )?
if ( stream_baseClassDeclaration.HasNext() )
adaptor.AddChild( root_1, stream_baseClassDeclaration.NextTree() );
stream_baseClassDeclaration.Reset();
adaptor.AddChild( root_1, stream_classStatementBlock.NextTree() );
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
//.........这里部分代码省略.........
示例3: classStatementBlock
// $ANTLR start "classStatementBlock"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:85:1: classStatementBlock : '{' ( classLevelStatement )* '}' -> ^( STATEMENT_BLOCK ( classLevelStatement )* ) ;
public classStatementBlock_return classStatementBlock() // throws RecognitionException [1]
{
var retval = new classStatementBlock_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken char_literal12 = null;
IToken char_literal14 = null;
classLevelStatement_return classLevelStatement13 = default( classLevelStatement_return );
CommonTree char_literal12_tree = null;
CommonTree char_literal14_tree = null;
var stream_60 = new RewriteRuleTokenStream( adaptor, "token 60" );
var stream_61 = new RewriteRuleTokenStream( adaptor, "token 61" );
var stream_classLevelStatement = new RewriteRuleSubtreeStream( adaptor, "rule classLevelStatement" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:2: ( '{' ( classLevelStatement )* '}' -> ^( STATEMENT_BLOCK ( classLevelStatement )* ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:4: '{' ( classLevelStatement )* '}'
{
char_literal12 = (IToken)Match( input, 60, FOLLOW_60_in_classStatementBlock328 );
stream_60.Add( char_literal12 );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:8: ( classLevelStatement )*
do
{
int alt4 = 2;
int LA4_0 = input.LA( 1 );
if ( ( LA4_0 == 62 || LA4_0 == 67 ) )
alt4 = 1;
switch ( alt4 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:8: classLevelStatement
{
PushFollow( FOLLOW_classLevelStatement_in_classStatementBlock330 );
classLevelStatement13 = classLevelStatement();
state.followingStackPointer--;
stream_classLevelStatement.Add( classLevelStatement13.Tree );
}
break;
default:
goto loop4;
}
} while ( true );
loop4:
; // Stops C# compiler whining that label 'loop4' has no statements
char_literal14 = (IToken)Match( input, 61, FOLLOW_61_in_classStatementBlock333 );
stream_61.Add( char_literal14 );
// AST REWRITE
// elements: classLevelStatement
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 86:33: -> ^( STATEMENT_BLOCK ( classLevelStatement )* )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:36: ^( STATEMENT_BLOCK ( classLevelStatement )* )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( STATEMENT_BLOCK, "STATEMENT_BLOCK" ), root_1 );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:55: ( classLevelStatement )*
while ( stream_classLevelStatement.HasNext() )
adaptor.AddChild( root_1, stream_classLevelStatement.NextTree() );
stream_classLevelStatement.Reset();
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
//.........这里部分代码省略.........
示例4: lambda_expression
//.........这里部分代码省略.........
int LA2_1 = input.LA(1);
if ((LA2_1==51))
{
alt2 = 1;
}
} finally { DebugExitDecision(2); }
switch (alt2)
{
case 1:
DebugEnterAlt(1);
// Queries\\PomonaQuery.g:90:20: ':' or_expression
{
DebugLocation(90, 20);
char_literal8=(IToken)Match(input,51,Follow._51_in_lambda_expression563);
stream_51.Add(char_literal8);
DebugLocation(90, 24);
PushFollow(Follow._or_expression_in_lambda_expression565);
or_expression9=or_expression();
PopFollow();
stream_or_expression.Add(or_expression9.Tree);
}
break;
}
} finally { DebugExitSubRule(2); }
{
// AST REWRITE
// elements: or_expression
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (object)adaptor.Nil();
// 90:41: -> ^( LAMBDA_OP ( or_expression )+ )
{
DebugLocation(90, 44);
// Queries\\PomonaQuery.g:90:44: ^( LAMBDA_OP ( or_expression )+ )
{
object root_1 = (object)adaptor.Nil();
DebugLocation(90, 46);
root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(LAMBDA_OP, "LAMBDA_OP"), root_1);
DebugLocation(90, 56);
if (!(stream_or_expression.HasNext))
{
throw new RewriteEarlyExitException();
}
while ( stream_or_expression.HasNext )
{
DebugLocation(90, 56);
adaptor.AddChild(root_1, stream_or_expression.NextTree());
}
stream_or_expression.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
retval.Stop = (IToken)input.LT(-1);
retval.Tree = (object)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("lambda_expression", 4);
LeaveRule("lambda_expression", 4);
LeaveRule_lambda_expression();
}
DebugLocation(91, 1);
} finally { DebugExitRule(GrammarFileName, "lambda_expression"); }
return retval;
}
示例5: and_expression
//.........这里部分代码省略.........
case 1:
DebugEnterAlt(1);
// Queries\\PomonaQuery.g:102:22: and_operator relational_expr
{
DebugLocation(102, 22);
PushFollow(Follow._and_operator_in_and_expression641);
and_operator16=and_operator();
PopFollow();
stream_and_operator.Add(and_operator16.Tree);
DebugLocation(102, 35);
PushFollow(Follow._relational_expr_in_and_expression643);
relational_expr17=relational_expr();
PopFollow();
stream_relational_expr.Add(relational_expr17.Tree);
}
break;
default:
goto loop5;
}
}
loop5:
;
} finally { DebugExitSubRule(5); }
{
// AST REWRITE
// elements: relational_expr
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (object)adaptor.Nil();
// 102:54: -> ^( AND_OP ( relational_expr )+ )
{
DebugLocation(102, 57);
// Queries\\PomonaQuery.g:102:57: ^( AND_OP ( relational_expr )+ )
{
object root_1 = (object)adaptor.Nil();
DebugLocation(102, 59);
root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(AND_OP, "AND_OP"), root_1);
DebugLocation(102, 66);
if (!(stream_relational_expr.HasNext))
{
throw new RewriteEarlyExitException();
}
while ( stream_relational_expr.HasNext )
{
DebugLocation(102, 66);
adaptor.AddChild(root_1, stream_relational_expr.NextTree());
}
stream_relational_expr.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
retval.Stop = (IToken)input.LT(-1);
retval.Tree = (object)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("and_expression", 7);
LeaveRule("and_expression", 7);
LeaveRule_and_expression();
}
DebugLocation(103, 1);
} finally { DebugExitRule(GrammarFileName, "and_expression"); }
return retval;
}
示例6: type_template_type
//.........这里部分代码省略.........
{
// AST REWRITE
// elements: type_ident, type_name
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 329:71: -> ^( Type_Template type_ident ( type_name )* )
{
DebugLocation(329, 74);
// SugarCpp.g:329:74: ^( Type_Template type_ident ( type_name )* )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(329, 76);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Template, "Type_Template"), root_1);
DebugLocation(329, 90);
adaptor.AddChild(root_1, stream_type_ident.NextTree());
DebugLocation(329, 101);
// SugarCpp.g:329:101: ( type_name )*
while ( stream_type_name.HasNext )
{
DebugLocation(329, 101);
adaptor.AddChild(root_1, stream_type_name.NextTree());
}
stream_type_name.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
case 2:
DebugEnterAlt(2);
// SugarCpp.g:330:8:
{
{
// AST REWRITE
// elements: type_ident
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 330:8: -> type_ident
{
示例7: as_expression
//.........这里部分代码省略.........
int LA1_1 = input.LA(1);
if ((LA1_1==61))
{
alt1 = 1;
}
} finally { DebugExitDecision(1); }
switch (alt1)
{
case 1:
DebugEnterAlt(1);
// Queries\\PomonaQuery.g:86:24: 'as' lambda_expression
{
DebugLocation(86, 24);
string_literal5=(IToken)Match(input,61,Follow._61_in_as_expression534);
stream_61.Add(string_literal5);
DebugLocation(86, 29);
PushFollow(Follow._lambda_expression_in_as_expression536);
lambda_expression6=lambda_expression();
PopFollow();
stream_lambda_expression.Add(lambda_expression6.Tree);
}
break;
}
} finally { DebugExitSubRule(1); }
{
// AST REWRITE
// elements: lambda_expression
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (object)adaptor.Nil();
// 86:50: -> ^( AS_OP ( lambda_expression )+ )
{
DebugLocation(86, 53);
// Queries\\PomonaQuery.g:86:53: ^( AS_OP ( lambda_expression )+ )
{
object root_1 = (object)adaptor.Nil();
DebugLocation(86, 55);
root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(AS_OP, "AS_OP"), root_1);
DebugLocation(86, 61);
if (!(stream_lambda_expression.HasNext))
{
throw new RewriteEarlyExitException();
}
while ( stream_lambda_expression.HasNext )
{
DebugLocation(86, 61);
adaptor.AddChild(root_1, stream_lambda_expression.NextTree());
}
stream_lambda_expression.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
retval.Stop = (IToken)input.LT(-1);
retval.Tree = (object)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("as_expression", 3);
LeaveRule("as_expression", 3);
LeaveRule_as_expression();
}
DebugLocation(87, 1);
} finally { DebugExitRule(GrammarFileName, "as_expression"); }
return retval;
}
示例8: bracket_expr_list
//.........这里部分代码省略.........
{
// AST REWRITE
// elements: expr
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 703:50: -> ^( Expr_Args ( expr )* )
{
DebugLocation(703, 53);
// SugarCpp.g:703:53: ^( Expr_Args ( expr )* )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(703, 55);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Args, "Expr_Args"), root_1);
DebugLocation(703, 65);
// SugarCpp.g:703:65: ( expr )*
while ( stream_expr.HasNext )
{
DebugLocation(703, 65);
adaptor.AddChild(root_1, stream_expr.NextTree());
}
stream_expr.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
case 2:
DebugEnterAlt(2);
// SugarCpp.g:704:24: ( WS )* ( NEWLINE )+ ( INDENT ( NEWLINE )* expr ( ( ( WS )* ',' | ( WS )* NEWLINE )+ ( WS )* expr )* ( ( WS )* NEWLINE )* ( ( WS )* ')' ( WS )* ( NEWLINE )* DEDENT | DEDENT ( NEWLINE )* ( WS )* ')' ) -> ^( Expr_Args ( expr )* ) | ( ( WS )* expr ( ( ( WS )* ',' | ( WS )* NEWLINE )+ ( WS )* expr )* )? ( WS )* ')' -> ^( Expr_Args ( expr )* ) )
{
DebugLocation(704, 24);
// SugarCpp.g:704:24: ( WS )*
try { DebugEnterSubRule(558);
while (true)
{
int alt558=2;
try { DebugEnterDecision(558, false);
int LA558_0 = input.LA(1);
if ((LA558_0==WS))
{
alt558 = 1;
}
} finally { DebugExitDecision(558); }
示例9: import_def
//.........这里部分代码省略.........
default:
goto loop62;
}
}
loop62:
;
} finally { DebugExitSubRule(62); }
DebugLocation(273, 91);
DEDENT99=(IToken)Match(input,DEDENT,Follow._DEDENT_in_import_def1314); if (state.failed) return retval;
if (state.backtracking == 0) stream_DEDENT.Add(DEDENT99);
}
break;
}
} finally { DebugExitSubRule(63); }
{
// AST REWRITE
// elements: STRING, attribute
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 273:100: -> ^( Import ( attribute )? ( STRING )* )
{
DebugLocation(273, 103);
// SugarCpp.g:273:103: ^( Import ( attribute )? ( STRING )* )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(273, 105);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Import, "Import"), root_1);
DebugLocation(273, 112);
// SugarCpp.g:273:112: ( attribute )?
if (stream_attribute.HasNext)
{
DebugLocation(273, 112);
adaptor.AddChild(root_1, stream_attribute.NextTree());
}
stream_attribute.Reset();
DebugLocation(273, 123);
// SugarCpp.g:273:123: ( STRING )*
while ( stream_STRING.HasNext )
{
DebugLocation(273, 123);
adaptor.AddChild(root_1, stream_STRING.NextNode());
}
stream_STRING.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("import_def", 11);
LeaveRule("import_def", 11);
LeaveRule_import_def();
}
DebugLocation(274, 1);
} finally { DebugExitRule(GrammarFileName, "import_def"); }
return retval;
}
示例10: global_typedef
//.........这里部分代码省略.........
// SugarCpp.g:269:43: WS
{
DebugLocation(269, 43);
WS86=(IToken)Match(input,WS,Follow._WS_in_global_typedef1251); if (state.failed) return retval;
if (state.backtracking == 0) stream_WS.Add(WS86);
}
break;
default:
goto loop53;
}
}
loop53:
;
} finally { DebugExitSubRule(53); }
DebugLocation(269, 47);
PushFollow(Follow._type_name_in_global_typedef1254);
type_name87=type_name();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_type_name.Add(type_name87.Tree);
{
// AST REWRITE
// elements: ident, type_name, attribute
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 269:57: -> ^( Stmt_Typedef ( attribute )? type_name ident )
{
DebugLocation(269, 60);
// SugarCpp.g:269:60: ^( Stmt_Typedef ( attribute )? type_name ident )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(269, 62);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Stmt_Typedef, "Stmt_Typedef"), root_1);
DebugLocation(269, 75);
// SugarCpp.g:269:75: ( attribute )?
if (stream_attribute.HasNext)
{
DebugLocation(269, 75);
adaptor.AddChild(root_1, stream_attribute.NextTree());
}
stream_attribute.Reset();
DebugLocation(269, 86);
adaptor.AddChild(root_1, stream_type_name.NextTree());
DebugLocation(269, 96);
adaptor.AddChild(root_1, stream_ident.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("global_typedef", 10);
LeaveRule("global_typedef", 10);
LeaveRule_global_typedef();
}
DebugLocation(270, 1);
} finally { DebugExitRule(GrammarFileName, "global_typedef"); }
return retval;
}
示例11: square_expr_list
//.........这里部分代码省略.........
} finally { DebugExitDecision(551); }
switch ( alt551 )
{
case 1:
DebugEnterAlt(1);
// SugarCpp.g:699:37: WS
{
DebugLocation(699, 37);
WS847=(IToken)Match(input,WS,Follow._WS_in_square_expr_list8023); if (state.failed) return retval;
if (state.backtracking == 0) stream_WS.Add(WS847);
}
break;
default:
goto loop551;
}
}
loop551:
;
} finally { DebugExitSubRule(551); }
DebugLocation(699, 41);
char_literal848=(IToken)Match(input,133,Follow._133_in_square_expr_list8026); if (state.failed) return retval;
if (state.backtracking == 0) stream_133.Add(char_literal848);
{
// AST REWRITE
// elements: expr
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 699:45: -> ^( Expr_Args ( expr )* )
{
DebugLocation(699, 48);
// SugarCpp.g:699:48: ^( Expr_Args ( expr )* )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(699, 50);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Args, "Expr_Args"), root_1);
DebugLocation(699, 60);
// SugarCpp.g:699:60: ( expr )*
while ( stream_expr.HasNext )
{
DebugLocation(699, 60);
adaptor.AddChild(root_1, stream_expr.NextTree());
}
stream_expr.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("square_expr_list", 93);
LeaveRule("square_expr_list", 93);
LeaveRule_square_expr_list();
}
DebugLocation(700, 1);
} finally { DebugExitRule(GrammarFileName, "square_expr_list"); }
return retval;
}
示例12: global_using
//.........这里部分代码省略.........
DebugLocation(265, 28);
PushFollow(Follow._stmt_using_item_in_global_using1211);
stmt_using_item79=stmt_using_item();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_stmt_using_item.Add(stmt_using_item79.Tree);
}
break;
default:
goto loop49;
}
}
loop49:
;
} finally { DebugExitSubRule(49); }
{
// AST REWRITE
// elements: stmt_using_item, attribute
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 265:46: -> ^( Stmt_Using ( attribute )? ( stmt_using_item )* )
{
DebugLocation(265, 49);
// SugarCpp.g:265:49: ^( Stmt_Using ( attribute )? ( stmt_using_item )* )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(265, 51);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Stmt_Using, "Stmt_Using"), root_1);
DebugLocation(265, 62);
// SugarCpp.g:265:62: ( attribute )?
if (stream_attribute.HasNext)
{
DebugLocation(265, 62);
adaptor.AddChild(root_1, stream_attribute.NextTree());
}
stream_attribute.Reset();
DebugLocation(265, 73);
// SugarCpp.g:265:73: ( stmt_using_item )*
while ( stream_stmt_using_item.HasNext )
{
DebugLocation(265, 73);
adaptor.AddChild(root_1, stream_stmt_using_item.NextTree());
}
stream_stmt_using_item.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("global_using", 9);
LeaveRule("global_using", 9);
LeaveRule_global_using();
}
DebugLocation(266, 1);
} finally { DebugExitRule(GrammarFileName, "global_using"); }
return retval;
}
示例13: lambda_expr
//.........这里部分代码省略.........
{
// AST REWRITE
// elements: lambda_type, func_args, lambda_expr_op, lambda_value
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 594:88: -> ^( Expr_Lambda lambda_expr_op ( func_args )? ( lambda_type )? lambda_value )
{
DebugLocation(594, 91);
// SugarCpp.g:594:91: ^( Expr_Lambda lambda_expr_op ( func_args )? ( lambda_type )? lambda_value )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(594, 93);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_Lambda, "Expr_Lambda"), root_1);
DebugLocation(594, 105);
adaptor.AddChild(root_1, stream_lambda_expr_op.NextTree());
DebugLocation(594, 120);
// SugarCpp.g:594:120: ( func_args )?
if (stream_func_args.HasNext)
{
DebugLocation(594, 120);
adaptor.AddChild(root_1, stream_func_args.NextTree());
}
stream_func_args.Reset();
DebugLocation(594, 131);
// SugarCpp.g:594:131: ( lambda_type )?
if (stream_lambda_type.HasNext)
{
DebugLocation(594, 131);
adaptor.AddChild(root_1, stream_lambda_type.NextTree());
}
stream_lambda_type.Reset();
DebugLocation(594, 144);
adaptor.AddChild(root_1, stream_lambda_value.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
case 2:
DebugEnterAlt(2);
// SugarCpp.g:595:4: modify_expr
{
root_0 = (CommonTree)adaptor.Nil();
DebugLocation(595, 4);
PushFollow(Follow._modify_expr_in_lambda_expr6486);
modify_expr732=modify_expr();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, modify_expr732.Tree);
}
break;
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);
}
finally
{
TraceOut("lambda_expr", 69);
LeaveRule("lambda_expr", 69);
LeaveRule_lambda_expr();
}
DebugLocation(596, 1);
} finally { DebugExitRule(GrammarFileName, "lambda_expr"); }
return retval;
}
示例14: list_expr
//.........这里部分代码省略.........
if (state.backtracking == 0) stream_type_name.Add(type_name690.Tree);
{
// AST REWRITE
// elements: for_item, feed_expr, type_name
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 578:133: -> ^( Expr_List_Generation ( type_name )? ^( Stmt_For ( for_item )* ^( Stmt_Block ) ) feed_expr )
{
DebugLocation(578, 136);
// SugarCpp.g:578:136: ^( Expr_List_Generation ( type_name )? ^( Stmt_For ( for_item )* ^( Stmt_Block ) ) feed_expr )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(578, 138);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Expr_List_Generation, "Expr_List_Generation"), root_1);
DebugLocation(578, 159);
// SugarCpp.g:578:159: ( type_name )?
if (stream_type_name.HasNext)
{
DebugLocation(578, 159);
adaptor.AddChild(root_1, stream_type_name.NextTree());
}
stream_type_name.Reset();
DebugLocation(578, 170);
// SugarCpp.g:578:170: ^( Stmt_For ( for_item )* ^( Stmt_Block ) )
{
CommonTree root_2 = (CommonTree)adaptor.Nil();
DebugLocation(578, 172);
root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Stmt_For, "Stmt_For"), root_2);
DebugLocation(578, 181);
// SugarCpp.g:578:181: ( for_item )*
while ( stream_for_item.HasNext )
{
DebugLocation(578, 181);
adaptor.AddChild(root_2, stream_for_item.NextTree());
}
stream_for_item.Reset();
DebugLocation(578, 191);
// SugarCpp.g:578:191: ^( Stmt_Block )
{
CommonTree root_3 = (CommonTree)adaptor.Nil();
DebugLocation(578, 193);
root_3 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Stmt_Block, "Stmt_Block"), root_3);
adaptor.AddChild(root_2, root_3);
}
adaptor.AddChild(root_1, root_2);
}
DebugLocation(578, 206);
adaptor.AddChild(root_1, stream_feed_expr.NextTree());
adaptor.AddChild(root_0, root_1);
示例15: type_name
//.........这里部分代码省略.........
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 301:57: -> ^( Type_Func ^( Type_List type_single ) ( type_name )? )
{
DebugLocation(301, 60);
// SugarCpp.g:301:60: ^( Type_Func ^( Type_List type_single ) ( type_name )? )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(301, 62);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Func, "Type_Func"), root_1);
DebugLocation(301, 72);
// SugarCpp.g:301:72: ^( Type_List type_single )
{
CommonTree root_2 = (CommonTree)adaptor.Nil();
DebugLocation(301, 74);
root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_List, "Type_List"), root_2);
DebugLocation(301, 84);
adaptor.AddChild(root_2, stream_type_single.NextTree());
adaptor.AddChild(root_1, root_2);
}
DebugLocation(301, 97);
// SugarCpp.g:301:97: ( type_name )?
if (stream_type_name.HasNext)
{
DebugLocation(301, 97);
adaptor.AddChild(root_1, stream_type_name.NextTree());
}
stream_type_name.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
case 2:
DebugEnterAlt(2);
// SugarCpp.g:302:9:
{
{
// AST REWRITE
// elements: type_single
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
if (state.backtracking == 0) {
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (CommonTree)adaptor.Nil();
// 302:9: -> type_single
{