本文整理汇总了C#中Antlr.Runtime.Tree.RewriteRuleSubtreeStream.NextNode方法的典型用法代码示例。如果您正苦于以下问题:C# RewriteRuleSubtreeStream.NextNode方法的具体用法?C# RewriteRuleSubtreeStream.NextNode怎么用?C# RewriteRuleSubtreeStream.NextNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr.Runtime.Tree.RewriteRuleSubtreeStream
的用法示例。
在下文中一共展示了RewriteRuleSubtreeStream.NextNode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: stmt_modify
//.........这里部分代码省略.........
loop358:
;
} finally { DebugExitSubRule(358); }
DebugLocation(524, 36);
PushFollow(Follow._where_expr_in_stmt_modify5174);
where_expr557=where_expr();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_where_expr.Add(where_expr557.Tree);
{
// AST REWRITE
// elements: lvalue, where_expr, modify_expr_op
// 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();
// 524:47: -> ^( modify_expr_op lvalue where_expr )
{
DebugLocation(524, 50);
// SugarCpp.g:524:50: ^( modify_expr_op lvalue where_expr )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(524, 52);
root_1 = (CommonTree)adaptor.BecomeRoot(stream_modify_expr_op.NextNode(), root_1);
DebugLocation(524, 67);
adaptor.AddChild(root_1, stream_lvalue.NextTree());
DebugLocation(524, 74);
adaptor.AddChild(root_1, stream_where_expr.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
case 2:
DebugEnterAlt(2);
// SugarCpp.g:525:13: ( WS )* '?=' ( WS )* where_expr
{
DebugLocation(525, 13);
// SugarCpp.g:525:13: ( WS )*
try { DebugEnterSubRule(359);
while (true)
{
int alt359=2;
try { DebugEnterDecision(359, false);
int LA359_0 = input.LA(1);
if ((LA359_0==WS))
{
示例2: formulaDeclaration
// $ANTLR start "formulaDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:125:1: formulaDeclaration : entityChainNoFilter assignmentOp expression ';' -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) ) ;
public formulaDeclaration_return formulaDeclaration() // throws RecognitionException [1]
{
var retval = new formulaDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken char_literal36 = null;
entityChainNoFilter_return entityChainNoFilter33 = default( entityChainNoFilter_return );
assignmentOp_return assignmentOp34 = default( assignmentOp_return );
expression_return expression35 = default( expression_return );
CommonTree char_literal36_tree = null;
var stream_63 = new RewriteRuleTokenStream( adaptor, "token 63" );
var stream_entityChainNoFilter = new RewriteRuleSubtreeStream( adaptor, "rule entityChainNoFilter" );
var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
var stream_assignmentOp = new RewriteRuleSubtreeStream( adaptor, "rule assignmentOp" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:2: ( entityChainNoFilter assignmentOp expression ';' -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:4: entityChainNoFilter assignmentOp expression ';'
{
PushFollow( FOLLOW_entityChainNoFilter_in_formulaDeclaration558 );
entityChainNoFilter33 = entityChainNoFilter();
state.followingStackPointer--;
stream_entityChainNoFilter.Add( entityChainNoFilter33.Tree );
PushFollow( FOLLOW_assignmentOp_in_formulaDeclaration560 );
assignmentOp34 = assignmentOp();
state.followingStackPointer--;
stream_assignmentOp.Add( assignmentOp34.Tree );
PushFollow( FOLLOW_expression_in_formulaDeclaration562 );
expression35 = expression();
state.followingStackPointer--;
stream_expression.Add( expression35.Tree );
char_literal36 = (IToken)Match( input, 63, FOLLOW_63_in_formulaDeclaration564 );
stream_63.Add( char_literal36 );
// AST REWRITE
// elements: assignmentOp, entityChainNoFilter, expression
// 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();
// 126:52: -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:55: ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( FORMULA, "FORMULA" ), root_1 );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:66: ^( assignmentOp entityChainNoFilter expression )
{
var root_2 = (CommonTree)adaptor.GetNilNode();
root_2 = (CommonTree)adaptor.BecomeRoot( stream_assignmentOp.NextNode(), root_2 );
adaptor.AddChild( root_2, stream_entityChainNoFilter.NextTree() );
adaptor.AddChild( root_2, stream_expression.NextTree() );
adaptor.AddChild( root_1, root_2 );
}
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 )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
示例3: unaryExpression
//.........这里部分代码省略.........
}
retval.Tree = root_0;retval.Tree = root_0;
}
break;
case 3 :
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:494:4: c= caseExpression
{
PushFollow(FOLLOW_caseExpression_in_unaryExpression2442);
c = caseExpression();
state.followingStackPointer--;
stream_caseExpression.Add(c.Tree);
// AST REWRITE
// elements: c
// token labels:
// rule labels: c, retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_c = new RewriteRuleSubtreeStream(adaptor, "rule c", c!=null ? c.Tree : null);
RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);
root_0 = (IASTNode)adaptor.GetNilNode();
// 494:21: -> ^( $c)
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:494:24: ^( $c)
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot(stream_c.NextNode(), root_1);
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;retval.Tree = root_0;
}
break;
case 4 :
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:495:4: q= quantifiedExpression
{
PushFollow(FOLLOW_quantifiedExpression_in_unaryExpression2456);
q = quantifiedExpression();
state.followingStackPointer--;
stream_quantifiedExpression.Add(q.Tree);
// AST REWRITE
// elements: q
// token labels:
// rule labels: retval, q
// 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);
RewriteRuleSubtreeStream stream_q = new RewriteRuleSubtreeStream(adaptor, "rule q", q!=null ? q.Tree : null);
root_0 = (IASTNode)adaptor.GetNilNode();
// 495:27: -> ^( $q)
示例4: expressionOrVector
// $ANTLR start "expressionOrVector"
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:548:1: expressionOrVector : e= expression (v= vectorExpr )? -> {v != null}? ^( VECTOR_EXPR[\"{vector}\"] $e $v) -> ^( $e) ;
public HqlParser.expressionOrVector_return expressionOrVector() // throws RecognitionException [1]
{
HqlParser.expressionOrVector_return retval = new HqlParser.expressionOrVector_return();
retval.Start = input.LT(1);
IASTNode root_0 = null;
HqlParser.expression_return e = default(HqlParser.expression_return);
HqlParser.vectorExpr_return v = default(HqlParser.vectorExpr_return);
RewriteRuleSubtreeStream stream_vectorExpr = new RewriteRuleSubtreeStream(adaptor,"rule vectorExpr");
RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor,"rule expression");
try
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:549:2: (e= expression (v= vectorExpr )? -> {v != null}? ^( VECTOR_EXPR[\"{vector}\"] $e $v) -> ^( $e) )
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:549:4: e= expression (v= vectorExpr )?
{
PushFollow(FOLLOW_expression_in_expressionOrVector2861);
e = expression();
state.followingStackPointer--;
stream_expression.Add(e.Tree);
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:549:17: (v= vectorExpr )?
int alt82 = 2;
int LA82_0 = input.LA(1);
if ( (LA82_0 == COMMA) )
{
alt82 = 1;
}
switch (alt82)
{
case 1 :
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:549:19: v= vectorExpr
{
PushFollow(FOLLOW_vectorExpr_in_expressionOrVector2867);
v = vectorExpr();
state.followingStackPointer--;
stream_vectorExpr.Add(v.Tree);
}
break;
}
// AST REWRITE
// elements: e, v, e
// token labels:
// rule labels: retval, v, e
// 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);
RewriteRuleSubtreeStream stream_v = new RewriteRuleSubtreeStream(adaptor, "rule v", v!=null ? v.Tree : null);
RewriteRuleSubtreeStream stream_e = new RewriteRuleSubtreeStream(adaptor, "rule e", e!=null ? e.Tree : null);
root_0 = (IASTNode)adaptor.GetNilNode();
// 550:2: -> {v != null}? ^( VECTOR_EXPR[\"{vector}\"] $e $v)
if (v != null)
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:550:18: ^( VECTOR_EXPR[\"{vector}\"] $e $v)
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(VECTOR_EXPR, "{vector}"), root_1);
adaptor.AddChild(root_1, stream_e.NextTree());
adaptor.AddChild(root_1, stream_v.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
else // 551:2: -> ^( $e)
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:551:5: ^( $e)
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot(stream_e.NextNode(), root_1);
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;retval.Tree = root_0;
}
retval.Stop = input.LT(-1);
retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
}
//.........这里部分代码省略.........
示例5: propertyname
//.........这里部分代码省略.........
// C:\\projects\\LinqToQuerystring\\LinqToQuerystring\\LinqToQuerystring.g:111:49: ( '/' next= subpropertyname[false] -> ^( $propertyname $next) )?
int alt25=2;
try { DebugEnterSubRule(25);
try { DebugEnterDecision(25, false);
int LA25_1 = input.LA(1);
if ((LA25_1==74))
{
int LA25_2 = input.LA(2);
if ((LA25_2==DYNAMICIDENTIFIER||LA25_2==IDENTIFIER))
{
alt25 = 1;
}
}
} finally { DebugExitDecision(25); }
switch (alt25)
{
case 1:
DebugEnterAlt(1);
// C:\\projects\\LinqToQuerystring\\LinqToQuerystring\\LinqToQuerystring.g:111:50: '/' next= subpropertyname[false]
{
DebugLocation(111, 50);
char_literal90=(IToken)Match(input,74,Follow._74_in_propertyname879);
stream_74.Add(char_literal90);
DebugLocation(111, 58);
PushFollow(Follow._subpropertyname_in_propertyname883);
next=subpropertyname(false);
PopFollow();
stream_subpropertyname.Add(next.Tree);
{
// AST REWRITE
// elements: propertyname, next
// token labels:
// rule labels: next, retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
RewriteRuleSubtreeStream stream_next=new RewriteRuleSubtreeStream(adaptor,"rule next",next!=null?next.Tree:null);
RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);
root_0 = (object)adaptor.Nil();
// 111:82: -> ^( $propertyname $next)
{
DebugLocation(111, 85);
// C:\\projects\\LinqToQuerystring\\LinqToQuerystring\\LinqToQuerystring.g:111:85: ^( $propertyname $next)
{
object root_1 = (object)adaptor.Nil();
DebugLocation(111, 88);
root_1 = (object)adaptor.BecomeRoot(stream_retval.NextNode(), root_1);
DebugLocation(111, 102);
adaptor.AddChild(root_1, stream_next.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
break;
}
} finally { DebugExitSubRule(25); }
}
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("propertyname", 22);
LeaveRule("propertyname", 22);
LeaveRule_propertyname();
}
DebugLocation(111, 108);
} finally { DebugExitRule(GrammarFileName, "propertyname"); }
return retval;
}
示例6: negatedExpression
//.........这里部分代码省略.........
throw nvae_d47s0;
}
switch (alt47)
{
case 1 :
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:375:4: NOT x= negatedExpression
{
NOT148=(IToken)Match(input,NOT,FOLLOW_NOT_in_negatedExpression1854);
stream_NOT.Add(NOT148);
PushFollow(FOLLOW_negatedExpression_in_negatedExpression1858);
x = negatedExpression();
state.followingStackPointer--;
stream_negatedExpression.Add(x.Tree);
// AST REWRITE
// elements:
// 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 = (IASTNode)adaptor.GetNilNode();
// 376:3: -> ^()
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:376:6: ^()
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot(NegateNode(((x != null) ? ((IASTNode)x.Tree) : null)), root_1);
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;retval.Tree = root_0;
}
break;
case 2 :
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:377:4: equalityExpression
{
PushFollow(FOLLOW_equalityExpression_in_negatedExpression1871);
equalityExpression149 = equalityExpression();
state.followingStackPointer--;
stream_equalityExpression.Add(equalityExpression149.Tree);
// AST REWRITE
// elements: equalityExpression
// 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 = (IASTNode)adaptor.GetNilNode();
// 378:3: -> ^( equalityExpression )
{
// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:378:6: ^( equalityExpression )
{
IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
root_1 = (IASTNode)adaptor.BecomeRoot(stream_equalityExpression.NextNode(), root_1);
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT(-1);
retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
// Conversion of the second argument necessary, but harmless
retval.Tree = (IASTNode)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);
}
finally
{
}
return retval;
}
示例7: CheckRRSubtreeStreamBehaviourWhileEmpty1
public void CheckRRSubtreeStreamBehaviourWhileEmpty1() {
string description = "RewriteRuleSubtreeStream test";
RewriteRuleSubtreeStream subtreeTest =
new RewriteRuleSubtreeStream(CreateTreeAdaptor(), description);
Assert.IsFalse(subtreeTest.HasNext(), "HasNext() has to give back false here.");
Assert.AreEqual(description.ToString(), subtreeTest.Description,
"Description strings should be equal.");
Assert.AreEqual(0, subtreeTest.Size(), "The number of elements should be zero.");
subtreeTest.Reset();
Assert.IsTrue(true, "Reset() shouldn't make any problems here.");
Assert.AreEqual(0, subtreeTest.Size(),
"The number of elements should be still zero.");
subtreeTest.NextNode();
}
示例8: CheckRRSubtreeStreamBehaviourWithElements
public void CheckRRSubtreeStreamBehaviourWithElements() {
RewriteRuleSubtreeStream subtreeTest =
new RewriteRuleSubtreeStream(CreateTreeAdaptor(),
"RewriteRuleSubtreeStream test");
IToken token1 = CreateToken(1, "test token without any real context");
ITree tree1 = CreateTree(token1);
// Test Add()
subtreeTest.Add(tree1);
Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (1).");
Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (1).");
// Test NextNode()
Assert.AreEqual(tree1, (ITree) subtreeTest.NextNode(),
"The returned tree should be equal to the given tree (1).");
Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (2).");
Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (1).");
subtreeTest.Reset();
Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (3).");
Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (2).");
// Test NextTree()
CommonTree returnedTree = (CommonTree) subtreeTest.NextTree();
Assert.AreEqual(token1, returnedTree.Token,
"The returned token should be equal to the given token (3).");
Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (4).");
Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (2).");
subtreeTest.Reset();
Assert.AreEqual(1, subtreeTest.Size(), "subtreeTest should have the size 1 (5).");
Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (3).");
// Test, what happens with two elements
IToken token2 = CreateToken(2, "test token without any real context");
ITree tree2 = CreateTree(token2);
subtreeTest.Add(tree2);
Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (1).");
Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (4).");
returnedTree = (CommonTree) subtreeTest.NextTree();
Assert.AreEqual(token1, returnedTree.Token,
"The returned token should be equal to the given token (4).");
Assert.AreEqual(2, subtreeTest.Size(), "subtreeTest should have the size 2 (2).");
Assert.IsTrue(subtreeTest.HasNext(), "HasNext() should be true here (5).");
returnedTree = (CommonTree) subtreeTest.NextTree();
Assert.AreEqual(token2, returnedTree.Token,
"The returned token should be equal to the given token (5).");
Assert.IsFalse(subtreeTest.HasNext(), "HasNext() should be false here (3).");
// Test exception
subtreeTest.NextTree();
}
示例9: varsDecl
//.........这里部分代码省略.........
}
switch (alt11)
{
case 1 :
// MathExpr.g:109:27: ',' varDecl
{
char_literal41=(IToken)Match(input,50,FOLLOW_50_in_varsDecl1189); if (state.failed) return retval;
if ( (state.backtracking==0) ) stream_50.Add(char_literal41);
PushFollow(FOLLOW_varDecl_in_varsDecl1191);
varDecl42 = varDecl();
state.followingStackPointer--;
if (state.failed) return retval;
if ( (state.backtracking==0) ) stream_varDecl.Add(varDecl42.Tree);
}
break;
default:
goto loop11;
}
} while (true);
loop11:
; // Stops C# compiler whining that label 'loop11' has no statements
// AST REWRITE
// elements: ident, varDecl
// 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 = (AstNode)adaptor.GetNilNode();
// 109:42: -> ^( VAR ^( ident ( varDecl )+ ) )
{
// MathExpr.g:109:45: ^( VAR ^( ident ( varDecl )+ ) )
{
AstNode root_1 = (AstNode)adaptor.GetNilNode();
root_1 = (AstNode)adaptor.BecomeRoot((AstNode)adaptor.Create(VAR, "VAR"), root_1);
// MathExpr.g:109:51: ^( ident ( varDecl )+ )
{
AstNode root_2 = (AstNode)adaptor.GetNilNode();
root_2 = (AstNode)adaptor.BecomeRoot(stream_ident.NextNode(), root_2);
if ( !(stream_varDecl.HasNext()) ) {
throw new RewriteEarlyExitException();
}
while ( stream_varDecl.HasNext() )
{
adaptor.AddChild(root_2, stream_varDecl.NextTree());
}
stream_varDecl.Reset();
adaptor.AddChild(root_1, root_2);
}
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;retval.Tree = root_0;}
}
retval.Stop = input.LT(-1);
if ( (state.backtracking==0) )
{ retval.Tree = (AstNode)adaptor.RulePostProcessing(root_0);
adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);}
}
catch (RecognitionException re)
{
ReportError(re);
Recover(input,re);
// Conversion of the second argument necessary, but harmless
retval.Tree = (AstNode)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);
}
finally
{
if ( state.backtracking > 0 )
{
Memoize(input, 13, varsDecl_StartIndex);
}
}
return retval;
}
示例10: qualifiedIdentExpression
//.........这里部分代码省略.........
{
case 1:
DebugEnterAlt(1);
// Java.g:945:17: arrayDeclarator
{
DebugLocation(945, 17);
PushFollow(Follow._arrayDeclarator_in_qualifiedIdentExpression13696);
arrayDeclarator492=arrayDeclarator();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_arrayDeclarator.Add(arrayDeclarator492.Tree);
{
// AST REWRITE
// elements: arrayDeclarator, qualifiedIdentExpression
// 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();
// 945:57: -> ^( arrayDeclarator $qualifiedIdentExpression)
{
DebugLocation(945, 61);
// Java.g:945:61: ^( arrayDeclarator $qualifiedIdentExpression)
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(945, 63);
root_1 = (CommonTree)adaptor.BecomeRoot(stream_arrayDeclarator.NextNode(), root_1);
DebugLocation(945, 80);
adaptor.AddChild(root_1, stream_retval.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
default:
if (cnt140 >= 1)
goto loop140;
if (state.backtracking>0) {state.failed=true; return retval;}
EarlyExitException eee140 = new EarlyExitException( 140, input );
DebugRecognitionException(eee140);
throw eee140;
}
cnt140++;
}
loop140:
;
} finally { DebugExitSubRule(140); }
示例11: primaryExpression
//.........这里部分代码省略.........
arguments471=arguments();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_arguments.Add(arguments471.Tree);
{
// AST REWRITE
// elements: DOT, SUPER, IDENT, genericTypeArgumentListSimplified, arguments
// 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();
// 917:57: -> ^( METHOD_CALL ^( DOT SUPER IDENT ) genericTypeArgumentListSimplified arguments )
{
DebugLocation(917, 61);
// Java.g:917:61: ^( METHOD_CALL ^( DOT SUPER IDENT ) genericTypeArgumentListSimplified arguments )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(917, 63);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(METHOD_CALL, "METHOD_CALL"), root_1);
DebugLocation(917, 75);
// Java.g:917:75: ^( DOT SUPER IDENT )
{
CommonTree root_2 = (CommonTree)adaptor.Nil();
DebugLocation(917, 77);
root_2 = (CommonTree)adaptor.BecomeRoot(stream_DOT.NextNode(), root_2);
DebugLocation(917, 81);
adaptor.AddChild(root_2, stream_SUPER.NextNode());
DebugLocation(917, 87);
adaptor.AddChild(root_2, stream_IDENT.NextNode());
adaptor.AddChild(root_1, root_2);
}
DebugLocation(917, 94);
adaptor.AddChild(root_1, stream_genericTypeArgumentListSimplified.NextTree());
DebugLocation(917, 128);
adaptor.AddChild(root_1, stream_arguments.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
break;
}
} finally { DebugExitSubRule(134); }
}
break;
case 2:
示例12: expr
//.........这里部分代码省略.........
state.followingStackPointer--;
if (state.failed) return retval;
if ( (state.backtracking==0) ) stream_groupExpr.Add(groupExpr119.Tree);
}
break;
}
PushFollow(FOLLOW_expr_in_expr1743);
expr120 = expr();
state.followingStackPointer--;
if (state.failed) return retval;
if ( (state.backtracking==0) ) stream_expr.Add(expr120.Tree);
// AST REWRITE
// elements: term, FOR, IDENT, groupExpr, ASSIGN, VAR, compare, 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 = (AstNode)adaptor.GetNilNode();
// 193:69: -> ^( FOR ( ^( VAR ^( IDENT TYPE ^( ASSIGN term ) ) ) )? ( compare )? ( groupExpr )? expr )
{
// MathExpr.g:193:72: ^( FOR ( ^( VAR ^( IDENT TYPE ^( ASSIGN term ) ) ) )? ( compare )? ( groupExpr )? expr )
{
AstNode root_1 = (AstNode)adaptor.GetNilNode();
root_1 = (AstNode)adaptor.BecomeRoot(stream_FOR.NextNode(), root_1);
// MathExpr.g:193:78: ( ^( VAR ^( IDENT TYPE ^( ASSIGN term ) ) ) )?
if ( stream_term.HasNext() || stream_IDENT.HasNext() || stream_ASSIGN.HasNext() || stream_VAR.HasNext() )
{
// MathExpr.g:193:78: ^( VAR ^( IDENT TYPE ^( ASSIGN term ) ) )
{
AstNode root_2 = (AstNode)adaptor.GetNilNode();
root_2 = (AstNode)adaptor.BecomeRoot(stream_VAR.NextNode(), root_2);
// MathExpr.g:193:84: ^( IDENT TYPE ^( ASSIGN term ) )
{
AstNode root_3 = (AstNode)adaptor.GetNilNode();
root_3 = (AstNode)adaptor.BecomeRoot(stream_IDENT.NextNode(), root_3);
adaptor.AddChild(root_3, (AstNode)adaptor.Create(TYPE, "TYPE"));
// MathExpr.g:193:97: ^( ASSIGN term )
{
AstNode root_4 = (AstNode)adaptor.GetNilNode();
root_4 = (AstNode)adaptor.BecomeRoot(stream_ASSIGN.NextNode(), root_4);
adaptor.AddChild(root_4, stream_term.NextTree());
adaptor.AddChild(root_3, root_4);
}
adaptor.AddChild(root_2, root_3);
}
adaptor.AddChild(root_1, root_2);
}
}
示例13: var_element
//.........这里部分代码省略.........
if (state.failed) return retval;
if ( (state.backtracking==0) ) stream_arrayValue.Add(arrayValue67.Tree);
}
break;
}
}
break;
}
// AST REWRITE
// elements: returnValue, arrayValue, ASSIGN, type, add, idar
// 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 = (AstNode)adaptor.GetNilNode();
// 148:94: -> ^( idar ( ^( TYPE type add ) )? ( ^( ASSIGN ( returnValue )? ( ^( ARRAY arrayValue ) )? ) )? )
{
// MathExpr.g:148:97: ^( idar ( ^( TYPE type add ) )? ( ^( ASSIGN ( returnValue )? ( ^( ARRAY arrayValue ) )? ) )? )
{
AstNode root_1 = (AstNode)adaptor.GetNilNode();
root_1 = (AstNode)adaptor.BecomeRoot(stream_idar.NextNode(), root_1);
// MathExpr.g:148:104: ( ^( TYPE type add ) )?
if ( stream_type.HasNext() || stream_add.HasNext() )
{
// MathExpr.g:148:104: ^( TYPE type add )
{
AstNode root_2 = (AstNode)adaptor.GetNilNode();
root_2 = (AstNode)adaptor.BecomeRoot((AstNode)adaptor.Create(TYPE, "TYPE"), root_2);
adaptor.AddChild(root_2, stream_type.NextTree());
adaptor.AddChild(root_2, stream_add.NextTree());
adaptor.AddChild(root_1, root_2);
}
}
stream_type.Reset();
stream_add.Reset();
// MathExpr.g:148:122: ( ^( ASSIGN ( returnValue )? ( ^( ARRAY arrayValue ) )? ) )?
if ( stream_returnValue.HasNext() || stream_arrayValue.HasNext() || stream_ASSIGN.HasNext() )
{
// MathExpr.g:148:122: ^( ASSIGN ( returnValue )? ( ^( ARRAY arrayValue ) )? )
{
AstNode root_2 = (AstNode)adaptor.GetNilNode();
root_2 = (AstNode)adaptor.BecomeRoot(stream_ASSIGN.NextNode(), root_2);
// MathExpr.g:148:131: ( returnValue )?
if ( stream_returnValue.HasNext() )
{
adaptor.AddChild(root_2, stream_returnValue.NextTree());
}