コード例 #1
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> objectLiteral()
	{
		EnterRule_objectLiteral();
		EnterRule("objectLiteral", 78);
		TraceIn("objectLiteral", 78);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int objectLiteral_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken char_literal408 = default(IToken);
		IToken LT409 = default(IToken);
		IToken LT411 = default(IToken);
		IToken char_literal412 = default(IToken);
		IToken LT413 = default(IToken);
		IToken LT415 = default(IToken);
		IToken char_literal416 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> propertyNameAndValue410 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> propertyNameAndValue414 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal408_tree = default(CommonTree);
		CommonTree LT409_tree = default(CommonTree);
		CommonTree LT411_tree = default(CommonTree);
		CommonTree char_literal412_tree = default(CommonTree);
		CommonTree LT413_tree = default(CommonTree);
		CommonTree LT415_tree = default(CommonTree);
		CommonTree char_literal416_tree = default(CommonTree);
		RewriteRuleITokenStream stream_110=new RewriteRuleITokenStream(adaptor,"token 110");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_55=new RewriteRuleITokenStream(adaptor,"token 55");
		RewriteRuleITokenStream stream_114=new RewriteRuleITokenStream(adaptor,"token 114");
		RewriteRuleSubtreeStream stream_propertyNameAndValue=new RewriteRuleSubtreeStream(adaptor,"rule propertyNameAndValue");
		try { DebugEnterRule(GrammarFileName, "objectLiteral");
		DebugLocation(624, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 78)) { return retval; }

			// JavaScript.g:625:2: ( '{' ( ( LT )* propertyNameAndValue ( ( LT )* ',' ( LT )* propertyNameAndValue )* )? ( LT )* '}' -> ^( '{' ( propertyNameAndValue )* ) )
			DebugEnterAlt(1);
			// JavaScript.g:625:4: '{' ( ( LT )* propertyNameAndValue ( ( LT )* ',' ( LT )* propertyNameAndValue )* )? ( LT )* '}'
			{
			DebugLocation(625, 4);
			char_literal408=(IToken)Match(input,110,Follow._110_in_objectLiteral6314); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_110.Add(char_literal408);

			DebugLocation(625, 8);
			// JavaScript.g:625:8: ( ( LT )* propertyNameAndValue ( ( LT )* ',' ( LT )* propertyNameAndValue )* )?
			int alt240=2;
			try { DebugEnterSubRule(240);
			try { DebugEnterDecision(240, false);
			try
			{
				alt240 = dfa240.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(240); }
			switch (alt240)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:625:9: ( LT )* propertyNameAndValue ( ( LT )* ',' ( LT )* propertyNameAndValue )*
				{
				DebugLocation(625, 9);
				// JavaScript.g:625:9: ( LT )*
				try { DebugEnterSubRule(236);
				while (true)
				{
					int alt236=2;
					try { DebugEnterDecision(236, false);
					int LA236_1 = input.LA(1);

					if ((LA236_1==LT))
					{
						alt236 = 1;
					}


					} finally { DebugExitDecision(236); }
					switch ( alt236 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:625:9: LT
						{
						DebugLocation(625, 9);
						LT409=(IToken)Match(input,LT,Follow._LT_in_objectLiteral6317); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT409);


						}
						break;

					default:
						goto loop236;
					}
				}

				loop236:
					;

				} finally { DebugExitSubRule(236); }

				DebugLocation(625, 13);
				PushFollow(Follow._propertyNameAndValue_in_objectLiteral6320);
				propertyNameAndValue410=propertyNameAndValue();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_propertyNameAndValue.Add(propertyNameAndValue410.Tree);
				DebugLocation(625, 34);
				// JavaScript.g:625:34: ( ( LT )* ',' ( LT )* propertyNameAndValue )*
				try { DebugEnterSubRule(239);
				while (true)
				{
					int alt239=2;
					try { DebugEnterDecision(239, false);
					try
					{
						alt239 = dfa239.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(239); }
					switch ( alt239 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:625:35: ( LT )* ',' ( LT )* propertyNameAndValue
						{
						DebugLocation(625, 35);
						// JavaScript.g:625:35: ( LT )*
						try { DebugEnterSubRule(237);
						while (true)
						{
							int alt237=2;
							try { DebugEnterDecision(237, false);
							int LA237_1 = input.LA(1);

							if ((LA237_1==LT))
							{
								alt237 = 1;
							}


							} finally { DebugExitDecision(237); }
							switch ( alt237 )
							{
							case 1:
								DebugEnterAlt(1);
								// JavaScript.g:625:35: LT
								{
								DebugLocation(625, 35);
								LT411=(IToken)Match(input,LT,Follow._LT_in_objectLiteral6323); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_LT.Add(LT411);


								}
								break;

							default:
								goto loop237;
							}
						}

						loop237:
							;

						} finally { DebugExitSubRule(237); }

						DebugLocation(625, 39);
						char_literal412=(IToken)Match(input,55,Follow._55_in_objectLiteral6326); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_55.Add(char_literal412);

						DebugLocation(625, 43);
						// JavaScript.g:625:43: ( LT )*
						try { DebugEnterSubRule(238);
						while (true)
						{
							int alt238=2;
							try { DebugEnterDecision(238, false);
							int LA238_1 = input.LA(1);

							if ((LA238_1==LT))
							{
								alt238 = 1;
							}


							} finally { DebugExitDecision(238); }
							switch ( alt238 )
							{
							case 1:
								DebugEnterAlt(1);
								// JavaScript.g:625:43: LT
								{
								DebugLocation(625, 43);
								LT413=(IToken)Match(input,LT,Follow._LT_in_objectLiteral6328); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_LT.Add(LT413);


								}
								break;

							default:
								goto loop238;
							}
						}

						loop238:
							;

						} finally { DebugExitSubRule(238); }

						DebugLocation(625, 47);
						PushFollow(Follow._propertyNameAndValue_in_objectLiteral6331);
						propertyNameAndValue414=propertyNameAndValue();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_propertyNameAndValue.Add(propertyNameAndValue414.Tree);

						}
						break;

					default:
						goto loop239;
					}
				}

				loop239:
					;

				} finally { DebugExitSubRule(239); }


				}
				break;

			}
			} finally { DebugExitSubRule(240); }

			DebugLocation(625, 72);
			// JavaScript.g:625:72: ( LT )*
			try { DebugEnterSubRule(241);
			while (true)
			{
				int alt241=2;
				try { DebugEnterDecision(241, false);
				int LA241_1 = input.LA(1);

				if ((LA241_1==LT))
				{
					alt241 = 1;
				}


				} finally { DebugExitDecision(241); }
				switch ( alt241 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:625:72: LT
					{
					DebugLocation(625, 72);
					LT415=(IToken)Match(input,LT,Follow._LT_in_objectLiteral6337); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT415);


					}
					break;

				default:
					goto loop241;
				}
			}

			loop241:
				;

			} finally { DebugExitSubRule(241); }

			DebugLocation(625, 76);
			char_literal416=(IToken)Match(input,114,Follow._114_in_objectLiteral6340); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_114.Add(char_literal416);



			{
			// AST REWRITE
			// elements: 110, propertyNameAndValue
			// 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();
			// 626:3: -> ^( '{' ( propertyNameAndValue )* )
			{
				DebugLocation(626, 6);
				// JavaScript.g:626:6: ^( '{' ( propertyNameAndValue )* )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(626, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ObjectLiteral(stream_110.NextToken()), root_1);

				DebugLocation(626, 32);
				// JavaScript.g:626:32: ( propertyNameAndValue )*
				while ( stream_propertyNameAndValue.HasNext )
				{
					DebugLocation(626, 32);
					adaptor.AddChild(root_1, stream_propertyNameAndValue.NextTree());

				}
				stream_propertyNameAndValue.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("objectLiteral", 78);
			LeaveRule("objectLiteral", 78);
			LeaveRule_objectLiteral();
			if (state.backtracking > 0) { Memoize(input, 78, objectLiteral_StartIndex); }

		}
		DebugLocation(627, 1);
		} finally { DebugExitRule(GrammarFileName, "objectLiteral"); }
		return retval;

	}
コード例 #2
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> functionExpression()
	{
		EnterRule_functionExpression();
		EnterRule("functionExpression", 5);
		TraceIn("functionExpression", 5);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int functionExpression_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal17 = default(IToken);
		IToken LT18 = default(IToken);
		IToken Identifier19 = default(IToken);
		IToken LT20 = default(IToken);
		IToken LT22 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> formalParameterList21 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> functionBody23 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal17_tree = default(CommonTree);
		CommonTree LT18_tree = default(CommonTree);
		CommonTree Identifier19_tree = default(CommonTree);
		CommonTree LT20_tree = default(CommonTree);
		CommonTree LT22_tree = default(CommonTree);
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleSubtreeStream stream_formalParameterList=new RewriteRuleSubtreeStream(adaptor,"rule formalParameterList");
		RewriteRuleSubtreeStream stream_functionBody=new RewriteRuleSubtreeStream(adaptor,"rule functionBody");
		try { DebugEnterRule(GrammarFileName, "functionExpression");
		DebugLocation(57, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 5)) { return retval; }

			// JavaScript.g:58:2: ( 'function' ( LT )* ( Identifier )? ( LT )* formalParameterList ( LT )* functionBody -> ^( 'function' ( Identifier )? formalParameterList functionBody ) )
			DebugEnterAlt(1);
			// JavaScript.g:58:4: 'function' ( LT )* ( Identifier )? ( LT )* formalParameterList ( LT )* functionBody
			{
			DebugLocation(58, 4);
			string_literal17=(IToken)Match(input,93,Follow._93_in_functionExpression272); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_93.Add(string_literal17);

			DebugLocation(58, 15);
			// JavaScript.g:58:15: ( LT )*
			try { DebugEnterSubRule(9);
			while (true)
			{
				int alt9=2;
				try { DebugEnterDecision(9, false);
				int LA9_1 = input.LA(1);

				if ((LA9_1==LT))
				{
					int LA9_2 = input.LA(2);

					if ((EvaluatePredicate(synpred9_JavaScript_fragment)))
					{
						alt9 = 1;
					}


				}


				} finally { DebugExitDecision(9); }
				switch ( alt9 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:58:15: LT
					{
					DebugLocation(58, 15);
					LT18=(IToken)Match(input,LT,Follow._LT_in_functionExpression274); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT18);


					}
					break;

				default:
					goto loop9;
				}
			}

			loop9:
				;

			} finally { DebugExitSubRule(9); }

			DebugLocation(58, 19);
			// JavaScript.g:58:19: ( Identifier )?
			int alt10=2;
			try { DebugEnterSubRule(10);
			try { DebugEnterDecision(10, false);
			int LA10_1 = input.LA(1);

			if ((LA10_1==Identifier))
			{
				alt10 = 1;
			}
			} finally { DebugExitDecision(10); }
			switch (alt10)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:58:19: Identifier
				{
				DebugLocation(58, 19);
				Identifier19=(IToken)Match(input,Identifier,Follow._Identifier_in_functionExpression277); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier19);


				}
				break;

			}
			} finally { DebugExitSubRule(10); }

			DebugLocation(58, 31);
			// JavaScript.g:58:31: ( LT )*
			try { DebugEnterSubRule(11);
			while (true)
			{
				int alt11=2;
				try { DebugEnterDecision(11, false);
				int LA11_1 = input.LA(1);

				if ((LA11_1==LT))
				{
					alt11 = 1;
				}


				} finally { DebugExitDecision(11); }
				switch ( alt11 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:58:31: LT
					{
					DebugLocation(58, 31);
					LT20=(IToken)Match(input,LT,Follow._LT_in_functionExpression280); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT20);


					}
					break;

				default:
					goto loop11;
				}
			}

			loop11:
				;

			} finally { DebugExitSubRule(11); }

			DebugLocation(58, 35);
			PushFollow(Follow._formalParameterList_in_functionExpression283);
			formalParameterList21=formalParameterList();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_formalParameterList.Add(formalParameterList21.Tree);
			DebugLocation(58, 55);
			// JavaScript.g:58:55: ( LT )*
			try { DebugEnterSubRule(12);
			while (true)
			{
				int alt12=2;
				try { DebugEnterDecision(12, false);
				int LA12_1 = input.LA(1);

				if ((LA12_1==LT))
				{
					alt12 = 1;
				}


				} finally { DebugExitDecision(12); }
				switch ( alt12 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:58:55: LT
					{
					DebugLocation(58, 55);
					LT22=(IToken)Match(input,LT,Follow._LT_in_functionExpression285); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT22);


					}
					break;

				default:
					goto loop12;
				}
			}

			loop12:
				;

			} finally { DebugExitSubRule(12); }

			DebugLocation(58, 59);
			PushFollow(Follow._functionBody_in_functionExpression288);
			functionBody23=functionBody();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_functionBody.Add(functionBody23.Tree);


			{
			// AST REWRITE
			// elements: 93, Identifier, formalParameterList, functionBody
			// 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();
			// 59:3: -> ^( 'function' ( Identifier )? formalParameterList functionBody )
			{
				DebugLocation(59, 6);
				// JavaScript.g:59:6: ^( 'function' ( Identifier )? formalParameterList functionBody )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(59, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new FunctionExpression(stream_93.NextToken()), root_1);

				DebugLocation(60, 5);
				// JavaScript.g:60:5: ( Identifier )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(60, 5);
					adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));

				}
				stream_Identifier.Reset();
				DebugLocation(61, 5);
				adaptor.AddChild(root_1, stream_formalParameterList.NextTree());
				DebugLocation(62, 5);
				adaptor.AddChild(root_1, stream_functionBody.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("functionExpression", 5);
			LeaveRule("functionExpression", 5);
			LeaveRule_functionExpression();
			if (state.backtracking > 0) { Memoize(input, 5, functionExpression_StartIndex); }

		}
		DebugLocation(63, 1);
		} finally { DebugExitRule(GrammarFileName, "functionExpression"); }
		return retval;

	}
コード例 #3
0
		public void CheckRRTokenStreamBehaviourWhileEmpty3() {
			RewriteRuleTokenStream tokenTest = new RewriteRuleTokenStream(CreateTreeAdaptor(),
				"RewriteRuleTokenStream test");

			tokenTest.NextToken();
		}
コード例 #4
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> caseClause()
	{
		EnterRule_caseClause();
		EnterRule("caseClause", 35);
		TraceIn("caseClause", 35);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int caseClause_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal206 = default(IToken);
		IToken LT207 = default(IToken);
		IToken LT209 = default(IToken);
		IToken char_literal210 = default(IToken);
		IToken LT211 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression208 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> statementList212 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal206_tree = default(CommonTree);
		CommonTree LT207_tree = default(CommonTree);
		CommonTree LT209_tree = default(CommonTree);
		CommonTree char_literal210_tree = default(CommonTree);
		CommonTree LT211_tree = default(CommonTree);
		RewriteRuleITokenStream stream_83=new RewriteRuleITokenStream(adaptor,"token 83");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_62=new RewriteRuleITokenStream(adaptor,"token 62");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statementList=new RewriteRuleSubtreeStream(adaptor,"rule statementList");
		try { DebugEnterRule(GrammarFileName, "caseClause");
		DebugLocation(225, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 35)) { return retval; }

			// JavaScript.g:226:2: ( 'case' ( LT )* expression ( LT )* ':' ( LT )* ( statementList )? -> ^( 'case' expression ( statementList )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:226:4: 'case' ( LT )* expression ( LT )* ':' ( LT )* ( statementList )?
			{
			DebugLocation(226, 4);
			string_literal206=(IToken)Match(input,83,Follow._83_in_caseClause1665); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_83.Add(string_literal206);

			DebugLocation(226, 11);
			// JavaScript.g:226:11: ( LT )*
			try { DebugEnterSubRule(103);
			while (true)
			{
				int alt103=2;
				try { DebugEnterDecision(103, false);
				int LA103_1 = input.LA(1);

				if ((LA103_1==LT))
				{
					alt103 = 1;
				}


				} finally { DebugExitDecision(103); }
				switch ( alt103 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:226:11: LT
					{
					DebugLocation(226, 11);
					LT207=(IToken)Match(input,LT,Follow._LT_in_caseClause1667); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT207);


					}
					break;

				default:
					goto loop103;
				}
			}

			loop103:
				;

			} finally { DebugExitSubRule(103); }

			DebugLocation(226, 15);
			PushFollow(Follow._expression_in_caseClause1670);
			expression208=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression208.Tree);
			DebugLocation(226, 26);
			// JavaScript.g:226:26: ( LT )*
			try { DebugEnterSubRule(104);
			while (true)
			{
				int alt104=2;
				try { DebugEnterDecision(104, false);
				int LA104_1 = input.LA(1);

				if ((LA104_1==LT))
				{
					alt104 = 1;
				}


				} finally { DebugExitDecision(104); }
				switch ( alt104 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:226:26: LT
					{
					DebugLocation(226, 26);
					LT209=(IToken)Match(input,LT,Follow._LT_in_caseClause1672); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT209);


					}
					break;

				default:
					goto loop104;
				}
			}

			loop104:
				;

			} finally { DebugExitSubRule(104); }

			DebugLocation(226, 30);
			char_literal210=(IToken)Match(input,62,Follow._62_in_caseClause1675); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_62.Add(char_literal210);

			DebugLocation(226, 34);
			// JavaScript.g:226:34: ( LT )*
			try { DebugEnterSubRule(105);
			while (true)
			{
				int alt105=2;
				try { DebugEnterDecision(105, false);
				int LA105_1 = input.LA(1);

				if ((LA105_1==LT))
				{
					int LA105_2 = input.LA(2);

					if ((EvaluatePredicate(synpred119_JavaScript_fragment)))
					{
						alt105 = 1;
					}


				}


				} finally { DebugExitDecision(105); }
				switch ( alt105 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:226:34: LT
					{
					DebugLocation(226, 34);
					LT211=(IToken)Match(input,LT,Follow._LT_in_caseClause1677); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT211);


					}
					break;

				default:
					goto loop105;
				}
			}

			loop105:
				;

			} finally { DebugExitSubRule(105); }

			DebugLocation(226, 38);
			// JavaScript.g:226:38: ( statementList )?
			int alt106=2;
			try { DebugEnterSubRule(106);
			try { DebugEnterDecision(106, false);
			int LA106_1 = input.LA(1);

			if ((LA106_1==Identifier||LA106_1==NumericLiteral||LA106_1==StringLiteral||LA106_1==40||LA106_1==48||(LA106_1>=52 && LA106_1<=53)||(LA106_1>=56 && LA106_1<=57)||LA106_1==63||LA106_1==78||LA106_1==82||LA106_1==85||(LA106_1>=87 && LA106_1<=88)||LA106_1==90||(LA106_1>=92 && LA106_1<=94)||(LA106_1>=97 && LA106_1<=110)||LA106_1==115))
			{
				alt106 = 1;
			}
			} finally { DebugExitDecision(106); }
			switch (alt106)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:226:38: statementList
				{
				DebugLocation(226, 38);
				PushFollow(Follow._statementList_in_caseClause1680);
				statementList212=statementList();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_statementList.Add(statementList212.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(106); }



			{
			// AST REWRITE
			// elements: 83, expression, statementList
			// 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();
			// 226:53: -> ^( 'case' expression ( statementList )? )
			{
				DebugLocation(226, 56);
				// JavaScript.g:226:56: ^( 'case' expression ( statementList )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(226, 58);
				root_1 = (CommonTree)adaptor.BecomeRoot(new CaseClause(stream_83.NextToken()), root_1);

				DebugLocation(226, 82);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(226, 93);
				// JavaScript.g:226:93: ( statementList )?
				if (stream_statementList.HasNext)
				{
					DebugLocation(226, 93);
					adaptor.AddChild(root_1, stream_statementList.NextTree());

				}
				stream_statementList.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("caseClause", 35);
			LeaveRule("caseClause", 35);
			LeaveRule_caseClause();
			if (state.backtracking > 0) { Memoize(input, 35, caseClause_StartIndex); }

		}
		DebugLocation(227, 1);
		} finally { DebugExitRule(GrammarFileName, "caseClause"); }
		return retval;

	}
コード例 #5
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> throwStatement()
	{
		EnterRule_throwStatement();
		EnterRule("throwStatement", 37);
		TraceIn("throwStatement", 37);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int throwStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal218 = default(IToken);
		IToken LT220 = default(IToken);
		IToken char_literal221 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression219 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal218_tree = default(CommonTree);
		CommonTree LT220_tree = default(CommonTree);
		CommonTree char_literal221_tree = default(CommonTree);
		RewriteRuleITokenStream stream_102=new RewriteRuleITokenStream(adaptor,"token 102");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		try { DebugEnterRule(GrammarFileName, "throwStatement");
		DebugLocation(233, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 37)) { return retval; }

			// JavaScript.g:234:2: ( 'throw' expression ( LT | ';' ) -> ^( 'throw' expression ) )
			DebugEnterAlt(1);
			// JavaScript.g:234:4: 'throw' expression ( LT | ';' )
			{
			DebugLocation(234, 4);
			string_literal218=(IToken)Match(input,102,Follow._102_in_throwStatement1746); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_102.Add(string_literal218);

			DebugLocation(234, 12);
			PushFollow(Follow._expression_in_throwStatement1748);
			expression219=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression219.Tree);
			DebugLocation(234, 23);
			// JavaScript.g:234:23: ( LT | ';' )
			int alt110=2;
			try { DebugEnterSubRule(110);
			try { DebugEnterDecision(110, false);
			int LA110_1 = input.LA(1);

			if ((LA110_1==LT))
			{
				alt110 = 1;
			}
			else if ((LA110_1==63))
			{
				alt110 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 110, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(110); }
			switch (alt110)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:234:24: LT
				{
				DebugLocation(234, 24);
				LT220=(IToken)Match(input,LT,Follow._LT_in_throwStatement1751); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT220);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:234:29: ';'
				{
				DebugLocation(234, 29);
				char_literal221=(IToken)Match(input,63,Follow._63_in_throwStatement1755); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal221);


				}
				break;

			}
			} finally { DebugExitSubRule(110); }



			{
			// AST REWRITE
			// elements: 102, 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();
			// 234:34: -> ^( 'throw' expression )
			{
				DebugLocation(234, 37);
				// JavaScript.g:234:37: ^( 'throw' expression )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(234, 39);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ThrowStatement(stream_102.NextToken()), root_1);

				DebugLocation(234, 68);
				adaptor.AddChild(root_1, stream_expression.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("throwStatement", 37);
			LeaveRule("throwStatement", 37);
			LeaveRule_throwStatement();
			if (state.backtracking > 0) { Memoize(input, 37, throwStatement_StartIndex); }

		}
		DebugLocation(235, 1);
		} finally { DebugExitRule(GrammarFileName, "throwStatement"); }
		return retval;

	}
コード例 #6
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> returnStatement()
	{
		EnterRule_returnStatement();
		EnterRule("returnStatement", 30);
		TraceIn("returnStatement", 30);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int returnStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal170 = default(IToken);
		IToken LT172 = default(IToken);
		IToken char_literal173 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression171 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal170_tree = default(CommonTree);
		CommonTree LT172_tree = default(CommonTree);
		CommonTree char_literal173_tree = default(CommonTree);
		RewriteRuleITokenStream stream_99=new RewriteRuleITokenStream(adaptor,"token 99");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		try { DebugEnterRule(GrammarFileName, "returnStatement");
		DebugLocation(202, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 30)) { return retval; }

			// JavaScript.g:203:2: ( 'return' ( expression )? ( LT | ';' ) -> ^( 'return' ( expression )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:203:4: 'return' ( expression )? ( LT | ';' )
			{
			DebugLocation(203, 4);
			string_literal170=(IToken)Match(input,99,Follow._99_in_returnStatement1433); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_99.Add(string_literal170);

			DebugLocation(203, 13);
			// JavaScript.g:203:13: ( expression )?
			int alt84=2;
			try { DebugEnterSubRule(84);
			try { DebugEnterDecision(84, false);
			int LA84_1 = input.LA(1);

			if ((LA84_1==Identifier||LA84_1==NumericLiteral||LA84_1==StringLiteral||LA84_1==40||LA84_1==48||(LA84_1>=52 && LA84_1<=53)||(LA84_1>=56 && LA84_1<=57)||LA84_1==78||LA84_1==87||LA84_1==90||LA84_1==93||(LA84_1>=97 && LA84_1<=98)||LA84_1==101||LA84_1==103||LA84_1==105||LA84_1==107||LA84_1==110||LA84_1==115))
			{
				alt84 = 1;
			}
			} finally { DebugExitDecision(84); }
			switch (alt84)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:203:13: expression
				{
				DebugLocation(203, 13);
				PushFollow(Follow._expression_in_returnStatement1435);
				expression171=expression();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_expression.Add(expression171.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(84); }

			DebugLocation(203, 25);
			// JavaScript.g:203:25: ( LT | ';' )
			int alt85=2;
			try { DebugEnterSubRule(85);
			try { DebugEnterDecision(85, false);
			int LA85_1 = input.LA(1);

			if ((LA85_1==LT))
			{
				alt85 = 1;
			}
			else if ((LA85_1==63))
			{
				alt85 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 85, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(85); }
			switch (alt85)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:203:26: LT
				{
				DebugLocation(203, 26);
				LT172=(IToken)Match(input,LT,Follow._LT_in_returnStatement1439); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT172);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:203:31: ';'
				{
				DebugLocation(203, 31);
				char_literal173=(IToken)Match(input,63,Follow._63_in_returnStatement1443); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal173);


				}
				break;

			}
			} finally { DebugExitSubRule(85); }



			{
			// AST REWRITE
			// elements: 99, 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();
			// 203:36: -> ^( 'return' ( expression )? )
			{
				DebugLocation(203, 39);
				// JavaScript.g:203:39: ^( 'return' ( expression )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(203, 41);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ReturnStatement(stream_99.NextToken()), root_1);

				DebugLocation(203, 72);
				// JavaScript.g:203:72: ( expression )?
				if (stream_expression.HasNext)
				{
					DebugLocation(203, 72);
					adaptor.AddChild(root_1, stream_expression.NextTree());

				}
				stream_expression.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("returnStatement", 30);
			LeaveRule("returnStatement", 30);
			LeaveRule_returnStatement();
			if (state.backtracking > 0) { Memoize(input, 30, returnStatement_StartIndex); }

		}
		DebugLocation(204, 1);
		} finally { DebugExitRule(GrammarFileName, "returnStatement"); }
		return retval;

	}
コード例 #7
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> labelledStatement()
	{
		EnterRule_labelledStatement();
		EnterRule("labelledStatement", 32);
		TraceIn("labelledStatement", 32);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int labelledStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken Identifier183 = default(IToken);
		IToken LT184 = default(IToken);
		IToken char_literal185 = default(IToken);
		IToken LT186 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statement187 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree Identifier183_tree = default(CommonTree);
		CommonTree LT184_tree = default(CommonTree);
		CommonTree char_literal185_tree = default(CommonTree);
		CommonTree LT186_tree = default(CommonTree);
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_62=new RewriteRuleITokenStream(adaptor,"token 62");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "labelledStatement");
		DebugLocation(211, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 32)) { return retval; }

			// JavaScript.g:212:2: ( Identifier ( LT )* ':' ( LT )* statement -> ^( ':' Identifier statement ) )
			DebugEnterAlt(1);
			// JavaScript.g:212:4: Identifier ( LT )* ':' ( LT )* statement
			{
			DebugLocation(212, 4);
			Identifier183=(IToken)Match(input,Identifier,Follow._Identifier_in_labelledStatement1519); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_Identifier.Add(Identifier183);

			DebugLocation(212, 15);
			// JavaScript.g:212:15: ( LT )*
			try { DebugEnterSubRule(90);
			while (true)
			{
				int alt90=2;
				try { DebugEnterDecision(90, false);
				int LA90_1 = input.LA(1);

				if ((LA90_1==LT))
				{
					alt90 = 1;
				}


				} finally { DebugExitDecision(90); }
				switch ( alt90 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:212:15: LT
					{
					DebugLocation(212, 15);
					LT184=(IToken)Match(input,LT,Follow._LT_in_labelledStatement1521); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT184);


					}
					break;

				default:
					goto loop90;
				}
			}

			loop90:
				;

			} finally { DebugExitSubRule(90); }

			DebugLocation(212, 19);
			char_literal185=(IToken)Match(input,62,Follow._62_in_labelledStatement1524); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_62.Add(char_literal185);

			DebugLocation(212, 23);
			// JavaScript.g:212:23: ( LT )*
			try { DebugEnterSubRule(91);
			while (true)
			{
				int alt91=2;
				try { DebugEnterDecision(91, false);
				int LA91_1 = input.LA(1);

				if ((LA91_1==LT))
				{
					alt91 = 1;
				}


				} finally { DebugExitDecision(91); }
				switch ( alt91 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:212:23: LT
					{
					DebugLocation(212, 23);
					LT186=(IToken)Match(input,LT,Follow._LT_in_labelledStatement1526); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT186);


					}
					break;

				default:
					goto loop91;
				}
			}

			loop91:
				;

			} finally { DebugExitSubRule(91); }

			DebugLocation(212, 27);
			PushFollow(Follow._statement_in_labelledStatement1529);
			statement187=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement187.Tree);


			{
			// AST REWRITE
			// elements: 62, Identifier, 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();
			// 213:9: -> ^( ':' Identifier statement )
			{
				DebugLocation(213, 12);
				// JavaScript.g:213:12: ^( ':' Identifier statement )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(213, 14);
				root_1 = (CommonTree)adaptor.BecomeRoot(new LabeledStatement(stream_62.NextToken()), root_1);

				DebugLocation(213, 41);
				adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));
				DebugLocation(213, 69);
				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("labelledStatement", 32);
			LeaveRule("labelledStatement", 32);
			LeaveRule_labelledStatement();
			if (state.backtracking > 0) { Memoize(input, 32, labelledStatement_StartIndex); }

		}
		DebugLocation(214, 1);
		} finally { DebugExitRule(GrammarFileName, "labelledStatement"); }
		return retval;

	}
コード例 #8
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> variableDeclarationNoIn()
	{
		EnterRule_variableDeclarationNoIn();
		EnterRule("variableDeclarationNoIn", 15);
		TraceIn("variableDeclarationNoIn", 15);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int variableDeclarationNoIn_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken Identifier78 = default(IToken);
		IToken LT79 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> initialiserNoIn80 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree Identifier78_tree = default(CommonTree);
		CommonTree LT79_tree = default(CommonTree);
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleSubtreeStream stream_initialiserNoIn=new RewriteRuleSubtreeStream(adaptor,"rule initialiserNoIn");
		try { DebugEnterRule(GrammarFileName, "variableDeclarationNoIn");
		DebugLocation(120, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 15)) { return retval; }

			// JavaScript.g:121:2: ( Identifier ( LT )* ( initialiserNoIn )? -> ^( VARIABLEDECL Identifier ( initialiserNoIn )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:121:4: Identifier ( LT )* ( initialiserNoIn )?
			{
			DebugLocation(121, 4);
			Identifier78=(IToken)Match(input,Identifier,Follow._Identifier_in_variableDeclarationNoIn720); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_Identifier.Add(Identifier78);

			DebugLocation(121, 15);
			// JavaScript.g:121:15: ( LT )*
			try { DebugEnterSubRule(38);
			while (true)
			{
				int alt38=2;
				try { DebugEnterDecision(38, false);
				int LA38_1 = input.LA(1);

				if ((LA38_1==LT))
				{
					int LA38_2 = input.LA(2);

					if ((EvaluatePredicate(synpred50_JavaScript_fragment)))
					{
						alt38 = 1;
					}


				}


				} finally { DebugExitDecision(38); }
				switch ( alt38 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:121:15: LT
					{
					DebugLocation(121, 15);
					LT79=(IToken)Match(input,LT,Follow._LT_in_variableDeclarationNoIn722); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT79);


					}
					break;

				default:
					goto loop38;
				}
			}

			loop38:
				;

			} finally { DebugExitSubRule(38); }

			DebugLocation(121, 19);
			// JavaScript.g:121:19: ( initialiserNoIn )?
			int alt39=2;
			try { DebugEnterSubRule(39);
			try { DebugEnterDecision(39, false);
			int LA39_1 = input.LA(1);

			if ((LA39_1==68))
			{
				alt39 = 1;
			}
			} finally { DebugExitDecision(39); }
			switch (alt39)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:121:19: initialiserNoIn
				{
				DebugLocation(121, 19);
				PushFollow(Follow._initialiserNoIn_in_variableDeclarationNoIn725);
				initialiserNoIn80=initialiserNoIn();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_initialiserNoIn.Add(initialiserNoIn80.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(39); }



			{
			// AST REWRITE
			// elements: Identifier, initialiserNoIn
			// 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();
			// 122:3: -> ^( VARIABLEDECL Identifier ( initialiserNoIn )? )
			{
				DebugLocation(122, 6);
				// JavaScript.g:122:6: ^( VARIABLEDECL Identifier ( initialiserNoIn )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(122, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new VariableDeclaration(VARIABLEDECL), root_1);

				DebugLocation(123, 5);
				adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));
				DebugLocation(124, 5);
				// JavaScript.g:124:5: ( initialiserNoIn )?
				if (stream_initialiserNoIn.HasNext)
				{
					DebugLocation(124, 5);
					adaptor.AddChild(root_1, stream_initialiserNoIn.NextTree());

				}
				stream_initialiserNoIn.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("variableDeclarationNoIn", 15);
			LeaveRule("variableDeclarationNoIn", 15);
			LeaveRule_variableDeclarationNoIn();
			if (state.backtracking > 0) { Memoize(input, 15, variableDeclarationNoIn_StartIndex); }

		}
		DebugLocation(125, 1);
		} finally { DebugExitRule(GrammarFileName, "variableDeclarationNoIn"); }
		return retval;

	}
コード例 #9
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> emptyStatement()
	{
		EnterRule_emptyStatement();
		EnterRule("emptyStatement", 18);
		TraceIn("emptyStatement", 18);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int emptyStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken char_literal87 = default(IToken);

		CommonTree char_literal87_tree = default(CommonTree);
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		try { DebugEnterRule(GrammarFileName, "emptyStatement");
		DebugLocation(135, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 18)) { return retval; }

			// JavaScript.g:136:2: ( ';' -> ';' )
			DebugEnterAlt(1);
			// JavaScript.g:136:4: ';'
			{
			DebugLocation(136, 4);
			char_literal87=(IToken)Match(input,63,Follow._63_in_emptyStatement815); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_63.Add(char_literal87);



			{
			// AST REWRITE
			// elements: 63
			// 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();
			// 136:8: -> ';'
			{
				DebugLocation(136, 11);
				adaptor.AddChild(root_0, new EmptyStatement(stream_63.NextToken()));

			}

			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("emptyStatement", 18);
			LeaveRule("emptyStatement", 18);
			LeaveRule_emptyStatement();
			if (state.backtracking > 0) { Memoize(input, 18, emptyStatement_StartIndex); }

		}
		DebugLocation(137, 1);
		} finally { DebugExitRule(GrammarFileName, "emptyStatement"); }
		return retval;

	}
コード例 #10
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> literal()
	{
		EnterRule_literal();
		EnterRule("literal", 81);
		TraceIn("literal", 81);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int literal_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal425 = default(IToken);
		IToken string_literal426 = default(IToken);
		IToken string_literal427 = default(IToken);
		IToken StringLiteral428 = default(IToken);
		IToken NumericLiteral429 = default(IToken);

		CommonTree string_literal425_tree = default(CommonTree);
		CommonTree string_literal426_tree = default(CommonTree);
		CommonTree string_literal427_tree = default(CommonTree);
		CommonTree StringLiteral428_tree = default(CommonTree);
		CommonTree NumericLiteral429_tree = default(CommonTree);
		RewriteRuleITokenStream stream_98=new RewriteRuleITokenStream(adaptor,"token 98");
		RewriteRuleITokenStream stream_103=new RewriteRuleITokenStream(adaptor,"token 103");
		RewriteRuleITokenStream stream_90=new RewriteRuleITokenStream(adaptor,"token 90");
		RewriteRuleITokenStream stream_StringLiteral=new RewriteRuleITokenStream(adaptor,"token StringLiteral");
		RewriteRuleITokenStream stream_NumericLiteral=new RewriteRuleITokenStream(adaptor,"token NumericLiteral");
		try { DebugEnterRule(GrammarFileName, "literal");
		DebugLocation(641, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 81)) { return retval; }

			// JavaScript.g:642:2: ( 'null' -> 'null' | 'true' -> 'true' | 'false' -> 'false' | StringLiteral -> StringLiteral | NumericLiteral -> NumericLiteral )
			int alt245=5;
			try { DebugEnterDecision(245, false);
			switch (input.LA(1))
			{
			case 98:
				{
				alt245 = 1;
				}
				break;
			case 103:
				{
				alt245 = 2;
				}
				break;
			case 90:
				{
				alt245 = 3;
				}
				break;
			case StringLiteral:
				{
				alt245 = 4;
				}
				break;
			case NumericLiteral:
				{
				alt245 = 5;
				}
				break;
			default:
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 245, 0, input, 1);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(245); }
			switch (alt245)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:642:4: 'null'
				{
				DebugLocation(642, 4);
				string_literal425=(IToken)Match(input,98,Follow._98_in_literal6458); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_98.Add(string_literal425);



				{
				// AST REWRITE
				// elements: 98
				// 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();
				// 642:13: -> 'null'
				{
					DebugLocation(642, 16);
					adaptor.AddChild(root_0, new NullLiteral(stream_98.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:643:4: 'true'
				{
				DebugLocation(643, 4);
				string_literal426=(IToken)Match(input,103,Follow._103_in_literal6474); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_103.Add(string_literal426);



				{
				// AST REWRITE
				// elements: 103
				// 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();
				// 643:13: -> 'true'
				{
					DebugLocation(643, 16);
					adaptor.AddChild(root_0, new TrueLiteral(stream_103.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// JavaScript.g:644:4: 'false'
				{
				DebugLocation(644, 4);
				string_literal427=(IToken)Match(input,90,Follow._90_in_literal6490); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_90.Add(string_literal427);



				{
				// AST REWRITE
				// elements: 90
				// 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();
				// 644:14: -> 'false'
				{
					DebugLocation(644, 17);
					adaptor.AddChild(root_0, new FalseLiteral(stream_90.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// JavaScript.g:645:4: StringLiteral
				{
				DebugLocation(645, 4);
				StringLiteral428=(IToken)Match(input,StringLiteral,Follow._StringLiteral_in_literal6506); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_StringLiteral.Add(StringLiteral428);



				{
				// AST REWRITE
				// elements: StringLiteral
				// 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();
				// 645:19: -> StringLiteral
				{
					DebugLocation(645, 22);
					adaptor.AddChild(root_0, new StringLiteral(stream_StringLiteral.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 5:
				DebugEnterAlt(5);
				// JavaScript.g:646:4: NumericLiteral
				{
				DebugLocation(646, 4);
				NumericLiteral429=(IToken)Match(input,NumericLiteral,Follow._NumericLiteral_in_literal6521); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_NumericLiteral.Add(NumericLiteral429);



				{
				// AST REWRITE
				// elements: NumericLiteral
				// 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();
				// 646:19: -> NumericLiteral
				{
					DebugLocation(646, 22);
					adaptor.AddChild(root_0, new NumericLiteral(stream_NumericLiteral.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				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("literal", 81);
			LeaveRule("literal", 81);
			LeaveRule_literal();
			if (state.backtracking > 0) { Memoize(input, 81, literal_StartIndex); }

		}
		DebugLocation(647, 1);
		} finally { DebugExitRule(GrammarFileName, "literal"); }
		return retval;

	}
コード例 #11
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> variableStatement()
	{
		EnterRule_variableStatement();
		EnterRule("variableStatement", 11);
		TraceIn("variableStatement", 11);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int variableStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal60 = default(IToken);
		IToken LT61 = default(IToken);
		IToken LT63 = default(IToken);
		IToken char_literal64 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> variableDeclarationList62 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal60_tree = default(CommonTree);
		CommonTree LT61_tree = default(CommonTree);
		CommonTree LT63_tree = default(CommonTree);
		CommonTree char_literal64_tree = default(CommonTree);
		RewriteRuleITokenStream stream_106=new RewriteRuleITokenStream(adaptor,"token 106");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		RewriteRuleSubtreeStream stream_variableDeclarationList=new RewriteRuleSubtreeStream(adaptor,"rule variableDeclarationList");
		try { DebugEnterRule(GrammarFileName, "variableStatement");
		DebugLocation(100, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 11)) { return retval; }

			// JavaScript.g:101:2: ( 'var' ( LT )* variableDeclarationList ( LT | ';' ) -> ^( 'var' variableDeclarationList ) )
			DebugEnterAlt(1);
			// JavaScript.g:101:4: 'var' ( LT )* variableDeclarationList ( LT | ';' )
			{
			DebugLocation(101, 4);
			string_literal60=(IToken)Match(input,106,Follow._106_in_variableStatement567); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_106.Add(string_literal60);

			DebugLocation(101, 10);
			// JavaScript.g:101:10: ( LT )*
			try { DebugEnterSubRule(28);
			while (true)
			{
				int alt28=2;
				try { DebugEnterDecision(28, false);
				int LA28_1 = input.LA(1);

				if ((LA28_1==LT))
				{
					alt28 = 1;
				}


				} finally { DebugExitDecision(28); }
				switch ( alt28 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:101:10: LT
					{
					DebugLocation(101, 10);
					LT61=(IToken)Match(input,LT,Follow._LT_in_variableStatement569); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT61);


					}
					break;

				default:
					goto loop28;
				}
			}

			loop28:
				;

			} finally { DebugExitSubRule(28); }

			DebugLocation(101, 14);
			PushFollow(Follow._variableDeclarationList_in_variableStatement572);
			variableDeclarationList62=variableDeclarationList();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_variableDeclarationList.Add(variableDeclarationList62.Tree);
			DebugLocation(101, 38);
			// JavaScript.g:101:38: ( LT | ';' )
			int alt29=2;
			try { DebugEnterSubRule(29);
			try { DebugEnterDecision(29, false);
			int LA29_1 = input.LA(1);

			if ((LA29_1==LT))
			{
				alt29 = 1;
			}
			else if ((LA29_1==63))
			{
				alt29 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 29, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(29); }
			switch (alt29)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:101:39: LT
				{
				DebugLocation(101, 39);
				LT63=(IToken)Match(input,LT,Follow._LT_in_variableStatement575); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT63);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:101:44: ';'
				{
				DebugLocation(101, 44);
				char_literal64=(IToken)Match(input,63,Follow._63_in_variableStatement579); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal64);


				}
				break;

			}
			} finally { DebugExitSubRule(29); }



			{
			// AST REWRITE
			// elements: 106, variableDeclarationList
			// 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();
			// 102:3: -> ^( 'var' variableDeclarationList )
			{
				DebugLocation(102, 6);
				// JavaScript.g:102:6: ^( 'var' variableDeclarationList )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(102, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new VariableStatement(stream_106.NextToken()), root_1);

				DebugLocation(102, 38);
				adaptor.AddChild(root_1, stream_variableDeclarationList.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("variableStatement", 11);
			LeaveRule("variableStatement", 11);
			LeaveRule_variableStatement();
			if (state.backtracking > 0) { Memoize(input, 11, variableStatement_StartIndex); }

		}
		DebugLocation(103, 1);
		} finally { DebugExitRule(GrammarFileName, "variableStatement"); }
		return retval;

	}
コード例 #12
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> propertyName()
	{
		EnterRule_propertyName();
		EnterRule("propertyName", 80);
		TraceIn("propertyName", 80);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int propertyName_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken Identifier422 = default(IToken);
		IToken StringLiteral423 = default(IToken);
		IToken NumericLiteral424 = default(IToken);

		CommonTree Identifier422_tree = default(CommonTree);
		CommonTree StringLiteral423_tree = default(CommonTree);
		CommonTree NumericLiteral424_tree = default(CommonTree);
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_StringLiteral=new RewriteRuleITokenStream(adaptor,"token StringLiteral");
		RewriteRuleITokenStream stream_NumericLiteral=new RewriteRuleITokenStream(adaptor,"token NumericLiteral");
		try { DebugEnterRule(GrammarFileName, "propertyName");
		DebugLocation(634, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 80)) { return retval; }

			// JavaScript.g:635:2: ( Identifier -> Identifier | StringLiteral -> StringLiteral | NumericLiteral -> NumericLiteral )
			int alt244=3;
			try { DebugEnterDecision(244, false);
			switch (input.LA(1))
			{
			case Identifier:
				{
				alt244 = 1;
				}
				break;
			case StringLiteral:
				{
				alt244 = 2;
				}
				break;
			case NumericLiteral:
				{
				alt244 = 3;
				}
				break;
			default:
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 244, 0, input, 1);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(244); }
			switch (alt244)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:635:4: Identifier
				{
				DebugLocation(635, 4);
				Identifier422=(IToken)Match(input,Identifier,Follow._Identifier_in_propertyName6407); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier422);



				{
				// AST REWRITE
				// elements: Identifier
				// 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();
				// 635:16: -> Identifier
				{
					DebugLocation(635, 19);
					adaptor.AddChild(root_0, new Identifier(stream_Identifier.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:636:4: StringLiteral
				{
				DebugLocation(636, 4);
				StringLiteral423=(IToken)Match(input,StringLiteral,Follow._StringLiteral_in_propertyName6422); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_StringLiteral.Add(StringLiteral423);



				{
				// AST REWRITE
				// elements: StringLiteral
				// 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();
				// 636:19: -> StringLiteral
				{
					DebugLocation(636, 22);
					adaptor.AddChild(root_0, new StringLiteral(stream_StringLiteral.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// JavaScript.g:637:4: NumericLiteral
				{
				DebugLocation(637, 4);
				NumericLiteral424=(IToken)Match(input,NumericLiteral,Follow._NumericLiteral_in_propertyName6437); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_NumericLiteral.Add(NumericLiteral424);



				{
				// AST REWRITE
				// elements: NumericLiteral
				// 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();
				// 637:19: -> NumericLiteral
				{
					DebugLocation(637, 22);
					adaptor.AddChild(root_0, new NumericLiteral(stream_NumericLiteral.NextToken()));

				}

				retval.Tree = root_0;
				}
				}

				}
				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("propertyName", 80);
			LeaveRule("propertyName", 80);
			LeaveRule_propertyName();
			if (state.backtracking > 0) { Memoize(input, 80, propertyName_StartIndex); }

		}
		DebugLocation(638, 1);
		} finally { DebugExitRule(GrammarFileName, "propertyName"); }
		return retval;

	}
コード例 #13
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> propertyNameAndValue()
	{
		EnterRule_propertyNameAndValue();
		EnterRule("propertyNameAndValue", 79);
		TraceIn("propertyNameAndValue", 79);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int propertyNameAndValue_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken LT418 = default(IToken);
		IToken char_literal419 = default(IToken);
		IToken LT420 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> propertyName417 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> assignmentExpression421 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree LT418_tree = default(CommonTree);
		CommonTree char_literal419_tree = default(CommonTree);
		CommonTree LT420_tree = default(CommonTree);
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_62=new RewriteRuleITokenStream(adaptor,"token 62");
		RewriteRuleSubtreeStream stream_propertyName=new RewriteRuleSubtreeStream(adaptor,"rule propertyName");
		RewriteRuleSubtreeStream stream_assignmentExpression=new RewriteRuleSubtreeStream(adaptor,"rule assignmentExpression");
		try { DebugEnterRule(GrammarFileName, "propertyNameAndValue");
		DebugLocation(629, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 79)) { return retval; }

			// JavaScript.g:630:2: ( propertyName ( LT )* ':' ( LT )* assignmentExpression -> ^( ':' propertyName assignmentExpression ) )
			DebugEnterAlt(1);
			// JavaScript.g:630:4: propertyName ( LT )* ':' ( LT )* assignmentExpression
			{
			DebugLocation(630, 4);
			PushFollow(Follow._propertyName_in_propertyNameAndValue6368);
			propertyName417=propertyName();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_propertyName.Add(propertyName417.Tree);
			DebugLocation(630, 17);
			// JavaScript.g:630:17: ( LT )*
			try { DebugEnterSubRule(242);
			while (true)
			{
				int alt242=2;
				try { DebugEnterDecision(242, false);
				int LA242_1 = input.LA(1);

				if ((LA242_1==LT))
				{
					alt242 = 1;
				}


				} finally { DebugExitDecision(242); }
				switch ( alt242 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:630:17: LT
					{
					DebugLocation(630, 17);
					LT418=(IToken)Match(input,LT,Follow._LT_in_propertyNameAndValue6370); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT418);


					}
					break;

				default:
					goto loop242;
				}
			}

			loop242:
				;

			} finally { DebugExitSubRule(242); }

			DebugLocation(630, 21);
			char_literal419=(IToken)Match(input,62,Follow._62_in_propertyNameAndValue6373); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_62.Add(char_literal419);

			DebugLocation(630, 25);
			// JavaScript.g:630:25: ( LT )*
			try { DebugEnterSubRule(243);
			while (true)
			{
				int alt243=2;
				try { DebugEnterDecision(243, false);
				int LA243_1 = input.LA(1);

				if ((LA243_1==LT))
				{
					alt243 = 1;
				}


				} finally { DebugExitDecision(243); }
				switch ( alt243 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:630:25: LT
					{
					DebugLocation(630, 25);
					LT420=(IToken)Match(input,LT,Follow._LT_in_propertyNameAndValue6375); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT420);


					}
					break;

				default:
					goto loop243;
				}
			}

			loop243:
				;

			} finally { DebugExitSubRule(243); }

			DebugLocation(630, 29);
			PushFollow(Follow._assignmentExpression_in_propertyNameAndValue6378);
			assignmentExpression421=assignmentExpression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_assignmentExpression.Add(assignmentExpression421.Tree);


			{
			// AST REWRITE
			// elements: 62, propertyName, assignmentExpression
			// 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();
			// 631:3: -> ^( ':' propertyName assignmentExpression )
			{
				DebugLocation(631, 6);
				// JavaScript.g:631:6: ^( ':' propertyName assignmentExpression )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(631, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new PropertyAssignment(stream_62.NextToken()), root_1);

				DebugLocation(631, 37);
				adaptor.AddChild(root_1, stream_propertyName.NextTree());
				DebugLocation(631, 50);
				adaptor.AddChild(root_1, stream_assignmentExpression.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("propertyNameAndValue", 79);
			LeaveRule("propertyNameAndValue", 79);
			LeaveRule_propertyNameAndValue();
			if (state.backtracking > 0) { Memoize(input, 79, propertyNameAndValue_StartIndex); }

		}
		DebugLocation(632, 1);
		} finally { DebugExitRule(GrammarFileName, "propertyNameAndValue"); }
		return retval;

	}
コード例 #14
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> statementBlock()
	{
		EnterRule_statementBlock();
		EnterRule("statementBlock", 9);
		TraceIn("statementBlock", 9);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int statementBlock_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken char_literal52 = default(IToken);
		IToken LT53 = default(IToken);
		IToken LT55 = default(IToken);
		IToken char_literal56 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statementList54 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal52_tree = default(CommonTree);
		CommonTree LT53_tree = default(CommonTree);
		CommonTree LT55_tree = default(CommonTree);
		CommonTree char_literal56_tree = default(CommonTree);
		RewriteRuleITokenStream stream_110=new RewriteRuleITokenStream(adaptor,"token 110");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_114=new RewriteRuleITokenStream(adaptor,"token 114");
		RewriteRuleSubtreeStream stream_statementList=new RewriteRuleSubtreeStream(adaptor,"rule statementList");
		try { DebugEnterRule(GrammarFileName, "statementBlock");
		DebugLocation(92, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 9)) { return retval; }

			// JavaScript.g:93:2: ( '{' ( LT )* ( statementList )? ( LT )* '}' -> ^( '{' ( statementList )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:93:4: '{' ( LT )* ( statementList )? ( LT )* '}'
			{
			DebugLocation(93, 4);
			char_literal52=(IToken)Match(input,110,Follow._110_in_statementBlock509); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_110.Add(char_literal52);

			DebugLocation(93, 8);
			// JavaScript.g:93:8: ( LT )*
			try { DebugEnterSubRule(23);
			while (true)
			{
				int alt23=2;
				try { DebugEnterDecision(23, false);
				int LA23_1 = input.LA(1);

				if ((LA23_1==LT))
				{
					int LA23_2 = input.LA(2);

					if ((EvaluatePredicate(synpred35_JavaScript_fragment)))
					{
						alt23 = 1;
					}


				}


				} finally { DebugExitDecision(23); }
				switch ( alt23 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:93:8: LT
					{
					DebugLocation(93, 8);
					LT53=(IToken)Match(input,LT,Follow._LT_in_statementBlock511); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT53);


					}
					break;

				default:
					goto loop23;
				}
			}

			loop23:
				;

			} finally { DebugExitSubRule(23); }

			DebugLocation(93, 12);
			// JavaScript.g:93:12: ( statementList )?
			int alt24=2;
			try { DebugEnterSubRule(24);
			try { DebugEnterDecision(24, false);
			int LA24_1 = input.LA(1);

			if ((LA24_1==Identifier||LA24_1==NumericLiteral||LA24_1==StringLiteral||LA24_1==40||LA24_1==48||(LA24_1>=52 && LA24_1<=53)||(LA24_1>=56 && LA24_1<=57)||LA24_1==63||LA24_1==78||LA24_1==82||LA24_1==85||(LA24_1>=87 && LA24_1<=88)||LA24_1==90||(LA24_1>=92 && LA24_1<=94)||(LA24_1>=97 && LA24_1<=110)||LA24_1==115))
			{
				alt24 = 1;
			}
			} finally { DebugExitDecision(24); }
			switch (alt24)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:93:12: statementList
				{
				DebugLocation(93, 12);
				PushFollow(Follow._statementList_in_statementBlock514);
				statementList54=statementList();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_statementList.Add(statementList54.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(24); }

			DebugLocation(93, 27);
			// JavaScript.g:93:27: ( LT )*
			try { DebugEnterSubRule(25);
			while (true)
			{
				int alt25=2;
				try { DebugEnterDecision(25, false);
				int LA25_1 = input.LA(1);

				if ((LA25_1==LT))
				{
					alt25 = 1;
				}


				} finally { DebugExitDecision(25); }
				switch ( alt25 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:93:27: LT
					{
					DebugLocation(93, 27);
					LT55=(IToken)Match(input,LT,Follow._LT_in_statementBlock517); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT55);


					}
					break;

				default:
					goto loop25;
				}
			}

			loop25:
				;

			} finally { DebugExitSubRule(25); }

			DebugLocation(93, 31);
			char_literal56=(IToken)Match(input,114,Follow._114_in_statementBlock520); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_114.Add(char_literal56);



			{
			// AST REWRITE
			// elements: 110, statementList
			// 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();
			// 93:35: -> ^( '{' ( statementList )? )
			{
				DebugLocation(93, 38);
				// JavaScript.g:93:38: ^( '{' ( statementList )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(93, 40);
				root_1 = (CommonTree)adaptor.BecomeRoot(new StatementBlock(stream_110.NextToken()), root_1);

				DebugLocation(93, 65);
				// JavaScript.g:93:65: ( statementList )?
				if (stream_statementList.HasNext)
				{
					DebugLocation(93, 65);
					adaptor.AddChild(root_1, stream_statementList.NextTree());

				}
				stream_statementList.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("statementBlock", 9);
			LeaveRule("statementBlock", 9);
			LeaveRule_statementBlock();
			if (state.backtracking > 0) { Memoize(input, 9, statementBlock_StartIndex); }

		}
		DebugLocation(94, 1);
		} finally { DebugExitRule(GrammarFileName, "statementBlock"); }
		return retval;

	}
コード例 #15
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> functionDeclaration()
	{
		EnterRule_functionDeclaration();
		EnterRule("functionDeclaration", 4);
		TraceIn("functionDeclaration", 4);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int functionDeclaration_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal10 = default(IToken);
		IToken LT11 = default(IToken);
		IToken Identifier12 = default(IToken);
		IToken LT13 = default(IToken);
		IToken LT15 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> formalParameterList14 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> functionBody16 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal10_tree = default(CommonTree);
		CommonTree LT11_tree = default(CommonTree);
		CommonTree Identifier12_tree = default(CommonTree);
		CommonTree LT13_tree = default(CommonTree);
		CommonTree LT15_tree = default(CommonTree);
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleSubtreeStream stream_formalParameterList=new RewriteRuleSubtreeStream(adaptor,"rule formalParameterList");
		RewriteRuleSubtreeStream stream_functionBody=new RewriteRuleSubtreeStream(adaptor,"rule functionBody");
		try { DebugEnterRule(GrammarFileName, "functionDeclaration");
		DebugLocation(49, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 4)) { return retval; }

			// JavaScript.g:50:2: ( 'function' ( LT )* Identifier ( LT )* formalParameterList ( LT )* functionBody -> ^( 'function' Identifier formalParameterList functionBody ) )
			DebugEnterAlt(1);
			// JavaScript.g:50:4: 'function' ( LT )* Identifier ( LT )* formalParameterList ( LT )* functionBody
			{
			DebugLocation(50, 4);
			string_literal10=(IToken)Match(input,93,Follow._93_in_functionDeclaration205); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_93.Add(string_literal10);

			DebugLocation(50, 15);
			// JavaScript.g:50:15: ( LT )*
			try { DebugEnterSubRule(6);
			while (true)
			{
				int alt6=2;
				try { DebugEnterDecision(6, false);
				int LA6_1 = input.LA(1);

				if ((LA6_1==LT))
				{
					alt6 = 1;
				}


				} finally { DebugExitDecision(6); }
				switch ( alt6 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:50:15: LT
					{
					DebugLocation(50, 15);
					LT11=(IToken)Match(input,LT,Follow._LT_in_functionDeclaration207); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT11);


					}
					break;

				default:
					goto loop6;
				}
			}

			loop6:
				;

			} finally { DebugExitSubRule(6); }

			DebugLocation(50, 19);
			Identifier12=(IToken)Match(input,Identifier,Follow._Identifier_in_functionDeclaration210); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_Identifier.Add(Identifier12);

			DebugLocation(50, 30);
			// JavaScript.g:50:30: ( LT )*
			try { DebugEnterSubRule(7);
			while (true)
			{
				int alt7=2;
				try { DebugEnterDecision(7, false);
				int LA7_1 = input.LA(1);

				if ((LA7_1==LT))
				{
					alt7 = 1;
				}


				} finally { DebugExitDecision(7); }
				switch ( alt7 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:50:30: LT
					{
					DebugLocation(50, 30);
					LT13=(IToken)Match(input,LT,Follow._LT_in_functionDeclaration212); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT13);


					}
					break;

				default:
					goto loop7;
				}
			}

			loop7:
				;

			} finally { DebugExitSubRule(7); }

			DebugLocation(50, 34);
			PushFollow(Follow._formalParameterList_in_functionDeclaration215);
			formalParameterList14=formalParameterList();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_formalParameterList.Add(formalParameterList14.Tree);
			DebugLocation(50, 54);
			// JavaScript.g:50:54: ( LT )*
			try { DebugEnterSubRule(8);
			while (true)
			{
				int alt8=2;
				try { DebugEnterDecision(8, false);
				int LA8_1 = input.LA(1);

				if ((LA8_1==LT))
				{
					alt8 = 1;
				}


				} finally { DebugExitDecision(8); }
				switch ( alt8 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:50:54: LT
					{
					DebugLocation(50, 54);
					LT15=(IToken)Match(input,LT,Follow._LT_in_functionDeclaration217); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT15);


					}
					break;

				default:
					goto loop8;
				}
			}

			loop8:
				;

			} finally { DebugExitSubRule(8); }

			DebugLocation(50, 58);
			PushFollow(Follow._functionBody_in_functionDeclaration220);
			functionBody16=functionBody();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_functionBody.Add(functionBody16.Tree);


			{
			// AST REWRITE
			// elements: 93, Identifier, formalParameterList, functionBody
			// 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();
			// 51:3: -> ^( 'function' Identifier formalParameterList functionBody )
			{
				DebugLocation(51, 6);
				// JavaScript.g:51:6: ^( 'function' Identifier formalParameterList functionBody )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(51, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new FunctionDeclaration(stream_93.NextToken()), root_1);

				DebugLocation(52, 5);
				adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));
				DebugLocation(53, 5);
				adaptor.AddChild(root_1, stream_formalParameterList.NextTree());
				DebugLocation(54, 5);
				adaptor.AddChild(root_1, stream_functionBody.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("functionDeclaration", 4);
			LeaveRule("functionDeclaration", 4);
			LeaveRule_functionDeclaration();
			if (state.backtracking > 0) { Memoize(input, 4, functionDeclaration_StartIndex); }

		}
		DebugLocation(55, 1);
		} finally { DebugExitRule(GrammarFileName, "functionDeclaration"); }
		return retval;

	}
コード例 #16
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> ifStatement()
	{
		EnterRule_ifStatement();
		EnterRule("ifStatement", 20);
		TraceIn("ifStatement", 20);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int ifStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal91 = default(IToken);
		IToken LT92 = default(IToken);
		IToken char_literal93 = default(IToken);
		IToken LT94 = default(IToken);
		IToken LT96 = default(IToken);
		IToken char_literal97 = default(IToken);
		IToken LT98 = default(IToken);
		IToken LT99 = default(IToken);
		IToken string_literal100 = default(IToken);
		IToken LT101 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> ifstmt = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> elsestmt = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> expression95 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal91_tree = default(CommonTree);
		CommonTree LT92_tree = default(CommonTree);
		CommonTree char_literal93_tree = default(CommonTree);
		CommonTree LT94_tree = default(CommonTree);
		CommonTree LT96_tree = default(CommonTree);
		CommonTree char_literal97_tree = default(CommonTree);
		CommonTree LT98_tree = default(CommonTree);
		CommonTree LT99_tree = default(CommonTree);
		CommonTree string_literal100_tree = default(CommonTree);
		CommonTree LT101_tree = default(CommonTree);
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleITokenStream stream_89=new RewriteRuleITokenStream(adaptor,"token 89");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "ifStatement");
		DebugLocation(143, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 20)) { return retval; }

			// JavaScript.g:144:2: ( 'if' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* ifstmt= statement ( ( LT )* 'else' ( LT )* elsestmt= statement )? -> ^( 'if' expression $ifstmt ( $elsestmt)? ) )
			DebugEnterAlt(1);
			// JavaScript.g:144:4: 'if' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* ifstmt= statement ( ( LT )* 'else' ( LT )* elsestmt= statement )?
			{
			DebugLocation(144, 4);
			string_literal91=(IToken)Match(input,94,Follow._94_in_ifStatement860); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_94.Add(string_literal91);

			DebugLocation(144, 9);
			// JavaScript.g:144:9: ( LT )*
			try { DebugEnterSubRule(43);
			while (true)
			{
				int alt43=2;
				try { DebugEnterDecision(43, false);
				int LA43_1 = input.LA(1);

				if ((LA43_1==LT))
				{
					alt43 = 1;
				}


				} finally { DebugExitDecision(43); }
				switch ( alt43 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:144:9: LT
					{
					DebugLocation(144, 9);
					LT92=(IToken)Match(input,LT,Follow._LT_in_ifStatement862); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT92);


					}
					break;

				default:
					goto loop43;
				}
			}

			loop43:
				;

			} finally { DebugExitSubRule(43); }

			DebugLocation(144, 13);
			char_literal93=(IToken)Match(input,48,Follow._48_in_ifStatement865); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal93);

			DebugLocation(144, 17);
			// JavaScript.g:144:17: ( LT )*
			try { DebugEnterSubRule(44);
			while (true)
			{
				int alt44=2;
				try { DebugEnterDecision(44, false);
				int LA44_1 = input.LA(1);

				if ((LA44_1==LT))
				{
					alt44 = 1;
				}


				} finally { DebugExitDecision(44); }
				switch ( alt44 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:144:17: LT
					{
					DebugLocation(144, 17);
					LT94=(IToken)Match(input,LT,Follow._LT_in_ifStatement867); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT94);


					}
					break;

				default:
					goto loop44;
				}
			}

			loop44:
				;

			} finally { DebugExitSubRule(44); }

			DebugLocation(144, 21);
			PushFollow(Follow._expression_in_ifStatement870);
			expression95=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression95.Tree);
			DebugLocation(144, 32);
			// JavaScript.g:144:32: ( LT )*
			try { DebugEnterSubRule(45);
			while (true)
			{
				int alt45=2;
				try { DebugEnterDecision(45, false);
				int LA45_1 = input.LA(1);

				if ((LA45_1==LT))
				{
					alt45 = 1;
				}


				} finally { DebugExitDecision(45); }
				switch ( alt45 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:144:32: LT
					{
					DebugLocation(144, 32);
					LT96=(IToken)Match(input,LT,Follow._LT_in_ifStatement872); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT96);


					}
					break;

				default:
					goto loop45;
				}
			}

			loop45:
				;

			} finally { DebugExitSubRule(45); }

			DebugLocation(144, 36);
			char_literal97=(IToken)Match(input,49,Follow._49_in_ifStatement875); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal97);

			DebugLocation(144, 40);
			// JavaScript.g:144:40: ( LT )*
			try { DebugEnterSubRule(46);
			while (true)
			{
				int alt46=2;
				try { DebugEnterDecision(46, false);
				int LA46_1 = input.LA(1);

				if ((LA46_1==LT))
				{
					alt46 = 1;
				}


				} finally { DebugExitDecision(46); }
				switch ( alt46 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:144:40: LT
					{
					DebugLocation(144, 40);
					LT98=(IToken)Match(input,LT,Follow._LT_in_ifStatement877); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT98);


					}
					break;

				default:
					goto loop46;
				}
			}

			loop46:
				;

			} finally { DebugExitSubRule(46); }

			DebugLocation(144, 50);
			PushFollow(Follow._statement_in_ifStatement882);
			ifstmt=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(ifstmt.Tree);
			DebugLocation(144, 61);
			// JavaScript.g:144:61: ( ( LT )* 'else' ( LT )* elsestmt= statement )?
			int alt49=2;
			try { DebugEnterSubRule(49);
			try { DebugEnterDecision(49, false);
			int LA49_1 = input.LA(1);

			if ((LA49_1==LT))
			{
				int LA49_2 = input.LA(2);

				if ((EvaluatePredicate(synpred61_JavaScript_fragment)))
				{
					alt49 = 1;
				}
			}
			else if ((LA49_1==89))
			{
				int LA49_2 = input.LA(2);

				if ((EvaluatePredicate(synpred61_JavaScript_fragment)))
				{
					alt49 = 1;
				}
			}
			} finally { DebugExitDecision(49); }
			switch (alt49)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:144:62: ( LT )* 'else' ( LT )* elsestmt= statement
				{
				DebugLocation(144, 62);
				// JavaScript.g:144:62: ( LT )*
				try { DebugEnterSubRule(47);
				while (true)
				{
					int alt47=2;
					try { DebugEnterDecision(47, false);
					int LA47_1 = input.LA(1);

					if ((LA47_1==LT))
					{
						alt47 = 1;
					}


					} finally { DebugExitDecision(47); }
					switch ( alt47 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:144:62: LT
						{
						DebugLocation(144, 62);
						LT99=(IToken)Match(input,LT,Follow._LT_in_ifStatement885); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT99);


						}
						break;

					default:
						goto loop47;
					}
				}

				loop47:
					;

				} finally { DebugExitSubRule(47); }

				DebugLocation(144, 66);
				string_literal100=(IToken)Match(input,89,Follow._89_in_ifStatement888); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_89.Add(string_literal100);

				DebugLocation(144, 73);
				// JavaScript.g:144:73: ( LT )*
				try { DebugEnterSubRule(48);
				while (true)
				{
					int alt48=2;
					try { DebugEnterDecision(48, false);
					int LA48_1 = input.LA(1);

					if ((LA48_1==LT))
					{
						alt48 = 1;
					}


					} finally { DebugExitDecision(48); }
					switch ( alt48 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:144:73: LT
						{
						DebugLocation(144, 73);
						LT101=(IToken)Match(input,LT,Follow._LT_in_ifStatement890); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT101);


						}
						break;

					default:
						goto loop48;
					}
				}

				loop48:
					;

				} finally { DebugExitSubRule(48); }

				DebugLocation(144, 85);
				PushFollow(Follow._statement_in_ifStatement895);
				elsestmt=statement();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_statement.Add(elsestmt.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(49); }



			{
			// AST REWRITE
			// elements: 94, expression, ifstmt, elsestmt
			// token labels: 
			// rule labels: ifstmt, elsestmt, retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			if (state.backtracking == 0) {
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_ifstmt=new RewriteRuleSubtreeStream(adaptor,"rule ifstmt",ifstmt!=null?ifstmt.Tree:null);
			RewriteRuleSubtreeStream stream_elsestmt=new RewriteRuleSubtreeStream(adaptor,"rule elsestmt",elsestmt!=null?elsestmt.Tree:null);
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (CommonTree)adaptor.Nil();
			// 145:3: -> ^( 'if' expression $ifstmt ( $elsestmt)? )
			{
				DebugLocation(145, 6);
				// JavaScript.g:145:6: ^( 'if' expression $ifstmt ( $elsestmt)? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(145, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new IfStatement(stream_94.NextToken()), root_1);

				DebugLocation(145, 31);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(145, 43);
				adaptor.AddChild(root_1, stream_ifstmt.NextTree());
				DebugLocation(145, 51);
				// JavaScript.g:145:51: ( $elsestmt)?
				if (stream_elsestmt.HasNext)
				{
					DebugLocation(145, 51);
					adaptor.AddChild(root_1, stream_elsestmt.NextTree());

				}
				stream_elsestmt.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("ifStatement", 20);
			LeaveRule("ifStatement", 20);
			LeaveRule_ifStatement();
			if (state.backtracking > 0) { Memoize(input, 20, ifStatement_StartIndex); }

		}
		DebugLocation(146, 1);
		} finally { DebugExitRule(GrammarFileName, "ifStatement"); }
		return retval;

	}
コード例 #17
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> breakStatement()
	{
		EnterRule_breakStatement();
		EnterRule("breakStatement", 29);
		TraceIn("breakStatement", 29);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int breakStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal166 = default(IToken);
		IToken Identifier167 = default(IToken);
		IToken LT168 = default(IToken);
		IToken char_literal169 = default(IToken);

		CommonTree string_literal166_tree = default(CommonTree);
		CommonTree Identifier167_tree = default(CommonTree);
		CommonTree LT168_tree = default(CommonTree);
		CommonTree char_literal169_tree = default(CommonTree);
		RewriteRuleITokenStream stream_82=new RewriteRuleITokenStream(adaptor,"token 82");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		try { DebugEnterRule(GrammarFileName, "breakStatement");
		DebugLocation(198, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 29)) { return retval; }

			// JavaScript.g:199:2: ( 'break' ( Identifier )? ( LT | ';' ) -> ^( 'break' ( Identifier )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:199:4: 'break' ( Identifier )? ( LT | ';' )
			{
			DebugLocation(199, 4);
			string_literal166=(IToken)Match(input,82,Follow._82_in_breakStatement1392); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_82.Add(string_literal166);

			DebugLocation(199, 12);
			// JavaScript.g:199:12: ( Identifier )?
			int alt82=2;
			try { DebugEnterSubRule(82);
			try { DebugEnterDecision(82, false);
			int LA82_1 = input.LA(1);

			if ((LA82_1==Identifier))
			{
				alt82 = 1;
			}
			} finally { DebugExitDecision(82); }
			switch (alt82)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:199:12: Identifier
				{
				DebugLocation(199, 12);
				Identifier167=(IToken)Match(input,Identifier,Follow._Identifier_in_breakStatement1394); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier167);


				}
				break;

			}
			} finally { DebugExitSubRule(82); }

			DebugLocation(199, 24);
			// JavaScript.g:199:24: ( LT | ';' )
			int alt83=2;
			try { DebugEnterSubRule(83);
			try { DebugEnterDecision(83, false);
			int LA83_1 = input.LA(1);

			if ((LA83_1==LT))
			{
				alt83 = 1;
			}
			else if ((LA83_1==63))
			{
				alt83 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 83, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(83); }
			switch (alt83)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:199:25: LT
				{
				DebugLocation(199, 25);
				LT168=(IToken)Match(input,LT,Follow._LT_in_breakStatement1398); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT168);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:199:30: ';'
				{
				DebugLocation(199, 30);
				char_literal169=(IToken)Match(input,63,Follow._63_in_breakStatement1402); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal169);


				}
				break;

			}
			} finally { DebugExitSubRule(83); }



			{
			// AST REWRITE
			// elements: 82, Identifier
			// 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();
			// 199:35: -> ^( 'break' ( Identifier )? )
			{
				DebugLocation(199, 38);
				// JavaScript.g:199:38: ^( 'break' ( Identifier )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(199, 40);
				root_1 = (CommonTree)adaptor.BecomeRoot(new BreakStatement(stream_82.NextToken()), root_1);

				DebugLocation(199, 69);
				// JavaScript.g:199:69: ( Identifier )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(199, 69);
					adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));

				}
				stream_Identifier.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("breakStatement", 29);
			LeaveRule("breakStatement", 29);
			LeaveRule_breakStatement();
			if (state.backtracking > 0) { Memoize(input, 29, breakStatement_StartIndex); }

		}
		DebugLocation(200, 1);
		} finally { DebugExitRule(GrammarFileName, "breakStatement"); }
		return retval;

	}
コード例 #18
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> doWhileStatement()
	{
		EnterRule_doWhileStatement();
		EnterRule("doWhileStatement", 22);
		TraceIn("doWhileStatement", 22);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int doWhileStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal106 = default(IToken);
		IToken LT107 = default(IToken);
		IToken LT109 = default(IToken);
		IToken string_literal110 = default(IToken);
		IToken LT111 = default(IToken);
		IToken char_literal112 = default(IToken);
		IToken char_literal114 = default(IToken);
		IToken LT115 = default(IToken);
		IToken char_literal116 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statement108 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> expression113 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal106_tree = default(CommonTree);
		CommonTree LT107_tree = default(CommonTree);
		CommonTree LT109_tree = default(CommonTree);
		CommonTree string_literal110_tree = default(CommonTree);
		CommonTree LT111_tree = default(CommonTree);
		CommonTree char_literal112_tree = default(CommonTree);
		CommonTree char_literal114_tree = default(CommonTree);
		CommonTree LT115_tree = default(CommonTree);
		CommonTree char_literal116_tree = default(CommonTree);
		RewriteRuleITokenStream stream_88=new RewriteRuleITokenStream(adaptor,"token 88");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_108=new RewriteRuleITokenStream(adaptor,"token 108");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		try { DebugEnterRule(GrammarFileName, "doWhileStatement");
		DebugLocation(155, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 22)) { return retval; }

			// JavaScript.g:156:2: ( 'do' ( LT )* statement ( LT )* 'while' ( LT )* '(' expression ')' ( LT | ';' ) -> ^( 'do' statement expression ) )
			DebugEnterAlt(1);
			// JavaScript.g:156:4: 'do' ( LT )* statement ( LT )* 'while' ( LT )* '(' expression ')' ( LT | ';' )
			{
			DebugLocation(156, 4);
			string_literal106=(IToken)Match(input,88,Follow._88_in_doWhileStatement958); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_88.Add(string_literal106);

			DebugLocation(156, 9);
			// JavaScript.g:156:9: ( LT )*
			try { DebugEnterSubRule(51);
			while (true)
			{
				int alt51=2;
				try { DebugEnterDecision(51, false);
				int LA51_1 = input.LA(1);

				if ((LA51_1==LT))
				{
					alt51 = 1;
				}


				} finally { DebugExitDecision(51); }
				switch ( alt51 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:156:9: LT
					{
					DebugLocation(156, 9);
					LT107=(IToken)Match(input,LT,Follow._LT_in_doWhileStatement960); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT107);


					}
					break;

				default:
					goto loop51;
				}
			}

			loop51:
				;

			} finally { DebugExitSubRule(51); }

			DebugLocation(156, 13);
			PushFollow(Follow._statement_in_doWhileStatement963);
			statement108=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement108.Tree);
			DebugLocation(156, 23);
			// JavaScript.g:156:23: ( LT )*
			try { DebugEnterSubRule(52);
			while (true)
			{
				int alt52=2;
				try { DebugEnterDecision(52, false);
				int LA52_1 = input.LA(1);

				if ((LA52_1==LT))
				{
					alt52 = 1;
				}


				} finally { DebugExitDecision(52); }
				switch ( alt52 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:156:23: LT
					{
					DebugLocation(156, 23);
					LT109=(IToken)Match(input,LT,Follow._LT_in_doWhileStatement965); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT109);


					}
					break;

				default:
					goto loop52;
				}
			}

			loop52:
				;

			} finally { DebugExitSubRule(52); }

			DebugLocation(156, 27);
			string_literal110=(IToken)Match(input,108,Follow._108_in_doWhileStatement968); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_108.Add(string_literal110);

			DebugLocation(156, 35);
			// JavaScript.g:156:35: ( LT )*
			try { DebugEnterSubRule(53);
			while (true)
			{
				int alt53=2;
				try { DebugEnterDecision(53, false);
				int LA53_1 = input.LA(1);

				if ((LA53_1==LT))
				{
					alt53 = 1;
				}


				} finally { DebugExitDecision(53); }
				switch ( alt53 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:156:35: LT
					{
					DebugLocation(156, 35);
					LT111=(IToken)Match(input,LT,Follow._LT_in_doWhileStatement970); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT111);


					}
					break;

				default:
					goto loop53;
				}
			}

			loop53:
				;

			} finally { DebugExitSubRule(53); }

			DebugLocation(156, 39);
			char_literal112=(IToken)Match(input,48,Follow._48_in_doWhileStatement973); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal112);

			DebugLocation(156, 43);
			PushFollow(Follow._expression_in_doWhileStatement975);
			expression113=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression113.Tree);
			DebugLocation(156, 54);
			char_literal114=(IToken)Match(input,49,Follow._49_in_doWhileStatement977); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal114);

			DebugLocation(156, 58);
			// JavaScript.g:156:58: ( LT | ';' )
			int alt54=2;
			try { DebugEnterSubRule(54);
			try { DebugEnterDecision(54, false);
			int LA54_1 = input.LA(1);

			if ((LA54_1==LT))
			{
				alt54 = 1;
			}
			else if ((LA54_1==63))
			{
				alt54 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 54, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(54); }
			switch (alt54)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:156:59: LT
				{
				DebugLocation(156, 59);
				LT115=(IToken)Match(input,LT,Follow._LT_in_doWhileStatement980); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT115);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:156:64: ';'
				{
				DebugLocation(156, 64);
				char_literal116=(IToken)Match(input,63,Follow._63_in_doWhileStatement984); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal116);


				}
				break;

			}
			} finally { DebugExitSubRule(54); }



			{
			// AST REWRITE
			// elements: 88, statement, 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();
			// 157:3: -> ^( 'do' statement expression )
			{
				DebugLocation(157, 6);
				// JavaScript.g:157:6: ^( 'do' statement expression )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(157, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new DoWhileStatement(stream_88.NextToken()), root_1);

				DebugLocation(157, 36);
				adaptor.AddChild(root_1, stream_statement.NextTree());
				DebugLocation(157, 46);
				adaptor.AddChild(root_1, stream_expression.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("doWhileStatement", 22);
			LeaveRule("doWhileStatement", 22);
			LeaveRule_doWhileStatement();
			if (state.backtracking > 0) { Memoize(input, 22, doWhileStatement_StartIndex); }

		}
		DebugLocation(158, 1);
		} finally { DebugExitRule(GrammarFileName, "doWhileStatement"); }
		return retval;

	}
コード例 #19
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> withStatement()
	{
		EnterRule_withStatement();
		EnterRule("withStatement", 31);
		TraceIn("withStatement", 31);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int withStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal174 = default(IToken);
		IToken LT175 = default(IToken);
		IToken char_literal176 = default(IToken);
		IToken LT177 = default(IToken);
		IToken LT179 = default(IToken);
		IToken char_literal180 = default(IToken);
		IToken LT181 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression178 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> statement182 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal174_tree = default(CommonTree);
		CommonTree LT175_tree = default(CommonTree);
		CommonTree char_literal176_tree = default(CommonTree);
		CommonTree LT177_tree = default(CommonTree);
		CommonTree LT179_tree = default(CommonTree);
		CommonTree char_literal180_tree = default(CommonTree);
		CommonTree LT181_tree = default(CommonTree);
		RewriteRuleITokenStream stream_109=new RewriteRuleITokenStream(adaptor,"token 109");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "withStatement");
		DebugLocation(206, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 31)) { return retval; }

			// JavaScript.g:207:2: ( 'with' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* statement -> ^( 'with' expression statement ) )
			DebugEnterAlt(1);
			// JavaScript.g:207:4: 'with' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* statement
			{
			DebugLocation(207, 4);
			string_literal174=(IToken)Match(input,109,Follow._109_in_withStatement1470); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_109.Add(string_literal174);

			DebugLocation(207, 11);
			// JavaScript.g:207:11: ( LT )*
			try { DebugEnterSubRule(86);
			while (true)
			{
				int alt86=2;
				try { DebugEnterDecision(86, false);
				int LA86_1 = input.LA(1);

				if ((LA86_1==LT))
				{
					alt86 = 1;
				}


				} finally { DebugExitDecision(86); }
				switch ( alt86 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:207:11: LT
					{
					DebugLocation(207, 11);
					LT175=(IToken)Match(input,LT,Follow._LT_in_withStatement1472); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT175);


					}
					break;

				default:
					goto loop86;
				}
			}

			loop86:
				;

			} finally { DebugExitSubRule(86); }

			DebugLocation(207, 15);
			char_literal176=(IToken)Match(input,48,Follow._48_in_withStatement1475); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal176);

			DebugLocation(207, 19);
			// JavaScript.g:207:19: ( LT )*
			try { DebugEnterSubRule(87);
			while (true)
			{
				int alt87=2;
				try { DebugEnterDecision(87, false);
				int LA87_1 = input.LA(1);

				if ((LA87_1==LT))
				{
					alt87 = 1;
				}


				} finally { DebugExitDecision(87); }
				switch ( alt87 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:207:19: LT
					{
					DebugLocation(207, 19);
					LT177=(IToken)Match(input,LT,Follow._LT_in_withStatement1477); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT177);


					}
					break;

				default:
					goto loop87;
				}
			}

			loop87:
				;

			} finally { DebugExitSubRule(87); }

			DebugLocation(207, 23);
			PushFollow(Follow._expression_in_withStatement1480);
			expression178=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression178.Tree);
			DebugLocation(207, 34);
			// JavaScript.g:207:34: ( LT )*
			try { DebugEnterSubRule(88);
			while (true)
			{
				int alt88=2;
				try { DebugEnterDecision(88, false);
				int LA88_1 = input.LA(1);

				if ((LA88_1==LT))
				{
					alt88 = 1;
				}


				} finally { DebugExitDecision(88); }
				switch ( alt88 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:207:34: LT
					{
					DebugLocation(207, 34);
					LT179=(IToken)Match(input,LT,Follow._LT_in_withStatement1482); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT179);


					}
					break;

				default:
					goto loop88;
				}
			}

			loop88:
				;

			} finally { DebugExitSubRule(88); }

			DebugLocation(207, 38);
			char_literal180=(IToken)Match(input,49,Follow._49_in_withStatement1485); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal180);

			DebugLocation(207, 42);
			// JavaScript.g:207:42: ( LT )*
			try { DebugEnterSubRule(89);
			while (true)
			{
				int alt89=2;
				try { DebugEnterDecision(89, false);
				int LA89_1 = input.LA(1);

				if ((LA89_1==LT))
				{
					alt89 = 1;
				}


				} finally { DebugExitDecision(89); }
				switch ( alt89 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:207:42: LT
					{
					DebugLocation(207, 42);
					LT181=(IToken)Match(input,LT,Follow._LT_in_withStatement1487); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT181);


					}
					break;

				default:
					goto loop89;
				}
			}

			loop89:
				;

			} finally { DebugExitSubRule(89); }

			DebugLocation(207, 46);
			PushFollow(Follow._statement_in_withStatement1490);
			statement182=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement182.Tree);


			{
			// AST REWRITE
			// elements: 109, expression, 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();
			// 208:3: -> ^( 'with' expression statement )
			{
				DebugLocation(208, 6);
				// JavaScript.g:208:6: ^( 'with' expression statement )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(208, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new WithStatement(stream_109.NextToken()), root_1);

				DebugLocation(208, 35);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(208, 46);
				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("withStatement", 31);
			LeaveRule("withStatement", 31);
			LeaveRule_withStatement();
			if (state.backtracking > 0) { Memoize(input, 31, withStatement_StartIndex); }

		}
		DebugLocation(209, 1);
		} finally { DebugExitRule(GrammarFileName, "withStatement"); }
		return retval;

	}
