// $ANTLR start "expressionNoIn" // EcmaScriptV3.g:1133:1: expressionNoIn : exprs+= assignmentExpressionNoIn ( COMMA exprs+= assignmentExpressionNoIn )* -> { $exprs.Count > 1 }? ^( CEXPR ( $exprs)+ ) -> $exprs; public EcmaScriptV3Parser.expressionNoIn_return expressionNoIn() // throws RecognitionException [1] { EcmaScriptV3Parser.expressionNoIn_return retval = new EcmaScriptV3Parser.expressionNoIn_return(); retval.Start = input.LT(1); object root_0 = null; IToken COMMA137 = null; IList list_exprs = null; RuleReturnScope exprs = null; object COMMA137_tree=null; RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA"); RewriteRuleSubtreeStream stream_assignmentExpressionNoIn = new RewriteRuleSubtreeStream(adaptor,"rule assignmentExpressionNoIn"); try { // EcmaScriptV3.g:1134:2: (exprs+= assignmentExpressionNoIn ( COMMA exprs+= assignmentExpressionNoIn )* -> { $exprs.Count > 1 }? ^( CEXPR ( $exprs)+ ) -> $exprs) // EcmaScriptV3.g:1134:4: exprs+= assignmentExpressionNoIn ( COMMA exprs+= assignmentExpressionNoIn )* { PushFollow(FOLLOW_assignmentExpressionNoIn_in_expressionNoIn4412); exprs = assignmentExpressionNoIn(); state.followingStackPointer--; stream_assignmentExpressionNoIn.Add(exprs.Tree); if (list_exprs == null) list_exprs = new ArrayList(); list_exprs.Add(exprs.Tree); // EcmaScriptV3.g:1134:36: ( COMMA exprs+= assignmentExpressionNoIn )* do { int alt41 = 2; int LA41_0 = input.LA(1); if ( (LA41_0 == COMMA) ) { alt41 = 1; } switch (alt41) { case 1 : // EcmaScriptV3.g:1134:38: COMMA exprs+= assignmentExpressionNoIn { COMMA137=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_expressionNoIn4416); stream_COMMA.Add(COMMA137); PushFollow(FOLLOW_assignmentExpressionNoIn_in_expressionNoIn4420); exprs = assignmentExpressionNoIn(); state.followingStackPointer--; stream_assignmentExpressionNoIn.Add(exprs.Tree); if (list_exprs == null) list_exprs = new ArrayList(); list_exprs.Add(exprs.Tree); } break; default: goto loop41; } } while (true); loop41: ; // Stops C# compiler whining that label 'loop41' has no statements // AST REWRITE // elements: exprs, exprs // token labels: // rule labels: retval // token list labels: // rule list labels: exprs retval.Tree = root_0; RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null)); RewriteRuleSubtreeStream stream_exprs = new RewriteRuleSubtreeStream(adaptor, "token exprs", list_exprs); root_0 = (object)adaptor.GetNilNode(); // 1135:2: -> { $exprs.Count > 1 }? ^( CEXPR ( $exprs)+ ) if ( list_exprs.Count > 1 ) { // EcmaScriptV3.g:1135:27: ^( CEXPR ( $exprs)+ ) { object root_1 = (object)adaptor.GetNilNode(); root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(CEXPR, "CEXPR"), root_1); if ( !(stream_exprs.HasNext()) ) { throw new RewriteEarlyExitException(); } while ( stream_exprs.HasNext() ) { adaptor.AddChild(root_1, stream_exprs.NextTree()); } stream_exprs.Reset(); adaptor.AddChild(root_0, root_1); } } else // 1136:2: -> $exprs { adaptor.AddChild(root_0, stream_exprs.NextTree()); } retval.Tree = root_0;retval.Tree = root_0; } retval.Stop = input.LT(-1); retval.Tree = (object)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 = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }
public Patch CreatePatch() { int ctr = 0; foreach (Hunk hunk in this) { if (!hunk.Same) { ctr += hunk.Right.Count; } } object[] rightData = new object[ctr]; ArrayList hunks = new ArrayList(); ctr = 0; foreach (Hunk hunk in this) { if (hunk.Same) { hunks.Add(new Patch.Hunk(rightData, hunk.Left.Start, hunk.Left.Count, 0, 0, true)); } else { hunks.Add(new Patch.Hunk(rightData, hunk.Left.Start, hunk.Left.Count, ctr, hunk.Right.Count, false)); foreach (object t in hunk.Right) { rightData[ctr++] = t; } } } return new Patch((Patch.Hunk[]) hunks.ToArray(typeof(Patch.Hunk))); }
// $ANTLR start "formalParameterList" // EcmaScriptV3.g:1514:1: formalParameterList : LPAREN (args+= Identifier ( COMMA args+= Identifier )* )? RPAREN -> ^( ARGS ( $args)* ) ; public EcmaScriptV3Parser.formalParameterList_return formalParameterList() // throws RecognitionException [1] { EcmaScriptV3Parser.formalParameterList_return retval = new EcmaScriptV3Parser.formalParameterList_return(); retval.Start = input.LT(1); object root_0 = null; IToken LPAREN270 = null; IToken COMMA271 = null; IToken RPAREN272 = null; IToken args = null; IList list_args = null; object LPAREN270_tree=null; object COMMA271_tree=null; object RPAREN272_tree=null; object args_tree=null; RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor,"token RPAREN"); RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA"); RewriteRuleTokenStream stream_Identifier = new RewriteRuleTokenStream(adaptor,"token Identifier"); RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor,"token LPAREN"); try { // EcmaScriptV3.g:1515:2: ( LPAREN (args+= Identifier ( COMMA args+= Identifier )* )? RPAREN -> ^( ARGS ( $args)* ) ) // EcmaScriptV3.g:1515:4: LPAREN (args+= Identifier ( COMMA args+= Identifier )* )? RPAREN { LPAREN270=(IToken)Match(input,LPAREN,FOLLOW_LPAREN_in_formalParameterList5706); stream_LPAREN.Add(LPAREN270); // EcmaScriptV3.g:1515:11: (args+= Identifier ( COMMA args+= Identifier )* )? int alt71 = 2; int LA71_0 = input.LA(1); if ( (LA71_0 == Identifier) ) { alt71 = 1; } switch (alt71) { case 1 : // EcmaScriptV3.g:1515:13: args+= Identifier ( COMMA args+= Identifier )* { args=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_formalParameterList5712); stream_Identifier.Add(args); if (list_args == null) list_args = new ArrayList(); list_args.Add(args); // EcmaScriptV3.g:1515:30: ( COMMA args+= Identifier )* do { int alt70 = 2; int LA70_0 = input.LA(1); if ( (LA70_0 == COMMA) ) { alt70 = 1; } switch (alt70) { case 1 : // EcmaScriptV3.g:1515:32: COMMA args+= Identifier { COMMA271=(IToken)Match(input,COMMA,FOLLOW_COMMA_in_formalParameterList5716); stream_COMMA.Add(COMMA271); args=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_formalParameterList5720); stream_Identifier.Add(args); if (list_args == null) list_args = new ArrayList(); list_args.Add(args); } break; default: goto loop70; } } while (true); loop70: ; // Stops C# compiler whining that label 'loop70' has no statements } break; } RPAREN272=(IToken)Match(input,RPAREN,FOLLOW_RPAREN_in_formalParameterList5728); stream_RPAREN.Add(RPAREN272); // AST REWRITE // elements: args // token labels: // rule labels: retval // token list labels: args // rule list labels: retval.Tree = root_0; RewriteRuleTokenStream stream_args = new RewriteRuleTokenStream(adaptor,"token args", list_args); RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null)); root_0 = (object)adaptor.GetNilNode(); // 1516:2: -> ^( ARGS ( $args)* ) { // EcmaScriptV3.g:1516:5: ^( ARGS ( $args)* ) { object root_1 = (object)adaptor.GetNilNode(); root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(ARGS, "ARGS"), root_1); // EcmaScriptV3.g:1516:13: ( $args)* while ( stream_args.HasNext() ) { adaptor.AddChild(root_1, stream_args.NextNode()); } stream_args.Reset(); adaptor.AddChild(root_0, root_1); } } retval.Tree = root_0;retval.Tree = root_0; } retval.Stop = input.LT(-1); retval.Tree = (object)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 = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }