本文整理汇总了C#中AstParserRuleReturnScope类的典型用法代码示例。如果您正苦于以下问题:C# AstParserRuleReturnScope类的具体用法?C# AstParserRuleReturnScope怎么用?C# AstParserRuleReturnScope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AstParserRuleReturnScope类属于命名空间,在下文中一共展示了AstParserRuleReturnScope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsLeftHandSideAssign
/// <summary>
/// Is a RuleReturnScope node candidate for the left-hand-side of an assignment expression?
/// </summary>
/// <param name="lhs">The RuleReturnScope node</param>
/// <param name="cached">The cached result of a former call to this method</param>
/// <returns>True if so, false otherwise</returns>
public bool IsLeftHandSideAssign(AstParserRuleReturnScope<object, IToken> lhs, ref bool? cached)
{
if (cached.HasValue)
{
return cached.Value;
}
bool result;
if (IsLeftHandSideExpression(lhs))
{
switch (input.LA(1))
{
case ASSIGN:
case MULASS:
case DIVASS:
case MODASS:
case ADDASS:
case SUBASS:
case SHLASS:
case SHRASS:
case SHUASS:
case ANDASS:
case XORASS:
case ORASS:
result = true;
break;
default:
result = false;
break;
}
}
else
{
result = false;
}
cached = result;
return result;
}
示例2: IsLeftHandSideExpression
/// <summary>
/// Is a RuleReturnScope node candidate a left-hand-side expression?
/// </summary>
/// <param name="lhs">The RuleReturnScope node</param>
/// <returns>True if so, false otherwise</returns>
private bool IsLeftHandSideExpression(AstParserRuleReturnScope<object, IToken> lhs)
{
if (lhs.Tree == null) // e.g. during backtracking
{
return true;
}
else
{
switch (((ITree)lhs.Tree).Type)
{
// primaryExpression
case THIS:
case Identifier:
case NULL:
case TRUE:
case FALSE:
case DecimalLiteral:
case OctalIntegerLiteral:
case HexIntegerLiteral:
case StringLiteral:
case RegularExpressionLiteral:
case ARRAY:
case OBJECT:
case PAREXPR:
// functionExpression
case FUNCTION:
// newExpression
case NEW:
// leftHandSideExpression
case CALL:
case BYFIELD:
case BYINDEX:
return true;
default:
return false;
}
}
}
示例3: defaultXMLNamespaceStatement
private AstParserRuleReturnScope<CommonTree, IToken> defaultXMLNamespaceStatement()
{
EnterRule_defaultXMLNamespaceStatement();
EnterRule("defaultXMLNamespaceStatement", 70);
TraceIn("defaultXMLNamespaceStatement", 70);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken DEFAULT226 = default(IToken);
IToken XML227 = default(IToken);
IToken NAMESPACE228 = default(IToken);
IToken ASSIGN229 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> expression230 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> semi231 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree DEFAULT226_tree = default(CommonTree);
CommonTree XML227_tree = default(CommonTree);
CommonTree NAMESPACE228_tree = default(CommonTree);
CommonTree ASSIGN229_tree = default(CommonTree);
RewriteRuleITokenStream stream_DEFAULT=new RewriteRuleITokenStream(adaptor,"token DEFAULT");
RewriteRuleITokenStream stream_XML=new RewriteRuleITokenStream(adaptor,"token XML");
RewriteRuleITokenStream stream_NAMESPACE=new RewriteRuleITokenStream(adaptor,"token NAMESPACE");
RewriteRuleITokenStream stream_ASSIGN=new RewriteRuleITokenStream(adaptor,"token ASSIGN");
RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
RewriteRuleSubtreeStream stream_semi=new RewriteRuleSubtreeStream(adaptor,"rule semi");
try { DebugEnterRule(GrammarFileName, "defaultXMLNamespaceStatement");
DebugLocation(562, 1);
try
{
// AS3.g:563:2: ( DEFAULT XML NAMESPACE ASSIGN expression semi -> ^( DEFAULT_XML_NAMESPACE expression ) )
DebugEnterAlt(1);
// AS3.g:563:4: DEFAULT XML NAMESPACE ASSIGN expression semi
{
DebugLocation(563, 4);
DEFAULT226=(IToken)Match(input,DEFAULT,Follow._DEFAULT_in_defaultXMLNamespaceStatement3040); if (state.failed) return retval;
if (state.backtracking == 0) stream_DEFAULT.Add(DEFAULT226);
DebugLocation(563, 12);
XML227=(IToken)Match(input,XML,Follow._XML_in_defaultXMLNamespaceStatement3042); if (state.failed) return retval;
if (state.backtracking == 0) stream_XML.Add(XML227);
DebugLocation(563, 16);
NAMESPACE228=(IToken)Match(input,NAMESPACE,Follow._NAMESPACE_in_defaultXMLNamespaceStatement3044); if (state.failed) return retval;
if (state.backtracking == 0) stream_NAMESPACE.Add(NAMESPACE228);
DebugLocation(563, 26);
ASSIGN229=(IToken)Match(input,ASSIGN,Follow._ASSIGN_in_defaultXMLNamespaceStatement3046); if (state.failed) return retval;
if (state.backtracking == 0) stream_ASSIGN.Add(ASSIGN229);
DebugLocation(563, 33);
PushFollow(Follow._expression_in_defaultXMLNamespaceStatement3048);
expression230=expression();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_expression.Add(expression230.Tree);
DebugLocation(563, 44);
PushFollow(Follow._semi_in_defaultXMLNamespaceStatement3050);
semi231=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_semi.Add(semi231.Tree);
{
// AST REWRITE
// elements: expression
// 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();
// 564:3: -> ^( DEFAULT_XML_NAMESPACE expression )
{
DebugLocation(564, 6);
// AS3.g:564:6: ^( DEFAULT_XML_NAMESPACE expression )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(564, 8);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(DEFAULT_XML_NAMESPACE, "DEFAULT_XML_NAMESPACE"), root_1);
DebugLocation(564, 30);
adaptor.AddChild(root_1, stream_expression.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
//.........这里部分代码省略.........
示例4: doWhileStatement
private AstParserRuleReturnScope<CommonTree, IToken> doWhileStatement()
{
EnterRule_doWhileStatement();
EnterRule("doWhileStatement", 68);
TraceIn("doWhileStatement", 68);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken DO218 = default(IToken);
IToken WHILE220 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> statement219 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> condition221 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> semi222 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree DO218_tree = default(CommonTree);
CommonTree WHILE220_tree = default(CommonTree);
RewriteRuleITokenStream stream_DO=new RewriteRuleITokenStream(adaptor,"token DO");
RewriteRuleITokenStream stream_WHILE=new RewriteRuleITokenStream(adaptor,"token WHILE");
RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
RewriteRuleSubtreeStream stream_condition=new RewriteRuleSubtreeStream(adaptor,"rule condition");
RewriteRuleSubtreeStream stream_semi=new RewriteRuleSubtreeStream(adaptor,"rule semi");
try { DebugEnterRule(GrammarFileName, "doWhileStatement");
DebugLocation(553, 1);
try
{
// AS3.g:554:2: ( DO statement WHILE condition semi -> ^( DO_WHILE_LOOP DO statement WHILE condition ) )
DebugEnterAlt(1);
// AS3.g:554:4: DO statement WHILE condition semi
{
DebugLocation(554, 4);
DO218=(IToken)Match(input,DO,Follow._DO_in_doWhileStatement2989); if (state.failed) return retval;
if (state.backtracking == 0) stream_DO.Add(DO218);
DebugLocation(554, 7);
PushFollow(Follow._statement_in_doWhileStatement2991);
statement219=statement();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_statement.Add(statement219.Tree);
DebugLocation(554, 17);
WHILE220=(IToken)Match(input,WHILE,Follow._WHILE_in_doWhileStatement2993); if (state.failed) return retval;
if (state.backtracking == 0) stream_WHILE.Add(WHILE220);
DebugLocation(554, 23);
PushFollow(Follow._condition_in_doWhileStatement2995);
condition221=condition();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_condition.Add(condition221.Tree);
DebugLocation(554, 33);
PushFollow(Follow._semi_in_doWhileStatement2997);
semi222=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_semi.Add(semi222.Tree);
{
// AST REWRITE
// elements: DO, statement, WHILE, condition
// 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();
// 555:3: -> ^( DO_WHILE_LOOP DO statement WHILE condition )
{
DebugLocation(555, 6);
// AS3.g:555:6: ^( DO_WHILE_LOOP DO statement WHILE condition )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(555, 8);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(DO_WHILE_LOOP, "DO_WHILE_LOOP"), root_1);
DebugLocation(555, 22);
adaptor.AddChild(root_1, stream_DO.NextNode());
DebugLocation(555, 25);
adaptor.AddChild(root_1, stream_statement.NextTree());
DebugLocation(555, 35);
adaptor.AddChild(root_1, stream_WHILE.NextNode());
DebugLocation(555, 41);
adaptor.AddChild(root_1, stream_condition.NextTree());
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
//.........这里部分代码省略.........
示例5: forIter
private AstParserRuleReturnScope<CommonTree, IToken> forIter()
{
EnterRule_forIter();
EnterRule("forIter", 66);
TraceIn("forIter", 66);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
AstParserRuleReturnScope<CommonTree, IToken> expressionList214 = default(AstParserRuleReturnScope<CommonTree, IToken>);
RewriteRuleSubtreeStream stream_expressionList=new RewriteRuleSubtreeStream(adaptor,"rule expressionList");
try { DebugEnterRule(GrammarFileName, "forIter");
DebugLocation(543, 1);
try
{
// AS3.g:544:2: ( ( expressionList )? -> ^( FOR_ITERATOR ( expressionList )? ) )
DebugEnterAlt(1);
// AS3.g:544:4: ( expressionList )?
{
DebugLocation(544, 4);
// AS3.g:544:4: ( expressionList )?
int alt48=2;
try { DebugEnterSubRule(48);
try { DebugEnterDecision(48, false);
int LA48_1 = input.LA(1);
if ((LA48_1==AS||LA48_1==BNOT||(LA48_1>=DEC && LA48_1<=DECIMAL_LITERAL)||(LA48_1>=DYNAMIC && LA48_1<=E4X_ATTRI)||(LA48_1>=FALSE && LA48_1<=FLOAT_LITERAL)||LA48_1==FUNCTION||LA48_1==GET||(LA48_1>=HEX_LITERAL && LA48_1<=IDENT)||LA48_1==INC||(LA48_1>=INTERNAL && LA48_1<=IS)||(LA48_1>=LBRACK && LA48_1<=LCURLY)||LA48_1==LNOT||LA48_1==LPAREN||LA48_1==MINUS||LA48_1==NAMESPACE||LA48_1==NEW||LA48_1==NULL||LA48_1==OCTAL_LITERAL||LA48_1==PLUS||LA48_1==PRIVATE||(LA48_1>=PROTECTED && LA48_1<=PUBLIC)||LA48_1==REGEX_LITERAL||LA48_1==SET||(LA48_1>=STRING_LITERAL_DOUBLE && LA48_1<=SUPER)||LA48_1==TRUE||LA48_1==USE||LA48_1==XML||LA48_1==XML_LITERAL||LA48_1==243||(LA48_1>=255 && LA48_1<=257)))
{
alt48 = 1;
}
} finally { DebugExitDecision(48); }
switch (alt48)
{
case 1:
DebugEnterAlt(1);
// AS3.g:544:4: expressionList
{
DebugLocation(544, 4);
PushFollow(Follow._expressionList_in_forIter2939);
expressionList214=expressionList();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_expressionList.Add(expressionList214.Tree);
}
break;
}
} finally { DebugExitSubRule(48); }
{
// AST REWRITE
// elements: expressionList
// 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();
// 545:3: -> ^( FOR_ITERATOR ( expressionList )? )
{
DebugLocation(545, 6);
// AS3.g:545:6: ^( FOR_ITERATOR ( expressionList )? )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(545, 8);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(FOR_ITERATOR, "FOR_ITERATOR"), root_1);
DebugLocation(545, 21);
// AS3.g:545:21: ( expressionList )?
if (stream_expressionList.HasNext)
{
DebugLocation(545, 21);
adaptor.AddChild(root_1, stream_expressionList.NextTree());
}
stream_expressionList.Reset();
adaptor.AddChild(root_0, root_1);
}
}
retval.Tree = root_0;
}
}
}
retval.Stop = (IToken)input.LT(-1);
if (state.backtracking == 0) {
//.........这里部分代码省略.........
示例6: forInClauseDecl
private AstParserRuleReturnScope<CommonTree, IToken> forInClauseDecl()
{
EnterRule_forInClauseDecl();
EnterRule("forInClauseDecl", 62);
TraceIn("forInClauseDecl", 62);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
AstParserRuleReturnScope<CommonTree, IToken> varOrConst206 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> ident207 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> typeExpression208 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> ident209 = default(AstParserRuleReturnScope<CommonTree, IToken>);
try { DebugEnterRule(GrammarFileName, "forInClauseDecl");
DebugLocation(522, 1);
try
{
// AS3.g:523:2: ( varOrConst ident ( typeExpression )? | ident )
int alt45=2;
try { DebugEnterDecision(45, false);
int LA45_1 = input.LA(1);
if ((LA45_1==CONST||LA45_1==VAR))
{
alt45 = 1;
}
else if ((LA45_1==AS||LA45_1==DYNAMIC||LA45_1==GET||LA45_1==IDENT||LA45_1==IS||LA45_1==NAMESPACE||LA45_1==SET||LA45_1==SUPER||LA45_1==USE||LA45_1==XML))
{
alt45 = 2;
}
else
{
if (state.backtracking>0) {state.failed=true; return retval;}
NoViableAltException nvae = new NoViableAltException("", 45, 0, input, 1);
DebugRecognitionException(nvae);
throw nvae;
}
} finally { DebugExitDecision(45); }
switch (alt45)
{
case 1:
DebugEnterAlt(1);
// AS3.g:523:4: varOrConst ident ( typeExpression )?
{
root_0 = (CommonTree)adaptor.Nil();
DebugLocation(523, 4);
PushFollow(Follow._varOrConst_in_forInClauseDecl2840);
varOrConst206=varOrConst();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, varOrConst206.Tree);
DebugLocation(523, 15);
PushFollow(Follow._ident_in_forInClauseDecl2842);
ident207=ident();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, ident207.Tree);
DebugLocation(523, 21);
// AS3.g:523:21: ( typeExpression )?
int alt44=2;
try { DebugEnterSubRule(44);
try { DebugEnterDecision(44, false);
int LA44_1 = input.LA(1);
if ((LA44_1==COLON))
{
alt44 = 1;
}
} finally { DebugExitDecision(44); }
switch (alt44)
{
case 1:
DebugEnterAlt(1);
// AS3.g:523:21: typeExpression
{
DebugLocation(523, 21);
PushFollow(Follow._typeExpression_in_forInClauseDecl2844);
typeExpression208=typeExpression();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, typeExpression208.Tree);
}
break;
}
} finally { DebugExitSubRule(44); }
}
break;
case 2:
DebugEnterAlt(2);
// AS3.g:524:11: ident
{
root_0 = (CommonTree)adaptor.Nil();
//.........这里部分代码省略.........
示例7: traditionalForClause
private AstParserRuleReturnScope<CommonTree, IToken> traditionalForClause()
{
EnterRule_traditionalForClause();
EnterRule("traditionalForClause", 60);
TraceIn("traditionalForClause", 60);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
AstParserRuleReturnScope<CommonTree, IToken> forInit198 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> semi199 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> forCond200 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> semi201 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> forIter202 = default(AstParserRuleReturnScope<CommonTree, IToken>);
try { DebugEnterRule(GrammarFileName, "traditionalForClause");
DebugLocation(512, 1);
try
{
// AS3.g:513:2: ( forInit semi forCond semi forIter )
DebugEnterAlt(1);
// AS3.g:513:4: forInit semi forCond semi forIter
{
root_0 = (CommonTree)adaptor.Nil();
DebugLocation(513, 4);
PushFollow(Follow._forInit_in_traditionalForClause2795);
forInit198=forInit();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, forInit198.Tree);
DebugLocation(513, 13);
PushFollow(Follow._semi_in_traditionalForClause2798);
semi199=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, semi199.Tree);
DebugLocation(514, 3);
PushFollow(Follow._forCond_in_traditionalForClause2803);
forCond200=forCond();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, forCond200.Tree);
DebugLocation(514, 12);
PushFollow(Follow._semi_in_traditionalForClause2806);
semi201=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, semi201.Tree);
DebugLocation(515, 3);
PushFollow(Follow._forIter_in_traditionalForClause2811);
forIter202=forIter();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, forIter202.Tree);
}
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("traditionalForClause", 60);
LeaveRule("traditionalForClause", 60);
LeaveRule_traditionalForClause();
}
DebugLocation(516, 1);
} finally { DebugExitRule(GrammarFileName, "traditionalForClause"); }
return retval;
}
示例8: forStatement
private AstParserRuleReturnScope<CommonTree, IToken> forStatement()
{
EnterRule_forStatement();
EnterRule("forStatement", 59);
TraceIn("forStatement", 59);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken FOR190 = default(IToken);
IToken LPAREN191 = default(IToken);
IToken RPAREN193 = default(IToken);
IToken RPAREN196 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> forInClause192 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> statement194 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> traditionalForClause195 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> statement197 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree FOR190_tree = default(CommonTree);
CommonTree LPAREN191_tree = default(CommonTree);
CommonTree RPAREN193_tree = default(CommonTree);
CommonTree RPAREN196_tree = default(CommonTree);
RewriteRuleITokenStream stream_FOR=new RewriteRuleITokenStream(adaptor,"token FOR");
RewriteRuleITokenStream stream_LPAREN=new RewriteRuleITokenStream(adaptor,"token LPAREN");
RewriteRuleITokenStream stream_RPAREN=new RewriteRuleITokenStream(adaptor,"token RPAREN");
RewriteRuleSubtreeStream stream_forInClause=new RewriteRuleSubtreeStream(adaptor,"rule forInClause");
RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
RewriteRuleSubtreeStream stream_traditionalForClause=new RewriteRuleSubtreeStream(adaptor,"rule traditionalForClause");
try { DebugEnterRule(GrammarFileName, "forStatement");
DebugLocation(500, 1);
try
{
// AS3.g:502:2: ( FOR LPAREN ( forInClause RPAREN statement -> ^( FOR_IN_LOOP FOR LPAREN forInClause RPAREN statement ) | traditionalForClause RPAREN statement -> ^( FOR_LOOP FOR LPAREN traditionalForClause RPAREN statement ) ) )
DebugEnterAlt(1);
// AS3.g:502:4: FOR LPAREN ( forInClause RPAREN statement -> ^( FOR_IN_LOOP FOR LPAREN forInClause RPAREN statement ) | traditionalForClause RPAREN statement -> ^( FOR_LOOP FOR LPAREN traditionalForClause RPAREN statement ) )
{
DebugLocation(502, 4);
FOR190=(IToken)Match(input,FOR,Follow._FOR_in_forStatement2717); if (state.failed) return retval;
if (state.backtracking == 0) stream_FOR.Add(FOR190);
DebugLocation(503, 3);
LPAREN191=(IToken)Match(input,LPAREN,Follow._LPAREN_in_forStatement2721); if (state.failed) return retval;
if (state.backtracking == 0) stream_LPAREN.Add(LPAREN191);
DebugLocation(504, 3);
// AS3.g:504:3: ( forInClause RPAREN statement -> ^( FOR_IN_LOOP FOR LPAREN forInClause RPAREN statement ) | traditionalForClause RPAREN statement -> ^( FOR_LOOP FOR LPAREN traditionalForClause RPAREN statement ) )
int alt43=2;
try { DebugEnterSubRule(43);
try { DebugEnterDecision(43, false);
try
{
alt43 = dfa43.Predict(input);
}
catch (NoViableAltException nvae)
{
DebugRecognitionException(nvae);
throw;
}
} finally { DebugExitDecision(43); }
switch (alt43)
{
case 1:
DebugEnterAlt(1);
// AS3.g:504:5: forInClause RPAREN statement
{
DebugLocation(504, 5);
PushFollow(Follow._forInClause_in_forStatement2727);
forInClause192=forInClause();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_forInClause.Add(forInClause192.Tree);
DebugLocation(504, 17);
RPAREN193=(IToken)Match(input,RPAREN,Follow._RPAREN_in_forStatement2729); if (state.failed) return retval;
if (state.backtracking == 0) stream_RPAREN.Add(RPAREN193);
DebugLocation(504, 24);
PushFollow(Follow._statement_in_forStatement2731);
statement194=statement();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_statement.Add(statement194.Tree);
{
// AST REWRITE
// elements: FOR, LPAREN, forInClause, RPAREN, statement
// 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();
// 505:4: -> ^( FOR_IN_LOOP FOR LPAREN forInClause RPAREN statement )
{
DebugLocation(505, 7);
//.........这里部分代码省略.........
示例9: returnStatement
private AstParserRuleReturnScope<CommonTree, IToken> returnStatement()
{
EnterRule_returnStatement();
EnterRule("returnStatement", 50);
TraceIn("returnStatement", 50);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken RETURN168 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> s = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> expression169 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree RETURN168_tree = default(CommonTree);
RewriteRuleITokenStream stream_RETURN=new RewriteRuleITokenStream(adaptor,"token RETURN");
RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
RewriteRuleSubtreeStream stream_semi=new RewriteRuleSubtreeStream(adaptor,"rule semi");
try { DebugEnterRule(GrammarFileName, "returnStatement");
DebugLocation(450, 1);
try
{
// AS3.g:451:2: ( RETURN ( expression )? s= semi -> ^( RETURN_STATEMENT RETURN ( expression )? ) )
DebugEnterAlt(1);
// AS3.g:451:4: RETURN ( expression )? s= semi
{
DebugLocation(451, 4);
RETURN168=(IToken)Match(input,RETURN,Follow._RETURN_in_returnStatement2421); if (state.failed) return retval;
if (state.backtracking == 0) stream_RETURN.Add(RETURN168);
DebugLocation(451, 11);
// AS3.g:451:11: ( expression )?
int alt39=2;
try { DebugEnterSubRule(39);
try { DebugEnterDecision(39, false);
int LA39_1 = input.LA(1);
if ((LA39_1==AS||LA39_1==BNOT||(LA39_1>=DEC && LA39_1<=DECIMAL_LITERAL)||(LA39_1>=DYNAMIC && LA39_1<=E4X_ATTRI)||(LA39_1>=FALSE && LA39_1<=FLOAT_LITERAL)||LA39_1==FUNCTION||LA39_1==GET||(LA39_1>=HEX_LITERAL && LA39_1<=IDENT)||LA39_1==INC||(LA39_1>=INTERNAL && LA39_1<=IS)||(LA39_1>=LBRACK && LA39_1<=LCURLY)||LA39_1==LNOT||LA39_1==LPAREN||LA39_1==MINUS||LA39_1==NAMESPACE||LA39_1==NEW||LA39_1==NULL||LA39_1==OCTAL_LITERAL||LA39_1==PLUS||LA39_1==PRIVATE||(LA39_1>=PROTECTED && LA39_1<=PUBLIC)||LA39_1==REGEX_LITERAL||LA39_1==SET||(LA39_1>=STRING_LITERAL_DOUBLE && LA39_1<=SUPER)||LA39_1==TRUE||LA39_1==USE||LA39_1==XML||LA39_1==XML_LITERAL||LA39_1==243||(LA39_1>=255 && LA39_1<=257)))
{
alt39 = 1;
}
} finally { DebugExitDecision(39); }
switch (alt39)
{
case 1:
DebugEnterAlt(1);
// AS3.g:451:11: expression
{
DebugLocation(451, 11);
PushFollow(Follow._expression_in_returnStatement2423);
expression169=expression();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_expression.Add(expression169.Tree);
}
break;
}
} finally { DebugExitSubRule(39); }
DebugLocation(451, 24);
PushFollow(Follow._semi_in_returnStatement2428);
s=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_semi.Add(s.Tree);
{
// AST REWRITE
// elements: RETURN, expression
// 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();
// 452:9: -> ^( RETURN_STATEMENT RETURN ( expression )? )
{
DebugLocation(452, 12);
// AS3.g:452:12: ^( RETURN_STATEMENT RETURN ( expression )? )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(452, 14);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(RETURN_STATEMENT, "RETURN_STATEMENT"), root_1);
DebugLocation(452, 31);
adaptor.AddChild(root_1, stream_RETURN.NextNode());
DebugLocation(452, 38);
// AS3.g:452:38: ( expression )?
if (stream_expression.HasNext)
{
DebugLocation(452, 38);
adaptor.AddChild(root_1, stream_expression.NextTree());
//.........这里部分代码省略.........
示例10: finallyBlock
private AstParserRuleReturnScope<CommonTree, IToken> finallyBlock()
{
EnterRule_finallyBlock();
EnterRule("finallyBlock", 49);
TraceIn("finallyBlock", 49);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken string_literal166 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> block167 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree string_literal166_tree = default(CommonTree);
try { DebugEnterRule(GrammarFileName, "finallyBlock");
DebugLocation(446, 1);
try
{
// AS3.g:447:2: ( 'finally' block )
DebugEnterAlt(1);
// AS3.g:447:4: 'finally' block
{
root_0 = (CommonTree)adaptor.Nil();
DebugLocation(447, 4);
string_literal166=(IToken)Match(input,247,Follow._247_in_finallyBlock2408); if (state.failed) return retval;
if (state.backtracking == 0) {
string_literal166_tree = (CommonTree)adaptor.Create(string_literal166);
adaptor.AddChild(root_0, string_literal166_tree);
}
DebugLocation(447, 14);
PushFollow(Follow._block_in_finallyBlock2410);
block167=block();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, block167.Tree);
}
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("finallyBlock", 49);
LeaveRule("finallyBlock", 49);
LeaveRule_finallyBlock();
}
DebugLocation(448, 1);
} finally { DebugExitRule(GrammarFileName, "finallyBlock"); }
return retval;
}
示例11: catchBlock
private AstParserRuleReturnScope<CommonTree, IToken> catchBlock()
{
EnterRule_catchBlock();
EnterRule("catchBlock", 48);
TraceIn("catchBlock", 48);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken string_literal160 = default(IToken);
IToken LPAREN161 = default(IToken);
IToken RPAREN164 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> ident162 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> typeExpression163 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> block165 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree string_literal160_tree = default(CommonTree);
CommonTree LPAREN161_tree = default(CommonTree);
CommonTree RPAREN164_tree = default(CommonTree);
try { DebugEnterRule(GrammarFileName, "catchBlock");
DebugLocation(441, 1);
try
{
// AS3.g:442:2: ( 'catch' LPAREN ident ( typeExpression )? RPAREN block )
DebugEnterAlt(1);
// AS3.g:442:4: 'catch' LPAREN ident ( typeExpression )? RPAREN block
{
root_0 = (CommonTree)adaptor.Nil();
DebugLocation(442, 4);
string_literal160=(IToken)Match(input,242,Follow._242_in_catchBlock2384); if (state.failed) return retval;
if (state.backtracking == 0) {
string_literal160_tree = (CommonTree)adaptor.Create(string_literal160);
adaptor.AddChild(root_0, string_literal160_tree);
}
DebugLocation(442, 12);
LPAREN161=(IToken)Match(input,LPAREN,Follow._LPAREN_in_catchBlock2386); if (state.failed) return retval;
if (state.backtracking == 0) {
LPAREN161_tree = (CommonTree)adaptor.Create(LPAREN161);
adaptor.AddChild(root_0, LPAREN161_tree);
}
DebugLocation(442, 19);
PushFollow(Follow._ident_in_catchBlock2388);
ident162=ident();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, ident162.Tree);
DebugLocation(442, 25);
// AS3.g:442:25: ( typeExpression )?
int alt38=2;
try { DebugEnterSubRule(38);
try { DebugEnterDecision(38, false);
int LA38_1 = input.LA(1);
if ((LA38_1==COLON))
{
alt38 = 1;
}
} finally { DebugExitDecision(38); }
switch (alt38)
{
case 1:
DebugEnterAlt(1);
// AS3.g:442:25: typeExpression
{
DebugLocation(442, 25);
PushFollow(Follow._typeExpression_in_catchBlock2390);
typeExpression163=typeExpression();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, typeExpression163.Tree);
}
break;
}
} finally { DebugExitSubRule(38); }
DebugLocation(442, 41);
RPAREN164=(IToken)Match(input,RPAREN,Follow._RPAREN_in_catchBlock2393); if (state.failed) return retval;
if (state.backtracking == 0) {
RPAREN164_tree = (CommonTree)adaptor.Create(RPAREN164);
adaptor.AddChild(root_0, RPAREN164_tree);
}
DebugLocation(443, 3);
PushFollow(Follow._block_in_catchBlock2397);
block165=block();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) adaptor.AddChild(root_0, block165.Tree);
}
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);
}
//.........这里部分代码省略.........
示例12: tryStatement
private AstParserRuleReturnScope<CommonTree, IToken> tryStatement()
{
EnterRule_tryStatement();
EnterRule("tryStatement", 47);
TraceIn("tryStatement", 47);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken string_literal156 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> block157 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> catchBlock158 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> finallyBlock159 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree string_literal156_tree = default(CommonTree);
RewriteRuleITokenStream stream_254=new RewriteRuleITokenStream(adaptor,"token 254");
RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
RewriteRuleSubtreeStream stream_catchBlock=new RewriteRuleSubtreeStream(adaptor,"rule catchBlock");
RewriteRuleSubtreeStream stream_finallyBlock=new RewriteRuleSubtreeStream(adaptor,"rule finallyBlock");
try { DebugEnterRule(GrammarFileName, "tryStatement");
DebugLocation(433, 1);
try
{
// AS3.g:434:2: ( 'try' block ( catchBlock )* ( finallyBlock )? -> ^( TRY_STATEMENT 'try' block ( catchBlock )* ( finallyBlock )? ) )
DebugEnterAlt(1);
// AS3.g:434:4: 'try' block ( catchBlock )* ( finallyBlock )?
{
DebugLocation(434, 4);
string_literal156=(IToken)Match(input,254,Follow._254_in_tryStatement2335); if (state.failed) return retval;
if (state.backtracking == 0) stream_254.Add(string_literal156);
DebugLocation(435, 3);
PushFollow(Follow._block_in_tryStatement2339);
block157=block();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_block.Add(block157.Tree);
DebugLocation(436, 3);
// AS3.g:436:3: ( catchBlock )*
try { DebugEnterSubRule(36);
while (true)
{
int alt36=2;
try { DebugEnterDecision(36, false);
int LA36_1 = input.LA(1);
if ((LA36_1==242))
{
alt36 = 1;
}
} finally { DebugExitDecision(36); }
switch ( alt36 )
{
case 1:
DebugEnterAlt(1);
// AS3.g:436:3: catchBlock
{
DebugLocation(436, 3);
PushFollow(Follow._catchBlock_in_tryStatement2343);
catchBlock158=catchBlock();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_catchBlock.Add(catchBlock158.Tree);
}
break;
default:
goto loop36;
}
}
loop36:
;
} finally { DebugExitSubRule(36); }
DebugLocation(437, 3);
// AS3.g:437:3: ( finallyBlock )?
int alt37=2;
try { DebugEnterSubRule(37);
try { DebugEnterDecision(37, false);
int LA37_1 = input.LA(1);
if ((LA37_1==247))
{
alt37 = 1;
}
} finally { DebugExitDecision(37); }
switch (alt37)
{
case 1:
DebugEnterAlt(1);
// AS3.g:437:3: finallyBlock
{
DebugLocation(437, 3);
PushFollow(Follow._finallyBlock_in_tryStatement2348);
//.........这里部分代码省略.........
示例13: throwStatement
private AstParserRuleReturnScope<CommonTree, IToken> throwStatement()
{
EnterRule_throwStatement();
EnterRule("throwStatement", 46);
TraceIn("throwStatement", 46);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken string_literal154 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> s = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> expression155 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree string_literal154_tree = default(CommonTree);
RewriteRuleITokenStream stream_253=new RewriteRuleITokenStream(adaptor,"token 253");
RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
RewriteRuleSubtreeStream stream_semi=new RewriteRuleSubtreeStream(adaptor,"rule semi");
try { DebugEnterRule(GrammarFileName, "throwStatement");
DebugLocation(428, 1);
try
{
// AS3.g:429:2: ( 'throw' expression s= semi -> ^( THROW_STATEMENT 'throw' expression ) )
DebugEnterAlt(1);
// AS3.g:429:4: 'throw' expression s= semi
{
DebugLocation(429, 4);
string_literal154=(IToken)Match(input,253,Follow._253_in_throwStatement2298); if (state.failed) return retval;
if (state.backtracking == 0) stream_253.Add(string_literal154);
DebugLocation(429, 12);
PushFollow(Follow._expression_in_throwStatement2300);
expression155=expression();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_expression.Add(expression155.Tree);
DebugLocation(429, 24);
PushFollow(Follow._semi_in_throwStatement2304);
s=semi();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_semi.Add(s.Tree);
{
// AST REWRITE
// elements: 253, expression
// 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();
// 430:9: -> ^( THROW_STATEMENT 'throw' expression )
{
DebugLocation(430, 12);
// AS3.g:430:12: ^( THROW_STATEMENT 'throw' expression )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(430, 14);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(THROW_STATEMENT, "THROW_STATEMENT"), root_1);
DebugLocation(430, 30);
adaptor.AddChild(root_1, stream_253.NextNode());
DebugLocation(430, 38);
adaptor.AddChild(root_1, stream_expression.NextTree());
DebugLocation(430, 49);
adaptor.AddChild(root_1, maybeSemi(s));
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
{
//.........这里部分代码省略.........
示例14: elseClause
private AstParserRuleReturnScope<CommonTree, IToken> elseClause()
{
EnterRule_elseClause();
EnterRule("elseClause", 45);
TraceIn("elseClause", 45);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken ELSE152 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> statement153 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree ELSE152_tree = default(CommonTree);
RewriteRuleITokenStream stream_ELSE=new RewriteRuleITokenStream(adaptor,"token ELSE");
RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
try { DebugEnterRule(GrammarFileName, "elseClause");
DebugLocation(423, 1);
try
{
// AS3.g:424:2: ( ELSE statement -> ^( ELSE_CLAUSE ELSE statement ) )
DebugEnterAlt(1);
// AS3.g:424:4: ELSE statement
{
DebugLocation(424, 4);
ELSE152=(IToken)Match(input,ELSE,Follow._ELSE_in_elseClause2266); if (state.failed) return retval;
if (state.backtracking == 0) stream_ELSE.Add(ELSE152);
DebugLocation(424, 9);
PushFollow(Follow._statement_in_elseClause2268);
statement153=statement();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_statement.Add(statement153.Tree);
{
// AST REWRITE
// elements: ELSE, statement
// 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();
// 425:9: -> ^( ELSE_CLAUSE ELSE statement )
{
DebugLocation(425, 12);
// AS3.g:425:12: ^( ELSE_CLAUSE ELSE statement )
{
CommonTree root_1 = (CommonTree)adaptor.Nil();
DebugLocation(425, 14);
root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(ELSE_CLAUSE, "ELSE_CLAUSE"), root_1);
DebugLocation(425, 26);
adaptor.AddChild(root_1, stream_ELSE.NextNode());
DebugLocation(425, 31);
adaptor.AddChild(root_1, stream_statement.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("elseClause", 45);
LeaveRule("elseClause", 45);
LeaveRule_elseClause();
}
DebugLocation(426, 1);
} finally { DebugExitRule(GrammarFileName, "elseClause"); }
return retval;
}
示例15: ifStatement
private AstParserRuleReturnScope<CommonTree, IToken> ifStatement()
{
EnterRule_ifStatement();
EnterRule("ifStatement", 44);
TraceIn("ifStatement", 44);
AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
retval.Start = (IToken)input.LT(1);
CommonTree root_0 = default(CommonTree);
IToken IF148 = default(IToken);
AstParserRuleReturnScope<CommonTree, IToken> condition149 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> statement150 = default(AstParserRuleReturnScope<CommonTree, IToken>);
AstParserRuleReturnScope<CommonTree, IToken> elseClause151 = default(AstParserRuleReturnScope<CommonTree, IToken>);
CommonTree IF148_tree = default(CommonTree);
RewriteRuleITokenStream stream_IF=new RewriteRuleITokenStream(adaptor,"token IF");
RewriteRuleSubtreeStream stream_condition=new RewriteRuleSubtreeStream(adaptor,"rule condition");
RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
RewriteRuleSubtreeStream stream_elseClause=new RewriteRuleSubtreeStream(adaptor,"rule elseClause");
try { DebugEnterRule(GrammarFileName, "ifStatement");
DebugLocation(417, 1);
try
{
// AS3.g:418:2: ( IF condition statement ( ( ELSE )=> elseClause )? -> ^( IF_STMT IF condition statement ( elseClause )? ) )
DebugEnterAlt(1);
// AS3.g:418:4: IF condition statement ( ( ELSE )=> elseClause )?
{
DebugLocation(418, 4);
IF148=(IToken)Match(input,IF,Follow._IF_in_ifStatement2217); if (state.failed) return retval;
if (state.backtracking == 0) stream_IF.Add(IF148);
DebugLocation(418, 7);
PushFollow(Follow._condition_in_ifStatement2219);
condition149=condition();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_condition.Add(condition149.Tree);
DebugLocation(418, 17);
PushFollow(Follow._statement_in_ifStatement2221);
statement150=statement();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_statement.Add(statement150.Tree);
DebugLocation(419, 3);
// AS3.g:419:3: ( ( ELSE )=> elseClause )?
int alt35=2;
try { DebugEnterSubRule(35);
try { DebugEnterDecision(35, false);
int LA35_1 = input.LA(1);
if ((LA35_1==ELSE))
{
int LA35_2 = input.LA(2);
if ((EvaluatePredicate(synpred14_AS3_fragment)))
{
alt35 = 1;
}
}
} finally { DebugExitDecision(35); }
switch (alt35)
{
case 1:
DebugEnterAlt(1);
// AS3.g:419:4: ( ELSE )=> elseClause
{
DebugLocation(419, 12);
PushFollow(Follow._elseClause_in_ifStatement2230);
elseClause151=elseClause();
PopFollow();
if (state.failed) return retval;
if (state.backtracking == 0) stream_elseClause.Add(elseClause151.Tree);
}
break;
}
} finally { DebugExitSubRule(35); }
{
// AST REWRITE
// elements: IF, condition, statement, elseClause
// 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();
// 420:9: -> ^( IF_STMT IF condition statement ( elseClause )? )
{
DebugLocation(420, 12);
// AS3.g:420:12: ^( IF_STMT IF condition statement ( elseClause )? )
{
//.........这里部分代码省略.........