コード例 #20
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> whileStatement()
	{
		EnterRule_whileStatement();
		EnterRule("whileStatement", 23);
		TraceIn("whileStatement", 23);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int whileStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal117 = default(IToken);
		IToken LT118 = default(IToken);
		IToken char_literal119 = default(IToken);
		IToken LT120 = default(IToken);
		IToken LT122 = default(IToken);
		IToken char_literal123 = default(IToken);
		IToken LT124 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression121 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> statement125 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal117_tree = default(CommonTree);
		CommonTree LT118_tree = default(CommonTree);
		CommonTree char_literal119_tree = default(CommonTree);
		CommonTree LT120_tree = default(CommonTree);
		CommonTree LT122_tree = default(CommonTree);
		CommonTree char_literal123_tree = default(CommonTree);
		CommonTree LT124_tree = default(CommonTree);
		RewriteRuleITokenStream stream_108=new RewriteRuleITokenStream(adaptor,"token 108");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "whileStatement");
		DebugLocation(160, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 23)) { return retval; }

			// JavaScript.g:161:2: ( 'while' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* statement -> ^( 'while' expression statement ) )
			DebugEnterAlt(1);
			// JavaScript.g:161:4: 'while' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* statement
			{
			DebugLocation(161, 4);
			string_literal117=(IToken)Match(input,108,Follow._108_in_whileStatement1014); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_108.Add(string_literal117);

			DebugLocation(161, 12);
			// JavaScript.g:161:12: ( LT )*
			try { DebugEnterSubRule(55);
			while (true)
			{
				int alt55=2;
				try { DebugEnterDecision(55, false);
				int LA55_1 = input.LA(1);

				if ((LA55_1==LT))
				{
					alt55 = 1;
				}


				} finally { DebugExitDecision(55); }
				switch ( alt55 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:161:12: LT
					{
					DebugLocation(161, 12);
					LT118=(IToken)Match(input,LT,Follow._LT_in_whileStatement1016); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT118);


					}
					break;

				default:
					goto loop55;
				}
			}

			loop55:
				;

			} finally { DebugExitSubRule(55); }

			DebugLocation(161, 16);
			char_literal119=(IToken)Match(input,48,Follow._48_in_whileStatement1019); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal119);

			DebugLocation(161, 20);
			// JavaScript.g:161:20: ( LT )*
			try { DebugEnterSubRule(56);
			while (true)
			{
				int alt56=2;
				try { DebugEnterDecision(56, false);
				int LA56_1 = input.LA(1);

				if ((LA56_1==LT))
				{
					alt56 = 1;
				}


				} finally { DebugExitDecision(56); }
				switch ( alt56 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:161:20: LT
					{
					DebugLocation(161, 20);
					LT120=(IToken)Match(input,LT,Follow._LT_in_whileStatement1021); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT120);


					}
					break;

				default:
					goto loop56;
				}
			}

			loop56:
				;

			} finally { DebugExitSubRule(56); }

			DebugLocation(161, 24);
			PushFollow(Follow._expression_in_whileStatement1024);
			expression121=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression121.Tree);
			DebugLocation(161, 35);
			// JavaScript.g:161:35: ( LT )*
			try { DebugEnterSubRule(57);
			while (true)
			{
				int alt57=2;
				try { DebugEnterDecision(57, false);
				int LA57_1 = input.LA(1);

				if ((LA57_1==LT))
				{
					alt57 = 1;
				}


				} finally { DebugExitDecision(57); }
				switch ( alt57 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:161:35: LT
					{
					DebugLocation(161, 35);
					LT122=(IToken)Match(input,LT,Follow._LT_in_whileStatement1026); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT122);


					}
					break;

				default:
					goto loop57;
				}
			}

			loop57:
				;

			} finally { DebugExitSubRule(57); }

			DebugLocation(161, 39);
			char_literal123=(IToken)Match(input,49,Follow._49_in_whileStatement1029); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal123);

			DebugLocation(161, 43);
			// JavaScript.g:161:43: ( LT )*
			try { DebugEnterSubRule(58);
			while (true)
			{
				int alt58=2;
				try { DebugEnterDecision(58, false);
				int LA58_1 = input.LA(1);

				if ((LA58_1==LT))
				{
					alt58 = 1;
				}


				} finally { DebugExitDecision(58); }
				switch ( alt58 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:161:43: LT
					{
					DebugLocation(161, 43);
					LT124=(IToken)Match(input,LT,Follow._LT_in_whileStatement1031); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT124);


					}
					break;

				default:
					goto loop58;
				}
			}

			loop58:
				;

			} finally { DebugExitSubRule(58); }

			DebugLocation(161, 47);
			PushFollow(Follow._statement_in_whileStatement1034);
			statement125=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement125.Tree);


			{
			// AST REWRITE
			// elements: 108, expression, 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();
			// 162:3: -> ^( 'while' expression statement )
			{
				DebugLocation(162, 6);
				// JavaScript.g:162:6: ^( 'while' expression statement )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(162, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new WhileStatement(stream_108.NextToken()), root_1);

				DebugLocation(162, 37);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(162, 48);
				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("whileStatement", 23);
			LeaveRule("whileStatement", 23);
			LeaveRule_whileStatement();
			if (state.backtracking > 0) { Memoize(input, 23, whileStatement_StartIndex); }

		}
		DebugLocation(163, 1);
		} finally { DebugExitRule(GrammarFileName, "whileStatement"); }
		return retval;

	}
コード例 #21
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> switchStatement()
	{
		EnterRule_switchStatement();
		EnterRule("switchStatement", 33);
		TraceIn("switchStatement", 33);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int switchStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal188 = default(IToken);
		IToken LT189 = default(IToken);
		IToken char_literal190 = default(IToken);
		IToken LT191 = default(IToken);
		IToken LT193 = default(IToken);
		IToken char_literal194 = default(IToken);
		IToken LT195 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expression192 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> caseBlock196 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal188_tree = default(CommonTree);
		CommonTree LT189_tree = default(CommonTree);
		CommonTree char_literal190_tree = default(CommonTree);
		CommonTree LT191_tree = default(CommonTree);
		CommonTree LT193_tree = default(CommonTree);
		CommonTree char_literal194_tree = default(CommonTree);
		CommonTree LT195_tree = default(CommonTree);
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_caseBlock=new RewriteRuleSubtreeStream(adaptor,"rule caseBlock");
		try { DebugEnterRule(GrammarFileName, "switchStatement");
		DebugLocation(216, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 33)) { return retval; }

			// JavaScript.g:217:2: ( 'switch' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* caseBlock -> ^( 'switch' expression caseBlock ) )
			DebugEnterAlt(1);
			// JavaScript.g:217:4: 'switch' ( LT )* '(' ( LT )* expression ( LT )* ')' ( LT )* caseBlock
			{
			DebugLocation(217, 4);
			string_literal188=(IToken)Match(input,100,Follow._100_in_switchStatement1570); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_100.Add(string_literal188);

			DebugLocation(217, 13);
			// JavaScript.g:217:13: ( LT )*
			try { DebugEnterSubRule(92);
			while (true)
			{
				int alt92=2;
				try { DebugEnterDecision(92, false);
				int LA92_1 = input.LA(1);

				if ((LA92_1==LT))
				{
					alt92 = 1;
				}


				} finally { DebugExitDecision(92); }
				switch ( alt92 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:217:13: LT
					{
					DebugLocation(217, 13);
					LT189=(IToken)Match(input,LT,Follow._LT_in_switchStatement1572); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT189);


					}
					break;

				default:
					goto loop92;
				}
			}

			loop92:
				;

			} finally { DebugExitSubRule(92); }

			DebugLocation(217, 17);
			char_literal190=(IToken)Match(input,48,Follow._48_in_switchStatement1575); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal190);

			DebugLocation(217, 21);
			// JavaScript.g:217:21: ( LT )*
			try { DebugEnterSubRule(93);
			while (true)
			{
				int alt93=2;
				try { DebugEnterDecision(93, false);
				int LA93_1 = input.LA(1);

				if ((LA93_1==LT))
				{
					alt93 = 1;
				}


				} finally { DebugExitDecision(93); }
				switch ( alt93 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:217:21: LT
					{
					DebugLocation(217, 21);
					LT191=(IToken)Match(input,LT,Follow._LT_in_switchStatement1577); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT191);


					}
					break;

				default:
					goto loop93;
				}
			}

			loop93:
				;

			} finally { DebugExitSubRule(93); }

			DebugLocation(217, 25);
			PushFollow(Follow._expression_in_switchStatement1580);
			expression192=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression192.Tree);
			DebugLocation(217, 36);
			// JavaScript.g:217:36: ( LT )*
			try { DebugEnterSubRule(94);
			while (true)
			{
				int alt94=2;
				try { DebugEnterDecision(94, false);
				int LA94_1 = input.LA(1);

				if ((LA94_1==LT))
				{
					alt94 = 1;
				}


				} finally { DebugExitDecision(94); }
				switch ( alt94 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:217:36: LT
					{
					DebugLocation(217, 36);
					LT193=(IToken)Match(input,LT,Follow._LT_in_switchStatement1582); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT193);


					}
					break;

				default:
					goto loop94;
				}
			}

			loop94:
				;

			} finally { DebugExitSubRule(94); }

			DebugLocation(217, 40);
			char_literal194=(IToken)Match(input,49,Follow._49_in_switchStatement1585); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal194);

			DebugLocation(217, 44);
			// JavaScript.g:217:44: ( LT )*
			try { DebugEnterSubRule(95);
			while (true)
			{
				int alt95=2;
				try { DebugEnterDecision(95, false);
				int LA95_1 = input.LA(1);

				if ((LA95_1==LT))
				{
					alt95 = 1;
				}


				} finally { DebugExitDecision(95); }
				switch ( alt95 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:217:44: LT
					{
					DebugLocation(217, 44);
					LT195=(IToken)Match(input,LT,Follow._LT_in_switchStatement1587); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT195);


					}
					break;

				default:
					goto loop95;
				}
			}

			loop95:
				;

			} finally { DebugExitSubRule(95); }

			DebugLocation(217, 48);
			PushFollow(Follow._caseBlock_in_switchStatement1590);
			caseBlock196=caseBlock();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_caseBlock.Add(caseBlock196.Tree);


			{
			// AST REWRITE
			// elements: 100, expression, caseBlock
			// 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();
			// 218:3: -> ^( 'switch' expression caseBlock )
			{
				DebugLocation(218, 6);
				// JavaScript.g:218:6: ^( 'switch' expression caseBlock )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(218, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new SwitchStatement(stream_100.NextToken()), root_1);

				DebugLocation(218, 39);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(218, 50);
				adaptor.AddChild(root_1, stream_caseBlock.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("switchStatement", 33);
			LeaveRule("switchStatement", 33);
			LeaveRule_switchStatement();
			if (state.backtracking > 0) { Memoize(input, 33, switchStatement_StartIndex); }

		}
		DebugLocation(219, 1);
		} finally { DebugExitRule(GrammarFileName, "switchStatement"); }
		return retval;

	}
コード例 #22
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> forStatement()
	{
		EnterRule_forStatement();
		EnterRule("forStatement", 24);
		TraceIn("forStatement", 24);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int forStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal126 = default(IToken);
		IToken LT127 = default(IToken);
		IToken char_literal128 = default(IToken);
		IToken LT129 = default(IToken);
		IToken LT131 = default(IToken);
		IToken char_literal132 = default(IToken);
		IToken LT133 = default(IToken);
		IToken LT134 = default(IToken);
		IToken char_literal135 = default(IToken);
		IToken LT136 = default(IToken);
		IToken LT137 = default(IToken);
		IToken char_literal138 = default(IToken);
		IToken LT139 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> condition = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> incr = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> forStatementInitialiserPart130 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> statement140 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal126_tree = default(CommonTree);
		CommonTree LT127_tree = default(CommonTree);
		CommonTree char_literal128_tree = default(CommonTree);
		CommonTree LT129_tree = default(CommonTree);
		CommonTree LT131_tree = default(CommonTree);
		CommonTree char_literal132_tree = default(CommonTree);
		CommonTree LT133_tree = default(CommonTree);
		CommonTree LT134_tree = default(CommonTree);
		CommonTree char_literal135_tree = default(CommonTree);
		CommonTree LT136_tree = default(CommonTree);
		CommonTree LT137_tree = default(CommonTree);
		CommonTree char_literal138_tree = default(CommonTree);
		CommonTree LT139_tree = default(CommonTree);
		RewriteRuleITokenStream stream_92=new RewriteRuleITokenStream(adaptor,"token 92");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_forStatementInitialiserPart=new RewriteRuleSubtreeStream(adaptor,"rule forStatementInitialiserPart");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "forStatement");
		DebugLocation(165, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 24)) { return retval; }

			// JavaScript.g:166:2: ( 'for' ( LT )* '(' ( ( LT )* forStatementInitialiserPart )? ( LT )* ';' ( ( LT )* condition= expression )? ( LT )* ';' ( ( LT )* incr= expression )? ( LT )* ')' ( LT )* statement -> ^( 'for' ^( FORSTMTINIT ( forStatementInitialiserPart )? ) ^( FORSTMTCOND ( $condition)? ) ^( FORSTMTINCR ( $incr)? ) statement ) )
			DebugEnterAlt(1);
			// JavaScript.g:166:4: 'for' ( LT )* '(' ( ( LT )* forStatementInitialiserPart )? ( LT )* ';' ( ( LT )* condition= expression )? ( LT )* ';' ( ( LT )* incr= expression )? ( LT )* ')' ( LT )* statement
			{
			DebugLocation(166, 4);
			string_literal126=(IToken)Match(input,92,Follow._92_in_forStatement1064); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_92.Add(string_literal126);

			DebugLocation(166, 10);
			// JavaScript.g:166:10: ( LT )*
			try { DebugEnterSubRule(59);
			while (true)
			{
				int alt59=2;
				try { DebugEnterDecision(59, false);
				int LA59_1 = input.LA(1);

				if ((LA59_1==LT))
				{
					alt59 = 1;
				}


				} finally { DebugExitDecision(59); }
				switch ( alt59 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:166:10: LT
					{
					DebugLocation(166, 10);
					LT127=(IToken)Match(input,LT,Follow._LT_in_forStatement1066); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT127);


					}
					break;

				default:
					goto loop59;
				}
			}

			loop59:
				;

			} finally { DebugExitSubRule(59); }

			DebugLocation(166, 14);
			char_literal128=(IToken)Match(input,48,Follow._48_in_forStatement1069); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal128);

			DebugLocation(166, 18);
			// JavaScript.g:166:18: ( ( LT )* forStatementInitialiserPart )?
			int alt61=2;
			try { DebugEnterSubRule(61);
			try { DebugEnterDecision(61, false);
			try
			{
				alt61 = dfa61.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(61); }
			switch (alt61)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:166:19: ( LT )* forStatementInitialiserPart
				{
				DebugLocation(166, 19);
				// JavaScript.g:166:19: ( LT )*
				try { DebugEnterSubRule(60);
				while (true)
				{
					int alt60=2;
					try { DebugEnterDecision(60, false);
					int LA60_1 = input.LA(1);

					if ((LA60_1==LT))
					{
						alt60 = 1;
					}


					} finally { DebugExitDecision(60); }
					switch ( alt60 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:166:19: LT
						{
						DebugLocation(166, 19);
						LT129=(IToken)Match(input,LT,Follow._LT_in_forStatement1072); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT129);


						}
						break;

					default:
						goto loop60;
					}
				}

				loop60:
					;

				} finally { DebugExitSubRule(60); }

				DebugLocation(166, 23);
				PushFollow(Follow._forStatementInitialiserPart_in_forStatement1075);
				forStatementInitialiserPart130=forStatementInitialiserPart();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_forStatementInitialiserPart.Add(forStatementInitialiserPart130.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(61); }

			DebugLocation(166, 53);
			// JavaScript.g:166:53: ( LT )*
			try { DebugEnterSubRule(62);
			while (true)
			{
				int alt62=2;
				try { DebugEnterDecision(62, false);
				int LA62_1 = input.LA(1);

				if ((LA62_1==LT))
				{
					alt62 = 1;
				}


				} finally { DebugExitDecision(62); }
				switch ( alt62 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:166:53: LT
					{
					DebugLocation(166, 53);
					LT131=(IToken)Match(input,LT,Follow._LT_in_forStatement1079); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT131);


					}
					break;

				default:
					goto loop62;
				}
			}

			loop62:
				;

			} finally { DebugExitSubRule(62); }

			DebugLocation(166, 57);
			char_literal132=(IToken)Match(input,63,Follow._63_in_forStatement1082); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_63.Add(char_literal132);

			DebugLocation(166, 61);
			// JavaScript.g:166:61: ( ( LT )* condition= expression )?
			int alt64=2;
			try { DebugEnterSubRule(64);
			try { DebugEnterDecision(64, false);
			try
			{
				alt64 = dfa64.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(64); }
			switch (alt64)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:166:62: ( LT )* condition= expression
				{
				DebugLocation(166, 62);
				// JavaScript.g:166:62: ( LT )*
				try { DebugEnterSubRule(63);
				while (true)
				{
					int alt63=2;
					try { DebugEnterDecision(63, false);
					int LA63_1 = input.LA(1);

					if ((LA63_1==LT))
					{
						alt63 = 1;
					}


					} finally { DebugExitDecision(63); }
					switch ( alt63 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:166:62: LT
						{
						DebugLocation(166, 62);
						LT133=(IToken)Match(input,LT,Follow._LT_in_forStatement1085); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT133);


						}
						break;

					default:
						goto loop63;
					}
				}

				loop63:
					;

				} finally { DebugExitSubRule(63); }

				DebugLocation(166, 75);
				PushFollow(Follow._expression_in_forStatement1090);
				condition=expression();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_expression.Add(condition.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(64); }

			DebugLocation(166, 89);
			// JavaScript.g:166:89: ( LT )*
			try { DebugEnterSubRule(65);
			while (true)
			{
				int alt65=2;
				try { DebugEnterDecision(65, false);
				int LA65_1 = input.LA(1);

				if ((LA65_1==LT))
				{
					alt65 = 1;
				}


				} finally { DebugExitDecision(65); }
				switch ( alt65 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:166:89: LT
					{
					DebugLocation(166, 89);
					LT134=(IToken)Match(input,LT,Follow._LT_in_forStatement1094); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT134);


					}
					break;

				default:
					goto loop65;
				}
			}

			loop65:
				;

			} finally { DebugExitSubRule(65); }

			DebugLocation(166, 93);
			char_literal135=(IToken)Match(input,63,Follow._63_in_forStatement1097); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_63.Add(char_literal135);

			DebugLocation(166, 97);
			// JavaScript.g:166:97: ( ( LT )* incr= expression )?
			int alt67=2;
			try { DebugEnterSubRule(67);
			try { DebugEnterDecision(67, false);
			try
			{
				alt67 = dfa67.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(67); }
			switch (alt67)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:166:98: ( LT )* incr= expression
				{
				DebugLocation(166, 98);
				// JavaScript.g:166:98: ( LT )*
				try { DebugEnterSubRule(66);
				while (true)
				{
					int alt66=2;
					try { DebugEnterDecision(66, false);
					int LA66_1 = input.LA(1);

					if ((LA66_1==LT))
					{
						alt66 = 1;
					}


					} finally { DebugExitDecision(66); }
					switch ( alt66 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:166:98: LT
						{
						DebugLocation(166, 98);
						LT136=(IToken)Match(input,LT,Follow._LT_in_forStatement1100); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT136);


						}
						break;

					default:
						goto loop66;
					}
				}

				loop66:
					;

				} finally { DebugExitSubRule(66); }

				DebugLocation(166, 106);
				PushFollow(Follow._expression_in_forStatement1105);
				incr=expression();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_expression.Add(incr.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(67); }

			DebugLocation(166, 120);
			// JavaScript.g:166:120: ( LT )*
			try { DebugEnterSubRule(68);
			while (true)
			{
				int alt68=2;
				try { DebugEnterDecision(68, false);
				int LA68_1 = input.LA(1);

				if ((LA68_1==LT))
				{
					alt68 = 1;
				}


				} finally { DebugExitDecision(68); }
				switch ( alt68 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:166:120: LT
					{
					DebugLocation(166, 120);
					LT137=(IToken)Match(input,LT,Follow._LT_in_forStatement1109); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT137);


					}
					break;

				default:
					goto loop68;
				}
			}

			loop68:
				;

			} finally { DebugExitSubRule(68); }

			DebugLocation(166, 124);
			char_literal138=(IToken)Match(input,49,Follow._49_in_forStatement1112); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal138);

			DebugLocation(166, 128);
			// JavaScript.g:166:128: ( LT )*
			try { DebugEnterSubRule(69);
			while (true)
			{
				int alt69=2;
				try { DebugEnterDecision(69, false);
				int LA69_1 = input.LA(1);

				if ((LA69_1==LT))
				{
					alt69 = 1;
				}


				} finally { DebugExitDecision(69); }
				switch ( alt69 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:166:128: LT
					{
					DebugLocation(166, 128);
					LT139=(IToken)Match(input,LT,Follow._LT_in_forStatement1114); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT139);


					}
					break;

				default:
					goto loop69;
				}
			}

			loop69:
				;

			} finally { DebugExitSubRule(69); }

			DebugLocation(166, 132);
			PushFollow(Follow._statement_in_forStatement1117);
			statement140=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement140.Tree);


			{
			// AST REWRITE
			// elements: 92, forStatementInitialiserPart, condition, incr, statement
			// token labels: 
			// rule labels: condition, incr, retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			if (state.backtracking == 0) {
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_condition=new RewriteRuleSubtreeStream(adaptor,"rule condition",condition!=null?condition.Tree:null);
			RewriteRuleSubtreeStream stream_incr=new RewriteRuleSubtreeStream(adaptor,"rule incr",incr!=null?incr.Tree:null);
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (CommonTree)adaptor.Nil();
			// 167:3: -> ^( 'for' ^( FORSTMTINIT ( forStatementInitialiserPart )? ) ^( FORSTMTCOND ( $condition)? ) ^( FORSTMTINCR ( $incr)? ) statement )
			{
				DebugLocation(167, 6);
				// JavaScript.g:167:6: ^( 'for' ^( FORSTMTINIT ( forStatementInitialiserPart )? ) ^( FORSTMTCOND ( $condition)? ) ^( FORSTMTINCR ( $incr)? ) statement )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(167, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ForStatement(stream_92.NextToken()), root_1);

				DebugLocation(168, 8);
				// JavaScript.g:168:8: ^( FORSTMTINIT ( forStatementInitialiserPart )? )
				{
				CommonTree root_2 = (CommonTree)adaptor.Nil();
				DebugLocation(168, 10);
				root_2 = (CommonTree)adaptor.BecomeRoot(new ForStatementInitializer(FORSTMTINIT), root_2);

				DebugLocation(168, 52);
				// JavaScript.g:168:52: ( forStatementInitialiserPart )?
				if (stream_forStatementInitialiserPart.HasNext)
				{
					DebugLocation(168, 52);
					adaptor.AddChild(root_2, stream_forStatementInitialiserPart.NextTree());

				}
				stream_forStatementInitialiserPart.Reset();

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(169, 8);
				// JavaScript.g:169:8: ^( FORSTMTCOND ( $condition)? )
				{
				CommonTree root_2 = (CommonTree)adaptor.Nil();
				DebugLocation(169, 10);
				root_2 = (CommonTree)adaptor.BecomeRoot(new ForStatementCondition(FORSTMTCOND), root_2);

				DebugLocation(169, 51);
				// JavaScript.g:169:51: ( $condition)?
				if (stream_condition.HasNext)
				{
					DebugLocation(169, 51);
					adaptor.AddChild(root_2, stream_condition.NextTree());

				}
				stream_condition.Reset();

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(170, 8);
				// JavaScript.g:170:8: ^( FORSTMTINCR ( $incr)? )
				{
				CommonTree root_2 = (CommonTree)adaptor.Nil();
				DebugLocation(170, 10);
				root_2 = (CommonTree)adaptor.BecomeRoot(new ForStatementIncrementer(FORSTMTINCR), root_2);

				DebugLocation(170, 53);
				// JavaScript.g:170:53: ( $incr)?
				if (stream_incr.HasNext)
				{
					DebugLocation(170, 53);
					adaptor.AddChild(root_2, stream_incr.NextTree());

				}
				stream_incr.Reset();

				adaptor.AddChild(root_1, root_2);
				}
				DebugLocation(171, 8);
				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("forStatement", 24);
			LeaveRule("forStatement", 24);
			LeaveRule_forStatement();
			if (state.backtracking > 0) { Memoize(input, 24, forStatement_StartIndex); }

		}
		DebugLocation(172, 1);
		} finally { DebugExitRule(GrammarFileName, "forStatement"); }
		return retval;

	}
コード例 #23
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> defaultClause()
	{
		EnterRule_defaultClause();
		EnterRule("defaultClause", 36);
		TraceIn("defaultClause", 36);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int defaultClause_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal213 = default(IToken);
		IToken LT214 = default(IToken);
		IToken char_literal215 = default(IToken);
		IToken LT216 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statementList217 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal213_tree = default(CommonTree);
		CommonTree LT214_tree = default(CommonTree);
		CommonTree char_literal215_tree = default(CommonTree);
		CommonTree LT216_tree = default(CommonTree);
		RewriteRuleITokenStream stream_86=new RewriteRuleITokenStream(adaptor,"token 86");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_62=new RewriteRuleITokenStream(adaptor,"token 62");
		RewriteRuleSubtreeStream stream_statementList=new RewriteRuleSubtreeStream(adaptor,"rule statementList");
		try { DebugEnterRule(GrammarFileName, "defaultClause");
		DebugLocation(229, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 36)) { return retval; }

			// JavaScript.g:230:2: ( 'default' ( LT )* ':' ( LT )* ( statementList )? -> ^( 'default' ( statementList )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:230:4: 'default' ( LT )* ':' ( LT )* ( statementList )?
			{
			DebugLocation(230, 4);
			string_literal213=(IToken)Match(input,86,Follow._86_in_defaultClause1709); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_86.Add(string_literal213);

			DebugLocation(230, 14);
			// JavaScript.g:230:14: ( LT )*
			try { DebugEnterSubRule(107);
			while (true)
			{
				int alt107=2;
				try { DebugEnterDecision(107, false);
				int LA107_1 = input.LA(1);

				if ((LA107_1==LT))
				{
					alt107 = 1;
				}


				} finally { DebugExitDecision(107); }
				switch ( alt107 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:230:14: LT
					{
					DebugLocation(230, 14);
					LT214=(IToken)Match(input,LT,Follow._LT_in_defaultClause1711); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT214);


					}
					break;

				default:
					goto loop107;
				}
			}

			loop107:
				;

			} finally { DebugExitSubRule(107); }

			DebugLocation(230, 18);
			char_literal215=(IToken)Match(input,62,Follow._62_in_defaultClause1714); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_62.Add(char_literal215);

			DebugLocation(230, 22);
			// JavaScript.g:230:22: ( LT )*
			try { DebugEnterSubRule(108);
			while (true)
			{
				int alt108=2;
				try { DebugEnterDecision(108, false);
				int LA108_1 = input.LA(1);

				if ((LA108_1==LT))
				{
					int LA108_2 = input.LA(2);

					if ((EvaluatePredicate(synpred122_JavaScript_fragment)))
					{
						alt108 = 1;
					}


				}


				} finally { DebugExitDecision(108); }
				switch ( alt108 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:230:22: LT
					{
					DebugLocation(230, 22);
					LT216=(IToken)Match(input,LT,Follow._LT_in_defaultClause1716); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT216);


					}
					break;

				default:
					goto loop108;
				}
			}

			loop108:
				;

			} finally { DebugExitSubRule(108); }

			DebugLocation(230, 26);
			// JavaScript.g:230:26: ( statementList )?
			int alt109=2;
			try { DebugEnterSubRule(109);
			try { DebugEnterDecision(109, false);
			int LA109_1 = input.LA(1);

			if ((LA109_1==Identifier||LA109_1==NumericLiteral||LA109_1==StringLiteral||LA109_1==40||LA109_1==48||(LA109_1>=52 && LA109_1<=53)||(LA109_1>=56 && LA109_1<=57)||LA109_1==63||LA109_1==78||LA109_1==82||LA109_1==85||(LA109_1>=87 && LA109_1<=88)||LA109_1==90||(LA109_1>=92 && LA109_1<=94)||(LA109_1>=97 && LA109_1<=110)||LA109_1==115))
			{
				alt109 = 1;
			}
			} finally { DebugExitDecision(109); }
			switch (alt109)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:230:26: statementList
				{
				DebugLocation(230, 26);
				PushFollow(Follow._statementList_in_defaultClause1719);
				statementList217=statementList();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_statementList.Add(statementList217.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(109); }



			{
			// AST REWRITE
			// elements: 86, statementList
			// 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();
			// 230:41: -> ^( 'default' ( statementList )? )
			{
				DebugLocation(230, 44);
				// JavaScript.g:230:44: ^( 'default' ( statementList )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(230, 46);
				root_1 = (CommonTree)adaptor.BecomeRoot(new DefaultCaseClause(stream_86.NextToken()), root_1);

				DebugLocation(230, 80);
				// JavaScript.g:230:80: ( statementList )?
				if (stream_statementList.HasNext)
				{
					DebugLocation(230, 80);
					adaptor.AddChild(root_1, stream_statementList.NextTree());

				}
				stream_statementList.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("defaultClause", 36);
			LeaveRule("defaultClause", 36);
			LeaveRule_defaultClause();
			if (state.backtracking > 0) { Memoize(input, 36, defaultClause_StartIndex); }

		}
		DebugLocation(231, 1);
		} finally { DebugExitRule(GrammarFileName, "defaultClause"); }
		return retval;

	}
コード例 #24
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> forStatementInitialiserPart()
	{
		EnterRule_forStatementInitialiserPart();
		EnterRule("forStatementInitialiserPart", 25);
		TraceIn("forStatementInitialiserPart", 25);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int forStatementInitialiserPart_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal142 = default(IToken);
		IToken LT143 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> expressionNoIn141 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> variableDeclarationListNoIn144 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal142_tree = default(CommonTree);
		CommonTree LT143_tree = default(CommonTree);
		RewriteRuleITokenStream stream_106=new RewriteRuleITokenStream(adaptor,"token 106");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleSubtreeStream stream_variableDeclarationListNoIn=new RewriteRuleSubtreeStream(adaptor,"rule variableDeclarationListNoIn");
		try { DebugEnterRule(GrammarFileName, "forStatementInitialiserPart");
		DebugLocation(174, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 25)) { return retval; }

			// JavaScript.g:175:2: ( expressionNoIn | 'var' ( LT )* variableDeclarationListNoIn -> ^( 'var' variableDeclarationListNoIn ) )
			int alt71=2;
			try { DebugEnterDecision(71, false);
			int LA71_1 = input.LA(1);

			if ((LA71_1==Identifier||LA71_1==NumericLiteral||LA71_1==StringLiteral||LA71_1==40||LA71_1==48||(LA71_1>=52 && LA71_1<=53)||(LA71_1>=56 && LA71_1<=57)||LA71_1==78||LA71_1==87||LA71_1==90||LA71_1==93||(LA71_1>=97 && LA71_1<=98)||LA71_1==101||LA71_1==103||LA71_1==105||LA71_1==107||LA71_1==110||LA71_1==115))
			{
				alt71 = 1;
			}
			else if ((LA71_1==106))
			{
				alt71 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 71, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(71); }
			switch (alt71)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:175:4: expressionNoIn
				{
				root_0 = (CommonTree)adaptor.Nil();

				DebugLocation(175, 4);
				PushFollow(Follow._expressionNoIn_in_forStatementInitialiserPart1213);
				expressionNoIn141=expressionNoIn();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) adaptor.AddChild(root_0, expressionNoIn141.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:176:4: 'var' ( LT )* variableDeclarationListNoIn
				{
				DebugLocation(176, 4);
				string_literal142=(IToken)Match(input,106,Follow._106_in_forStatementInitialiserPart1218); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_106.Add(string_literal142);

				DebugLocation(176, 10);
				// JavaScript.g:176:10: ( LT )*
				try { DebugEnterSubRule(70);
				while (true)
				{
					int alt70=2;
					try { DebugEnterDecision(70, false);
					int LA70_1 = input.LA(1);

					if ((LA70_1==LT))
					{
						alt70 = 1;
					}


					} finally { DebugExitDecision(70); }
					switch ( alt70 )
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:176:10: LT
						{
						DebugLocation(176, 10);
						LT143=(IToken)Match(input,LT,Follow._LT_in_forStatementInitialiserPart1220); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_LT.Add(LT143);


						}
						break;

					default:
						goto loop70;
					}
				}

				loop70:
					;

				} finally { DebugExitSubRule(70); }

				DebugLocation(176, 14);
				PushFollow(Follow._variableDeclarationListNoIn_in_forStatementInitialiserPart1223);
				variableDeclarationListNoIn144=variableDeclarationListNoIn();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_variableDeclarationListNoIn.Add(variableDeclarationListNoIn144.Tree);


				{
				// AST REWRITE
				// elements: 106, variableDeclarationListNoIn
				// 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();
				// 177:3: -> ^( 'var' variableDeclarationListNoIn )
				{
					DebugLocation(177, 6);
					// JavaScript.g:177:6: ^( 'var' variableDeclarationListNoIn )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(177, 8);
					root_1 = (CommonTree)adaptor.BecomeRoot(new VariableStatement(stream_106.NextToken()), root_1);

					DebugLocation(177, 38);
					adaptor.AddChild(root_1, stream_variableDeclarationListNoIn.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				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("forStatementInitialiserPart", 25);
			LeaveRule("forStatementInitialiserPart", 25);
			LeaveRule_forStatementInitialiserPart();
			if (state.backtracking > 0) { Memoize(input, 25, forStatementInitialiserPart_StartIndex); }

		}
		DebugLocation(178, 1);
		} finally { DebugExitRule(GrammarFileName, "forStatementInitialiserPart"); }
		return retval;

	}
コード例 #25
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> tryStatement()
	{
		EnterRule_tryStatement();
		EnterRule("tryStatement", 38);
		TraceIn("tryStatement", 38);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int tryStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal222 = default(IToken);
		IToken LT223 = default(IToken);
		IToken LT225 = default(IToken);
		IToken LT228 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statementBlock224 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> finallyClause226 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> catchClause227 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> finallyClause229 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal222_tree = default(CommonTree);
		CommonTree LT223_tree = default(CommonTree);
		CommonTree LT225_tree = default(CommonTree);
		CommonTree LT228_tree = default(CommonTree);
		RewriteRuleITokenStream stream_104=new RewriteRuleITokenStream(adaptor,"token 104");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleSubtreeStream stream_statementBlock=new RewriteRuleSubtreeStream(adaptor,"rule statementBlock");
		RewriteRuleSubtreeStream stream_finallyClause=new RewriteRuleSubtreeStream(adaptor,"rule finallyClause");
		RewriteRuleSubtreeStream stream_catchClause=new RewriteRuleSubtreeStream(adaptor,"rule catchClause");
		try { DebugEnterRule(GrammarFileName, "tryStatement");
		DebugLocation(237, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 38)) { return retval; }

			// JavaScript.g:238:2: ( 'try' ( LT )* statementBlock ( LT )* ( finallyClause | catchClause ( ( LT )* finallyClause )? ) -> ^( 'try' statementBlock ( catchClause )? ( finallyClause )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:238:4: 'try' ( LT )* statementBlock ( LT )* ( finallyClause | catchClause ( ( LT )* finallyClause )? )
			{
			DebugLocation(238, 4);
			string_literal222=(IToken)Match(input,104,Follow._104_in_tryStatement1780); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_104.Add(string_literal222);

			DebugLocation(238, 10);
			// JavaScript.g:238:10: ( LT )*
			try { DebugEnterSubRule(111);
			while (true)
			{
				int alt111=2;
				try { DebugEnterDecision(111, false);
				int LA111_1 = input.LA(1);

				if ((LA111_1==LT))
				{
					alt111 = 1;
				}


				} finally { DebugExitDecision(111); }
				switch ( alt111 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:238:10: LT
					{
					DebugLocation(238, 10);
					LT223=(IToken)Match(input,LT,Follow._LT_in_tryStatement1782); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT223);


					}
					break;

				default:
					goto loop111;
				}
			}

			loop111:
				;

			} finally { DebugExitSubRule(111); }

			DebugLocation(238, 14);
			PushFollow(Follow._statementBlock_in_tryStatement1785);
			statementBlock224=statementBlock();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statementBlock.Add(statementBlock224.Tree);
			DebugLocation(238, 29);
			// JavaScript.g:238:29: ( LT )*
			try { DebugEnterSubRule(112);
			while (true)
			{
				int alt112=2;
				try { DebugEnterDecision(112, false);
				int LA112_1 = input.LA(1);

				if ((LA112_1==LT))
				{
					alt112 = 1;
				}


				} finally { DebugExitDecision(112); }
				switch ( alt112 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:238:29: LT
					{
					DebugLocation(238, 29);
					LT225=(IToken)Match(input,LT,Follow._LT_in_tryStatement1787); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT225);


					}
					break;

				default:
					goto loop112;
				}
			}

			loop112:
				;

			} finally { DebugExitSubRule(112); }

			DebugLocation(238, 33);
			// JavaScript.g:238:33: ( finallyClause | catchClause ( ( LT )* finallyClause )? )
			int alt115=2;
			try { DebugEnterSubRule(115);
			try { DebugEnterDecision(115, false);
			int LA115_1 = input.LA(1);

			if ((LA115_1==91))
			{
				alt115 = 1;
			}
			else if ((LA115_1==84))
			{
				alt115 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 115, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(115); }
			switch (alt115)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:238:34: finallyClause
				{
				DebugLocation(238, 34);
				PushFollow(Follow._finallyClause_in_tryStatement1791);
				finallyClause226=finallyClause();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_finallyClause.Add(finallyClause226.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:238:50: catchClause ( ( LT )* finallyClause )?
				{
				DebugLocation(238, 50);
				PushFollow(Follow._catchClause_in_tryStatement1795);
				catchClause227=catchClause();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_catchClause.Add(catchClause227.Tree);
				DebugLocation(238, 62);
				// JavaScript.g:238:62: ( ( LT )* finallyClause )?
				int alt114=2;
				try { DebugEnterSubRule(114);
				try { DebugEnterDecision(114, false);
				try
				{
					alt114 = dfa114.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(114); }
				switch (alt114)
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:238:63: ( LT )* finallyClause
					{
					DebugLocation(238, 63);
					// JavaScript.g:238:63: ( LT )*
					try { DebugEnterSubRule(113);
					while (true)
					{
						int alt113=2;
						try { DebugEnterDecision(113, false);
						int LA113_1 = input.LA(1);

						if ((LA113_1==LT))
						{
							alt113 = 1;
						}


						} finally { DebugExitDecision(113); }
						switch ( alt113 )
						{
						case 1:
							DebugEnterAlt(1);
							// JavaScript.g:238:63: LT
							{
							DebugLocation(238, 63);
							LT228=(IToken)Match(input,LT,Follow._LT_in_tryStatement1798); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_LT.Add(LT228);


							}
							break;

						default:
							goto loop113;
						}
					}

					loop113:
						;

					} finally { DebugExitSubRule(113); }

					DebugLocation(238, 67);
					PushFollow(Follow._finallyClause_in_tryStatement1801);
					finallyClause229=finallyClause();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_finallyClause.Add(finallyClause229.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(114); }


				}
				break;

			}
			} finally { DebugExitSubRule(115); }



			{
			// AST REWRITE
			// elements: 104, statementBlock, catchClause, finallyClause
			// 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();
			// 239:3: -> ^( 'try' statementBlock ( catchClause )? ( finallyClause )? )
			{
				DebugLocation(239, 6);
				// JavaScript.g:239:6: ^( 'try' statementBlock ( catchClause )? ( finallyClause )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(239, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new TryStatement(stream_104.NextToken()), root_1);

				DebugLocation(239, 33);
				adaptor.AddChild(root_1, stream_statementBlock.NextTree());
				DebugLocation(239, 48);
				// JavaScript.g:239:48: ( catchClause )?
				if (stream_catchClause.HasNext)
				{
					DebugLocation(239, 48);
					adaptor.AddChild(root_1, stream_catchClause.NextTree());

				}
				stream_catchClause.Reset();
				DebugLocation(239, 61);
				// JavaScript.g:239:61: ( finallyClause )?
				if (stream_finallyClause.HasNext)
				{
					DebugLocation(239, 61);
					adaptor.AddChild(root_1, stream_finallyClause.NextTree());

				}
				stream_finallyClause.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("tryStatement", 38);
			LeaveRule("tryStatement", 38);
			LeaveRule_tryStatement();
			if (state.backtracking > 0) { Memoize(input, 38, tryStatement_StartIndex); }

		}
		DebugLocation(240, 1);
		} finally { DebugExitRule(GrammarFileName, "tryStatement"); }
		return retval;

	}
コード例 #26
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> forInStatement()
	{
		EnterRule_forInStatement();
		EnterRule("forInStatement", 26);
		TraceIn("forInStatement", 26);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int forInStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal145 = default(IToken);
		IToken LT146 = default(IToken);
		IToken char_literal147 = default(IToken);
		IToken LT148 = default(IToken);
		IToken LT150 = default(IToken);
		IToken string_literal151 = default(IToken);
		IToken LT152 = default(IToken);
		IToken LT154 = default(IToken);
		IToken char_literal155 = default(IToken);
		IToken LT156 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> forInStatementInitialiserPart149 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> expression153 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> statement157 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal145_tree = default(CommonTree);
		CommonTree LT146_tree = default(CommonTree);
		CommonTree char_literal147_tree = default(CommonTree);
		CommonTree LT148_tree = default(CommonTree);
		CommonTree LT150_tree = default(CommonTree);
		CommonTree string_literal151_tree = default(CommonTree);
		CommonTree LT152_tree = default(CommonTree);
		CommonTree LT154_tree = default(CommonTree);
		CommonTree char_literal155_tree = default(CommonTree);
		CommonTree LT156_tree = default(CommonTree);
		RewriteRuleITokenStream stream_92=new RewriteRuleITokenStream(adaptor,"token 92");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_95=new RewriteRuleITokenStream(adaptor,"token 95");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_forInStatementInitialiserPart=new RewriteRuleSubtreeStream(adaptor,"rule forInStatementInitialiserPart");
		RewriteRuleSubtreeStream stream_expression=new RewriteRuleSubtreeStream(adaptor,"rule expression");
		RewriteRuleSubtreeStream stream_statement=new RewriteRuleSubtreeStream(adaptor,"rule statement");
		try { DebugEnterRule(GrammarFileName, "forInStatement");
		DebugLocation(180, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 26)) { return retval; }

			// JavaScript.g:181:2: ( 'for' ( LT )* '(' ( LT )* forInStatementInitialiserPart ( LT )* 'in' ( LT )* expression ( LT )* ')' ( LT )* statement -> ^( 'for' forInStatementInitialiserPart expression statement ) )
			DebugEnterAlt(1);
			// JavaScript.g:181:4: 'for' ( LT )* '(' ( LT )* forInStatementInitialiserPart ( LT )* 'in' ( LT )* expression ( LT )* ')' ( LT )* statement
			{
			DebugLocation(181, 4);
			string_literal145=(IToken)Match(input,92,Follow._92_in_forInStatement1251); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_92.Add(string_literal145);

			DebugLocation(181, 10);
			// JavaScript.g:181:10: ( LT )*
			try { DebugEnterSubRule(72);
			while (true)
			{
				int alt72=2;
				try { DebugEnterDecision(72, false);
				int LA72_1 = input.LA(1);

				if ((LA72_1==LT))
				{
					alt72 = 1;
				}


				} finally { DebugExitDecision(72); }
				switch ( alt72 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:10: LT
					{
					DebugLocation(181, 10);
					LT146=(IToken)Match(input,LT,Follow._LT_in_forInStatement1253); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT146);


					}
					break;

				default:
					goto loop72;
				}
			}

			loop72:
				;

			} finally { DebugExitSubRule(72); }

			DebugLocation(181, 14);
			char_literal147=(IToken)Match(input,48,Follow._48_in_forInStatement1256); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal147);

			DebugLocation(181, 18);
			// JavaScript.g:181:18: ( LT )*
			try { DebugEnterSubRule(73);
			while (true)
			{
				int alt73=2;
				try { DebugEnterDecision(73, false);
				int LA73_1 = input.LA(1);

				if ((LA73_1==LT))
				{
					alt73 = 1;
				}


				} finally { DebugExitDecision(73); }
				switch ( alt73 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:18: LT
					{
					DebugLocation(181, 18);
					LT148=(IToken)Match(input,LT,Follow._LT_in_forInStatement1258); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT148);


					}
					break;

				default:
					goto loop73;
				}
			}

			loop73:
				;

			} finally { DebugExitSubRule(73); }

			DebugLocation(181, 22);
			PushFollow(Follow._forInStatementInitialiserPart_in_forInStatement1261);
			forInStatementInitialiserPart149=forInStatementInitialiserPart();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_forInStatementInitialiserPart.Add(forInStatementInitialiserPart149.Tree);
			DebugLocation(181, 52);
			// JavaScript.g:181:52: ( LT )*
			try { DebugEnterSubRule(74);
			while (true)
			{
				int alt74=2;
				try { DebugEnterDecision(74, false);
				int LA74_1 = input.LA(1);

				if ((LA74_1==LT))
				{
					alt74 = 1;
				}


				} finally { DebugExitDecision(74); }
				switch ( alt74 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:52: LT
					{
					DebugLocation(181, 52);
					LT150=(IToken)Match(input,LT,Follow._LT_in_forInStatement1263); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT150);


					}
					break;

				default:
					goto loop74;
				}
			}

			loop74:
				;

			} finally { DebugExitSubRule(74); }

			DebugLocation(181, 56);
			string_literal151=(IToken)Match(input,95,Follow._95_in_forInStatement1266); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_95.Add(string_literal151);

			DebugLocation(181, 61);
			// JavaScript.g:181:61: ( LT )*
			try { DebugEnterSubRule(75);
			while (true)
			{
				int alt75=2;
				try { DebugEnterDecision(75, false);
				int LA75_1 = input.LA(1);

				if ((LA75_1==LT))
				{
					alt75 = 1;
				}


				} finally { DebugExitDecision(75); }
				switch ( alt75 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:61: LT
					{
					DebugLocation(181, 61);
					LT152=(IToken)Match(input,LT,Follow._LT_in_forInStatement1268); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT152);


					}
					break;

				default:
					goto loop75;
				}
			}

			loop75:
				;

			} finally { DebugExitSubRule(75); }

			DebugLocation(181, 65);
			PushFollow(Follow._expression_in_forInStatement1271);
			expression153=expression();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_expression.Add(expression153.Tree);
			DebugLocation(181, 76);
			// JavaScript.g:181:76: ( LT )*
			try { DebugEnterSubRule(76);
			while (true)
			{
				int alt76=2;
				try { DebugEnterDecision(76, false);
				int LA76_1 = input.LA(1);

				if ((LA76_1==LT))
				{
					alt76 = 1;
				}


				} finally { DebugExitDecision(76); }
				switch ( alt76 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:76: LT
					{
					DebugLocation(181, 76);
					LT154=(IToken)Match(input,LT,Follow._LT_in_forInStatement1273); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT154);


					}
					break;

				default:
					goto loop76;
				}
			}

			loop76:
				;

			} finally { DebugExitSubRule(76); }

			DebugLocation(181, 80);
			char_literal155=(IToken)Match(input,49,Follow._49_in_forInStatement1276); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal155);

			DebugLocation(181, 84);
			// JavaScript.g:181:84: ( LT )*
			try { DebugEnterSubRule(77);
			while (true)
			{
				int alt77=2;
				try { DebugEnterDecision(77, false);
				int LA77_1 = input.LA(1);

				if ((LA77_1==LT))
				{
					alt77 = 1;
				}


				} finally { DebugExitDecision(77); }
				switch ( alt77 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:181:84: LT
					{
					DebugLocation(181, 84);
					LT156=(IToken)Match(input,LT,Follow._LT_in_forInStatement1278); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT156);


					}
					break;

				default:
					goto loop77;
				}
			}

			loop77:
				;

			} finally { DebugExitSubRule(77); }

			DebugLocation(181, 88);
			PushFollow(Follow._statement_in_forInStatement1281);
			statement157=statement();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statement.Add(statement157.Tree);


			{
			// AST REWRITE
			// elements: 92, forInStatementInitialiserPart, expression, 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();
			// 182:3: -> ^( 'for' forInStatementInitialiserPart expression statement )
			{
				DebugLocation(182, 6);
				// JavaScript.g:182:6: ^( 'for' forInStatementInitialiserPart expression statement )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(182, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ForInStatement(stream_92.NextToken()), root_1);

				DebugLocation(183, 4);
				adaptor.AddChild(root_1, stream_forInStatementInitialiserPart.NextTree());
				DebugLocation(184, 4);
				adaptor.AddChild(root_1, stream_expression.NextTree());
				DebugLocation(185, 4);
				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("forInStatement", 26);
			LeaveRule("forInStatement", 26);
			LeaveRule_forInStatement();
			if (state.backtracking > 0) { Memoize(input, 26, forInStatement_StartIndex); }

		}
		DebugLocation(186, 1);
		} finally { DebugExitRule(GrammarFileName, "forInStatement"); }
		return retval;

	}
コード例 #27
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> catchClause()
	{
		EnterRule_catchClause();
		EnterRule("catchClause", 39);
		TraceIn("catchClause", 39);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int catchClause_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal230 = default(IToken);
		IToken LT231 = default(IToken);
		IToken char_literal232 = default(IToken);
		IToken LT233 = default(IToken);
		IToken Identifier234 = default(IToken);
		IToken LT235 = default(IToken);
		IToken char_literal236 = default(IToken);
		IToken LT237 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> statementBlock238 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal230_tree = default(CommonTree);
		CommonTree LT231_tree = default(CommonTree);
		CommonTree char_literal232_tree = default(CommonTree);
		CommonTree LT233_tree = default(CommonTree);
		CommonTree Identifier234_tree = default(CommonTree);
		CommonTree LT235_tree = default(CommonTree);
		CommonTree char_literal236_tree = default(CommonTree);
		CommonTree LT237_tree = default(CommonTree);
		RewriteRuleITokenStream stream_84=new RewriteRuleITokenStream(adaptor,"token 84");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_48=new RewriteRuleITokenStream(adaptor,"token 48");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_49=new RewriteRuleITokenStream(adaptor,"token 49");
		RewriteRuleSubtreeStream stream_statementBlock=new RewriteRuleSubtreeStream(adaptor,"rule statementBlock");
		try { DebugEnterRule(GrammarFileName, "catchClause");
		DebugLocation(242, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 39)) { return retval; }

			// JavaScript.g:243:2: ( 'catch' ( LT )* '(' ( LT )* Identifier ( LT )* ')' ( LT )* statementBlock -> ^( 'catch' Identifier statementBlock ) )
			DebugEnterAlt(1);
			// JavaScript.g:243:4: 'catch' ( LT )* '(' ( LT )* Identifier ( LT )* ')' ( LT )* statementBlock
			{
			DebugLocation(243, 4);
			string_literal230=(IToken)Match(input,84,Follow._84_in_catchClause1843); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_84.Add(string_literal230);

			DebugLocation(243, 12);
			// JavaScript.g:243:12: ( LT )*
			try { DebugEnterSubRule(116);
			while (true)
			{
				int alt116=2;
				try { DebugEnterDecision(116, false);
				int LA116_1 = input.LA(1);

				if ((LA116_1==LT))
				{
					alt116 = 1;
				}


				} finally { DebugExitDecision(116); }
				switch ( alt116 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:243:12: LT
					{
					DebugLocation(243, 12);
					LT231=(IToken)Match(input,LT,Follow._LT_in_catchClause1845); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT231);


					}
					break;

				default:
					goto loop116;
				}
			}

			loop116:
				;

			} finally { DebugExitSubRule(116); }

			DebugLocation(243, 16);
			char_literal232=(IToken)Match(input,48,Follow._48_in_catchClause1848); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_48.Add(char_literal232);

			DebugLocation(243, 20);
			// JavaScript.g:243:20: ( LT )*
			try { DebugEnterSubRule(117);
			while (true)
			{
				int alt117=2;
				try { DebugEnterDecision(117, false);
				int LA117_1 = input.LA(1);

				if ((LA117_1==LT))
				{
					alt117 = 1;
				}


				} finally { DebugExitDecision(117); }
				switch ( alt117 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:243:20: LT
					{
					DebugLocation(243, 20);
					LT233=(IToken)Match(input,LT,Follow._LT_in_catchClause1850); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT233);


					}
					break;

				default:
					goto loop117;
				}
			}

			loop117:
				;

			} finally { DebugExitSubRule(117); }

			DebugLocation(243, 24);
			Identifier234=(IToken)Match(input,Identifier,Follow._Identifier_in_catchClause1853); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_Identifier.Add(Identifier234);

			DebugLocation(243, 35);
			// JavaScript.g:243:35: ( LT )*
			try { DebugEnterSubRule(118);
			while (true)
			{
				int alt118=2;
				try { DebugEnterDecision(118, false);
				int LA118_1 = input.LA(1);

				if ((LA118_1==LT))
				{
					alt118 = 1;
				}


				} finally { DebugExitDecision(118); }
				switch ( alt118 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:243:35: LT
					{
					DebugLocation(243, 35);
					LT235=(IToken)Match(input,LT,Follow._LT_in_catchClause1855); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT235);


					}
					break;

				default:
					goto loop118;
				}
			}

			loop118:
				;

			} finally { DebugExitSubRule(118); }

			DebugLocation(243, 39);
			char_literal236=(IToken)Match(input,49,Follow._49_in_catchClause1858); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_49.Add(char_literal236);

			DebugLocation(243, 43);
			// JavaScript.g:243:43: ( LT )*
			try { DebugEnterSubRule(119);
			while (true)
			{
				int alt119=2;
				try { DebugEnterDecision(119, false);
				int LA119_1 = input.LA(1);

				if ((LA119_1==LT))
				{
					alt119 = 1;
				}


				} finally { DebugExitDecision(119); }
				switch ( alt119 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:243:43: LT
					{
					DebugLocation(243, 43);
					LT237=(IToken)Match(input,LT,Follow._LT_in_catchClause1860); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT237);


					}
					break;

				default:
					goto loop119;
				}
			}

			loop119:
				;

			} finally { DebugExitSubRule(119); }

			DebugLocation(243, 47);
			PushFollow(Follow._statementBlock_in_catchClause1863);
			statementBlock238=statementBlock();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_statementBlock.Add(statementBlock238.Tree);


			{
			// AST REWRITE
			// elements: 84, Identifier, statementBlock
			// 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();
			// 244:3: -> ^( 'catch' Identifier statementBlock )
			{
				DebugLocation(244, 6);
				// JavaScript.g:244:6: ^( 'catch' Identifier statementBlock )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(244, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new CatchClause(stream_84.NextToken()), root_1);

				DebugLocation(244, 34);
				adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));
				DebugLocation(244, 62);
				adaptor.AddChild(root_1, stream_statementBlock.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("catchClause", 39);
			LeaveRule("catchClause", 39);
			LeaveRule_catchClause();
			if (state.backtracking > 0) { Memoize(input, 39, catchClause_StartIndex); }

		}
		DebugLocation(245, 1);
		} finally { DebugExitRule(GrammarFileName, "catchClause"); }
		return retval;

	}
コード例 #28
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> continueStatement()
	{
		EnterRule_continueStatement();
		EnterRule("continueStatement", 28);
		TraceIn("continueStatement", 28);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int continueStatement_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken string_literal162 = default(IToken);
		IToken Identifier163 = default(IToken);
		IToken LT164 = default(IToken);
		IToken char_literal165 = default(IToken);

		CommonTree string_literal162_tree = default(CommonTree);
		CommonTree Identifier163_tree = default(CommonTree);
		CommonTree LT164_tree = default(CommonTree);
		CommonTree char_literal165_tree = default(CommonTree);
		RewriteRuleITokenStream stream_85=new RewriteRuleITokenStream(adaptor,"token 85");
		RewriteRuleITokenStream stream_Identifier=new RewriteRuleITokenStream(adaptor,"token Identifier");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_63=new RewriteRuleITokenStream(adaptor,"token 63");
		try { DebugEnterRule(GrammarFileName, "continueStatement");
		DebugLocation(193, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 28)) { return retval; }

			// JavaScript.g:194:2: ( 'continue' ( Identifier )? ( LT | ';' ) -> ^( 'continue' ( Identifier )? ) )
			DebugEnterAlt(1);
			// JavaScript.g:194:4: 'continue' ( Identifier )? ( LT | ';' )
			{
			DebugLocation(194, 4);
			string_literal162=(IToken)Match(input,85,Follow._85_in_continueStatement1348); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_85.Add(string_literal162);

			DebugLocation(194, 15);
			// JavaScript.g:194:15: ( Identifier )?
			int alt80=2;
			try { DebugEnterSubRule(80);
			try { DebugEnterDecision(80, false);
			int LA80_1 = input.LA(1);

			if ((LA80_1==Identifier))
			{
				alt80 = 1;
			}
			} finally { DebugExitDecision(80); }
			switch (alt80)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:194:15: Identifier
				{
				DebugLocation(194, 15);
				Identifier163=(IToken)Match(input,Identifier,Follow._Identifier_in_continueStatement1350); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_Identifier.Add(Identifier163);


				}
				break;

			}
			} finally { DebugExitSubRule(80); }

			DebugLocation(194, 27);
			// JavaScript.g:194:27: ( LT | ';' )
			int alt81=2;
			try { DebugEnterSubRule(81);
			try { DebugEnterDecision(81, false);
			int LA81_1 = input.LA(1);

			if ((LA81_1==LT))
			{
				alt81 = 1;
			}
			else if ((LA81_1==63))
			{
				alt81 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 81, 0, input, 1);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(81); }
			switch (alt81)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:194:28: LT
				{
				DebugLocation(194, 28);
				LT164=(IToken)Match(input,LT,Follow._LT_in_continueStatement1354); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_LT.Add(LT164);


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// JavaScript.g:194:33: ';'
				{
				DebugLocation(194, 33);
				char_literal165=(IToken)Match(input,63,Follow._63_in_continueStatement1358); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_63.Add(char_literal165);


				}
				break;

			}
			} finally { DebugExitSubRule(81); }



			{
			// AST REWRITE
			// elements: 85, Identifier
			// 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();
			// 195:3: -> ^( 'continue' ( Identifier )? )
			{
				DebugLocation(195, 6);
				// JavaScript.g:195:6: ^( 'continue' ( Identifier )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(195, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ContinueStatement(stream_85.NextToken()), root_1);

				DebugLocation(195, 43);
				// JavaScript.g:195:43: ( Identifier )?
				if (stream_Identifier.HasNext)
				{
					DebugLocation(195, 43);
					adaptor.AddChild(root_1, new Identifier(stream_Identifier.NextToken()));

				}
				stream_Identifier.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("continueStatement", 28);
			LeaveRule("continueStatement", 28);
			LeaveRule_continueStatement();
			if (state.backtracking > 0) { Memoize(input, 28, continueStatement_StartIndex); }

		}
		DebugLocation(196, 1);
		} finally { DebugExitRule(GrammarFileName, "continueStatement"); }
		return retval;

	}
コード例 #29
0
		public void CheckRRTokenStreamBehaviourWithElements() {
			RewriteRuleTokenStream tokenTest = new RewriteRuleTokenStream(CreateTreeAdaptor(),
				"RewriteRuleTokenStream test");

			IToken token1 = CreateToken(1, "test token without any real context");

			// Test Add()
			tokenTest.Add(token1);
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (1).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (1).");

			// Test NextNode()
			CommonTree tree = (CommonTree) tokenTest.NextNode();
			Assert.AreEqual(token1, tree.Token,
				"The returned token should be equal to the given token (1).");
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (2).");
			Assert.IsFalse(tokenTest.HasNext(), "HasNext() should be false here (1).");
			tokenTest.Reset();
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (3).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (2).");

			// Test NextToken()
			IToken returnedToken = tokenTest.NextToken();
			Assert.AreEqual(token1, returnedToken,
				"The returned token should be equal to the given token (2).");
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (4).");
			Assert.IsFalse(tokenTest.HasNext(), "HasNext() should be false here (2).");
			tokenTest.Reset();
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (5).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (3).");

			// Test NextTree()
			returnedToken = (IToken) tokenTest.NextTree();
			Assert.AreEqual(token1, returnedToken,
				"The returned token should be equal to the given token (3).");
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (6).");
			Assert.IsFalse(tokenTest.HasNext(), "HasNext() should be false here (2).");
			tokenTest.Reset();
			Assert.AreEqual(1, tokenTest.Size(), "tokenTest should have the size 1 (7).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (3).");

			// Test, what happens with two elements
			IToken token2 = CreateToken(2, "test token without any real context");

			tokenTest.Add(token2);
			Assert.AreEqual(2, tokenTest.Size(), "tokenTest should have the size 2 (1).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (4).");
			returnedToken = tokenTest.NextToken();
			Assert.AreEqual(token1, returnedToken,
				"The returned token should be equal to the given token (4).");
			Assert.AreEqual(2, tokenTest.Size(), "tokenTest should have the size 2 (2).");
			Assert.IsTrue(tokenTest.HasNext(), "HasNext() should be true here (5).");
			returnedToken = tokenTest.NextToken();
			Assert.AreEqual(token2, returnedToken,
				"The returned token should be equal to the given token (5).");
			Assert.IsFalse(tokenTest.HasNext(), "HasNext() should be false here (3).");

			// Test exception
			tokenTest.NextToken();
		}
コード例 #30
0
ファイル: JavaScriptParser.cs プロジェクト: apoco/jacobsoft
	private AstParserRuleReturnScope<CommonTree, IToken> arrayLiteral()
	{
		EnterRule_arrayLiteral();
		EnterRule("arrayLiteral", 77);
		TraceIn("arrayLiteral", 77);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);
		int arrayLiteral_StartIndex = input.Index;

		CommonTree root_0 = default(CommonTree);

		IToken char_literal399 = default(IToken);
		IToken LT400 = default(IToken);
		IToken LT402 = default(IToken);
		IToken char_literal403 = default(IToken);
		IToken LT404 = default(IToken);
		IToken LT406 = default(IToken);
		IToken char_literal407 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> assignmentExpression401 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> assignmentExpression405 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal399_tree = default(CommonTree);
		CommonTree LT400_tree = default(CommonTree);
		CommonTree LT402_tree = default(CommonTree);
		CommonTree char_literal403_tree = default(CommonTree);
		CommonTree LT404_tree = default(CommonTree);
		CommonTree LT406_tree = default(CommonTree);
		CommonTree char_literal407_tree = default(CommonTree);
		RewriteRuleITokenStream stream_78=new RewriteRuleITokenStream(adaptor,"token 78");
		RewriteRuleITokenStream stream_LT=new RewriteRuleITokenStream(adaptor,"token LT");
		RewriteRuleITokenStream stream_55=new RewriteRuleITokenStream(adaptor,"token 55");
		RewriteRuleITokenStream stream_79=new RewriteRuleITokenStream(adaptor,"token 79");
		RewriteRuleSubtreeStream stream_assignmentExpression=new RewriteRuleSubtreeStream(adaptor,"rule assignmentExpression");
		try { DebugEnterRule(GrammarFileName, "arrayLiteral");
		DebugLocation(618, 1);
		try
		{
			if (state.backtracking > 0 && AlreadyParsedRule(input, 77)) { return retval; }

			// JavaScript.g:619:2: ( '[' ( LT )* ( assignmentExpression )? ( ( LT )* ',' ( ( LT )* assignmentExpression )? )* ( LT )* ']' -> ^( '[' ( assignmentExpression )* ) )
			DebugEnterAlt(1);
			// JavaScript.g:619:4: '[' ( LT )* ( assignmentExpression )? ( ( LT )* ',' ( ( LT )* assignmentExpression )? )* ( LT )* ']'
			{
			DebugLocation(619, 4);
			char_literal399=(IToken)Match(input,78,Follow._78_in_arrayLiteral6252); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_78.Add(char_literal399);

			DebugLocation(619, 8);
			// JavaScript.g:619:8: ( LT )*
			try { DebugEnterSubRule(229);
			while (true)
			{
				int alt229=2;
				try { DebugEnterDecision(229, false);
				int LA229_1 = input.LA(1);

				if ((LA229_1==LT))
				{
					int LA229_2 = input.LA(2);

					if ((EvaluatePredicate(synpred281_JavaScript_fragment)))
					{
						alt229 = 1;
					}


				}


				} finally { DebugExitDecision(229); }
				switch ( alt229 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:619:8: LT
					{
					DebugLocation(619, 8);
					LT400=(IToken)Match(input,LT,Follow._LT_in_arrayLiteral6254); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT400);


					}
					break;

				default:
					goto loop229;
				}
			}

			loop229:
				;

			} finally { DebugExitSubRule(229); }

			DebugLocation(619, 12);
			// JavaScript.g:619:12: ( assignmentExpression )?
			int alt230=2;
			try { DebugEnterSubRule(230);
			try { DebugEnterDecision(230, false);
			int LA230_1 = input.LA(1);

			if ((LA230_1==Identifier||LA230_1==NumericLiteral||LA230_1==StringLiteral||LA230_1==40||LA230_1==48||(LA230_1>=52 && LA230_1<=53)||(LA230_1>=56 && LA230_1<=57)||LA230_1==78||LA230_1==87||LA230_1==90||LA230_1==93||(LA230_1>=97 && LA230_1<=98)||LA230_1==101||LA230_1==103||LA230_1==105||LA230_1==107||LA230_1==110||LA230_1==115))
			{
				alt230 = 1;
			}
			} finally { DebugExitDecision(230); }
			switch (alt230)
			{
			case 1:
				DebugEnterAlt(1);
				// JavaScript.g:619:12: assignmentExpression
				{
				DebugLocation(619, 12);
				PushFollow(Follow._assignmentExpression_in_arrayLiteral6257);
				assignmentExpression401=assignmentExpression();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_assignmentExpression.Add(assignmentExpression401.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(230); }

			DebugLocation(619, 34);
			// JavaScript.g:619:34: ( ( LT )* ',' ( ( LT )* assignmentExpression )? )*
			try { DebugEnterSubRule(234);
			while (true)
			{
				int alt234=2;
				try { DebugEnterDecision(234, false);
				try
				{
					alt234 = dfa234.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(234); }
				switch ( alt234 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:619:35: ( LT )* ',' ( ( LT )* assignmentExpression )?
					{
					DebugLocation(619, 35);
					// JavaScript.g:619:35: ( LT )*
					try { DebugEnterSubRule(231);
					while (true)
					{
						int alt231=2;
						try { DebugEnterDecision(231, false);
						int LA231_1 = input.LA(1);

						if ((LA231_1==LT))
						{
							alt231 = 1;
						}


						} finally { DebugExitDecision(231); }
						switch ( alt231 )
						{
						case 1:
							DebugEnterAlt(1);
							// JavaScript.g:619:35: LT
							{
							DebugLocation(619, 35);
							LT402=(IToken)Match(input,LT,Follow._LT_in_arrayLiteral6261); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_LT.Add(LT402);


							}
							break;

						default:
							goto loop231;
						}
					}

					loop231:
						;

					} finally { DebugExitSubRule(231); }

					DebugLocation(619, 39);
					char_literal403=(IToken)Match(input,55,Follow._55_in_arrayLiteral6264); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_55.Add(char_literal403);

					DebugLocation(619, 43);
					// JavaScript.g:619:43: ( ( LT )* assignmentExpression )?
					int alt233=2;
					try { DebugEnterSubRule(233);
					try { DebugEnterDecision(233, false);
					try
					{
						alt233 = dfa233.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(233); }
					switch (alt233)
					{
					case 1:
						DebugEnterAlt(1);
						// JavaScript.g:619:44: ( LT )* assignmentExpression
						{
						DebugLocation(619, 44);
						// JavaScript.g:619:44: ( LT )*
						try { DebugEnterSubRule(232);
						while (true)
						{
							int alt232=2;
							try { DebugEnterDecision(232, false);
							int LA232_1 = input.LA(1);

							if ((LA232_1==LT))
							{
								alt232 = 1;
							}


							} finally { DebugExitDecision(232); }
							switch ( alt232 )
							{
							case 1:
								DebugEnterAlt(1);
								// JavaScript.g:619:44: LT
								{
								DebugLocation(619, 44);
								LT404=(IToken)Match(input,LT,Follow._LT_in_arrayLiteral6267); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_LT.Add(LT404);


								}
								break;

							default:
								goto loop232;
							}
						}

						loop232:
							;

						} finally { DebugExitSubRule(232); }

						DebugLocation(619, 48);
						PushFollow(Follow._assignmentExpression_in_arrayLiteral6270);
						assignmentExpression405=assignmentExpression();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_assignmentExpression.Add(assignmentExpression405.Tree);

						}
						break;

					}
					} finally { DebugExitSubRule(233); }


					}
					break;

				default:
					goto loop234;
				}
			}

			loop234:
				;

			} finally { DebugExitSubRule(234); }

			DebugLocation(619, 73);
			// JavaScript.g:619:73: ( LT )*
			try { DebugEnterSubRule(235);
			while (true)
			{
				int alt235=2;
				try { DebugEnterDecision(235, false);
				int LA235_1 = input.LA(1);

				if ((LA235_1==LT))
				{
					alt235 = 1;
				}


				} finally { DebugExitDecision(235); }
				switch ( alt235 )
				{
				case 1:
					DebugEnterAlt(1);
					// JavaScript.g:619:73: LT
					{
					DebugLocation(619, 73);
					LT406=(IToken)Match(input,LT,Follow._LT_in_arrayLiteral6276); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_LT.Add(LT406);


					}
					break;

				default:
					goto loop235;
				}
			}

			loop235:
				;

			} finally { DebugExitSubRule(235); }

			DebugLocation(619, 77);
			char_literal407=(IToken)Match(input,79,Follow._79_in_arrayLiteral6279); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_79.Add(char_literal407);



			{
			// AST REWRITE
			// elements: 78, assignmentExpression
			// 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();
			// 620:3: -> ^( '[' ( assignmentExpression )* )
			{
				DebugLocation(620, 6);
				// JavaScript.g:620:6: ^( '[' ( assignmentExpression )* )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(620, 8);
				root_1 = (CommonTree)adaptor.BecomeRoot(new ArrayLiteral(stream_78.NextToken()), root_1);

				DebugLocation(620, 31);
				// JavaScript.g:620:31: ( assignmentExpression )*
				while ( stream_assignmentExpression.HasNext )
				{
					DebugLocation(620, 31);
					adaptor.AddChild(root_1, stream_assignmentExpression.NextTree());

				}
				stream_assignmentExpression.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("arrayLiteral", 77);
			LeaveRule("arrayLiteral", 77);
			LeaveRule_arrayLiteral();
			if (state.backtracking > 0) { Memoize(input, 77, arrayLiteral_StartIndex); }

		}
		DebugLocation(621, 1);
		} finally { DebugExitRule(GrammarFileName, "arrayLiteral"); }
		return retval;

	}