Пример #1
0
	private AstParserRuleReturnScope<CommonTree, IToken> lvalue()
	{
		EnterRule_lvalue();
		EnterRule("lvalue", 101);
		TraceIn("lvalue", 101);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken char_literal958 = default(IToken);
		IToken WS959 = default(IToken);
		IToken WS961 = default(IToken);
		IToken char_literal962 = default(IToken);
		IToken WS963 = default(IToken);
		IToken WS965 = default(IToken);
		IToken char_literal966 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> lvalue_item960 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> lvalue_item964 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> lvalue_item967 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal958_tree = default(CommonTree);
		CommonTree WS959_tree = default(CommonTree);
		CommonTree WS961_tree = default(CommonTree);
		CommonTree char_literal962_tree = default(CommonTree);
		CommonTree WS963_tree = default(CommonTree);
		CommonTree WS965_tree = default(CommonTree);
		CommonTree char_literal966_tree = default(CommonTree);
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_lvalue_item=new RewriteRuleSubtreeStream(adaptor,"rule lvalue_item");
		try { DebugEnterRule(GrammarFileName, "lvalue");
		DebugLocation(759, 1);
		try
		{
			// SugarCpp.g:760:2: ( '(' ( WS )* lvalue_item ( ( WS )* ',' ( WS )* lvalue_item )+ ( WS )* ')' -> ^( Match_Tuple ( lvalue_item )* ) | lvalue_item )
			int alt624=2;
			try { DebugEnterDecision(624, false);
			int LA624_0 = input.LA(1);

			if ((LA624_0==93))
			{
				alt624 = 1;
			}
			else if ((LA624_0==IDENT||LA624_0==86||LA624_0==91||LA624_0==95||(LA624_0>=97 && LA624_0<=98)||(LA624_0>=101 && LA624_0<=102)||LA624_0==131||LA624_0==161||LA624_0==186))
			{
				alt624 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 624, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(624); }
			switch (alt624)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:760:4: '(' ( WS )* lvalue_item ( ( WS )* ',' ( WS )* lvalue_item )+ ( WS )* ')'
				{
				DebugLocation(760, 4);
				char_literal958=(IToken)Match(input,93,Follow._93_in_lvalue9181); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_93.Add(char_literal958);

				DebugLocation(760, 8);
				// SugarCpp.g:760:8: ( WS )*
				try { DebugEnterSubRule(619);
				while (true)
				{
					int alt619=2;
					try { DebugEnterDecision(619, false);
					int LA619_0 = input.LA(1);

					if ((LA619_0==WS))
					{
						alt619 = 1;
					}


					} finally { DebugExitDecision(619); }
					switch ( alt619 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:760:8: WS
						{
						DebugLocation(760, 8);
						WS959=(IToken)Match(input,WS,Follow._WS_in_lvalue9183); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS959);


						}
						break;

					default:
						goto loop619;
					}
				}

				loop619:
					;

				} finally { DebugExitSubRule(619); }

				DebugLocation(760, 12);
				PushFollow(Follow._lvalue_item_in_lvalue9186);
				lvalue_item960=lvalue_item();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_lvalue_item.Add(lvalue_item960.Tree);
				DebugLocation(760, 24);
				// SugarCpp.g:760:24: ( ( WS )* ',' ( WS )* lvalue_item )+
				int cnt622=0;
				try { DebugEnterSubRule(622);
				while (true)
				{
					int alt622=2;
					try { DebugEnterDecision(622, false);
					try
					{
						alt622 = dfa622.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(622); }
					switch (alt622)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:760:25: ( WS )* ',' ( WS )* lvalue_item
						{
						DebugLocation(760, 25);
						// SugarCpp.g:760:25: ( WS )*
						try { DebugEnterSubRule(620);
						while (true)
						{
							int alt620=2;
							try { DebugEnterDecision(620, false);
							int LA620_0 = input.LA(1);

							if ((LA620_0==WS))
							{
								alt620 = 1;
							}


							} finally { DebugExitDecision(620); }
							switch ( alt620 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:760:25: WS
								{
								DebugLocation(760, 25);
								WS961=(IToken)Match(input,WS,Follow._WS_in_lvalue9189); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS961);


								}
								break;

							default:
								goto loop620;
							}
						}

						loop620:
							;

						} finally { DebugExitSubRule(620); }

						DebugLocation(760, 29);
						char_literal962=(IToken)Match(input,100,Follow._100_in_lvalue9192); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_100.Add(char_literal962);

						DebugLocation(760, 33);
						// SugarCpp.g:760:33: ( WS )*
						try { DebugEnterSubRule(621);
						while (true)
						{
							int alt621=2;
							try { DebugEnterDecision(621, false);
							int LA621_0 = input.LA(1);

							if ((LA621_0==WS))
							{
								alt621 = 1;
							}


							} finally { DebugExitDecision(621); }
							switch ( alt621 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:760:33: WS
								{
								DebugLocation(760, 33);
								WS963=(IToken)Match(input,WS,Follow._WS_in_lvalue9194); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS963);


								}
								break;

							default:
								goto loop621;
							}
						}

						loop621:
							;

						} finally { DebugExitSubRule(621); }

						DebugLocation(760, 37);
						PushFollow(Follow._lvalue_item_in_lvalue9197);
						lvalue_item964=lvalue_item();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_lvalue_item.Add(lvalue_item964.Tree);

						}
						break;

					default:
						if (cnt622 >= 1)
							goto loop622;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee622 = new EarlyExitException( 622, input );
						DebugRecognitionException(eee622);
						throw eee622;
					}
					cnt622++;
				}
				loop622:
					;

				} finally { DebugExitSubRule(622); }

				DebugLocation(760, 51);
				// SugarCpp.g:760:51: ( WS )*
				try { DebugEnterSubRule(623);
				while (true)
				{
					int alt623=2;
					try { DebugEnterDecision(623, false);
					int LA623_0 = input.LA(1);

					if ((LA623_0==WS))
					{
						alt623 = 1;
					}


					} finally { DebugExitDecision(623); }
					switch ( alt623 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:760:51: WS
						{
						DebugLocation(760, 51);
						WS965=(IToken)Match(input,WS,Follow._WS_in_lvalue9201); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS965);


						}
						break;

					default:
						goto loop623;
					}
				}

				loop623:
					;

				} finally { DebugExitSubRule(623); }

				DebugLocation(760, 55);
				char_literal966=(IToken)Match(input,94,Follow._94_in_lvalue9204); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_94.Add(char_literal966);



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

				root_0 = (CommonTree)adaptor.Nil();
				// 760:59: -> ^( Match_Tuple ( lvalue_item )* )
				{
					DebugLocation(760, 62);
					// SugarCpp.g:760:62: ^( Match_Tuple ( lvalue_item )* )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(760, 64);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Match_Tuple, "Match_Tuple"), root_1);

					DebugLocation(760, 76);
					// SugarCpp.g:760:76: ( lvalue_item )*
					while ( stream_lvalue_item.HasNext )
					{
						DebugLocation(760, 76);
						adaptor.AddChild(root_1, stream_lvalue_item.NextTree());

					}
					stream_lvalue_item.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:761:4: lvalue_item
				{
				root_0 = (CommonTree)adaptor.Nil();

				DebugLocation(761, 4);
				PushFollow(Follow._lvalue_item_in_lvalue9218);
				lvalue_item967=lvalue_item();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) adaptor.AddChild(root_0, lvalue_item967.Tree);

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (CommonTree)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("lvalue", 101);
			LeaveRule("lvalue", 101);
			LeaveRule_lvalue();
		}
		DebugLocation(762, 1);
		} finally { DebugExitRule(GrammarFileName, "lvalue"); }
		return retval;

	}
		// $ANTLR start "functionCall"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:255:1: functionCall : x= ID '(' ( expression ( ',' expression )* )? ')' -> ^( FUNCTION[$x] ( expression )* ) ;
		public functionCall_return functionCall() // throws RecognitionException [1]
		{
			var retval = new functionCall_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken x = null;
			IToken char_literal87 = null;
			IToken char_literal89 = null;
			IToken char_literal91 = null;
			expression_return expression88 = default( expression_return );

			expression_return expression90 = default( expression_return );


			CommonTree x_tree = null;
			CommonTree char_literal87_tree = null;
			CommonTree char_literal89_tree = null;
			CommonTree char_literal91_tree = null;
			var stream_69 = new RewriteRuleTokenStream( adaptor, "token 69" );
			var stream_94 = new RewriteRuleTokenStream( adaptor, "token 94" );
			var stream_ID = new RewriteRuleTokenStream( adaptor, "token ID" );
			var stream_70 = new RewriteRuleTokenStream( adaptor, "token 70" );
			var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:2: (x= ID '(' ( expression ( ',' expression )* )? ')' -> ^( FUNCTION[$x] ( expression )* ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:4: x= ID '(' ( expression ( ',' expression )* )? ')'
				{
					x = (IToken)Match( input, ID, FOLLOW_ID_in_functionCall1352 );
					stream_ID.Add( x );

					char_literal87 = (IToken)Match( input, 69, FOLLOW_69_in_functionCall1354 );
					stream_69.Add( char_literal87 );

					// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:13: ( expression ( ',' expression )* )?
					int alt33 = 2;
					int LA33_0 = input.LA( 1 );

					if ( ( ( LA33_0 >= ID && LA33_0 <= FLOAT ) || LA33_0 == 69 || ( LA33_0 >= 71 && LA33_0 <= 72 ) || LA33_0 == 87 || LA33_0 == 91 || ( LA33_0 >= 95 && LA33_0 <= 96 ) ) )
						alt33 = 1;
					switch ( alt33 )
					{
						case 1:
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:15: expression ( ',' expression )*
							{
								PushFollow( FOLLOW_expression_in_functionCall1358 );
								expression88 = expression();
								state.followingStackPointer--;

								stream_expression.Add( expression88.Tree );
								// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:26: ( ',' expression )*
								do
								{
									int alt32 = 2;
									int LA32_0 = input.LA( 1 );

									if ( ( LA32_0 == 94 ) )
										alt32 = 1;


									switch ( alt32 )
									{
										case 1:
											// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:28: ',' expression
											{
												char_literal89 = (IToken)Match( input, 94, FOLLOW_94_in_functionCall1362 );
												stream_94.Add( char_literal89 );

												PushFollow( FOLLOW_expression_in_functionCall1364 );
												expression90 = expression();
												state.followingStackPointer--;

												stream_expression.Add( expression90.Tree );
											}
											break;

										default:
											goto loop32;
									}
								} while ( true );

								loop32:
								; // Stops C# compiler whining that label 'loop32' has no statements
							}
							break;
					}

					char_literal91 = (IToken)Match( input, 70, FOLLOW_70_in_functionCall1372 );
					stream_70.Add( char_literal91 );


					// AST REWRITE
					// elements:          expression
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 256:53: -> ^( FUNCTION[$x] ( expression )* )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:56: ^( FUNCTION[$x] ( expression )* )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( FUNCTION, x ), root_1 );

							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:72: ( expression )*
							while ( stream_expression.HasNext() )
								adaptor.AddChild( root_1, stream_expression.NextTree() );
							stream_expression.Reset();

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
		// $ANTLR start "classStatementBlock"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:85:1: classStatementBlock : '{' ( classLevelStatement )* '}' -> ^( STATEMENT_BLOCK ( classLevelStatement )* ) ;
		public classStatementBlock_return classStatementBlock() // throws RecognitionException [1]
		{
			var retval = new classStatementBlock_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken char_literal12 = null;
			IToken char_literal14 = null;
			classLevelStatement_return classLevelStatement13 = default( classLevelStatement_return );


			CommonTree char_literal12_tree = null;
			CommonTree char_literal14_tree = null;
			var stream_60 = new RewriteRuleTokenStream( adaptor, "token 60" );
			var stream_61 = new RewriteRuleTokenStream( adaptor, "token 61" );
			var stream_classLevelStatement = new RewriteRuleSubtreeStream( adaptor, "rule classLevelStatement" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:2: ( '{' ( classLevelStatement )* '}' -> ^( STATEMENT_BLOCK ( classLevelStatement )* ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:4: '{' ( classLevelStatement )* '}'
				{
					char_literal12 = (IToken)Match( input, 60, FOLLOW_60_in_classStatementBlock328 );
					stream_60.Add( char_literal12 );

					// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:8: ( classLevelStatement )*
					do
					{
						int alt4 = 2;
						int LA4_0 = input.LA( 1 );

						if ( ( LA4_0 == 62 || LA4_0 == 67 ) )
							alt4 = 1;


						switch ( alt4 )
						{
							case 1:
								// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:8: classLevelStatement
								{
									PushFollow( FOLLOW_classLevelStatement_in_classStatementBlock330 );
									classLevelStatement13 = classLevelStatement();
									state.followingStackPointer--;

									stream_classLevelStatement.Add( classLevelStatement13.Tree );
								}
								break;

							default:
								goto loop4;
						}
					} while ( true );

					loop4:
					; // Stops C# compiler whining that label 'loop4' has no statements

					char_literal14 = (IToken)Match( input, 61, FOLLOW_61_in_classStatementBlock333 );
					stream_61.Add( char_literal14 );


					// AST REWRITE
					// elements:          classLevelStatement
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 86:33: -> ^( STATEMENT_BLOCK ( classLevelStatement )* )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:36: ^( STATEMENT_BLOCK ( classLevelStatement )* )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( STATEMENT_BLOCK, "STATEMENT_BLOCK" ), root_1 );

							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:86:55: ( classLevelStatement )*
							while ( stream_classLevelStatement.HasNext() )
								adaptor.AddChild( root_1, stream_classLevelStatement.NextTree() );
							stream_classLevelStatement.Reset();

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
		// $ANTLR start "relationshipJoinDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:116:1: relationshipJoinDeclaration : name 'where' expression -> ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) ) ;
		public relationshipJoinDeclaration_return relationshipJoinDeclaration() // throws RecognitionException [1]
		{
			var retval = new relationshipJoinDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken string_literal31 = null;
			name_return name30 = default( name_return );

			expression_return expression32 = default( expression_return );


			CommonTree string_literal31_tree = null;
			var stream_59 = new RewriteRuleTokenStream( adaptor, "token 59" );
			var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
			var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:2: ( name 'where' expression -> ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:4: name 'where' expression
				{
					PushFollow( FOLLOW_name_in_relationshipJoinDeclaration514 );
					name30 = name();
					state.followingStackPointer--;

					stream_name.Add( name30.Tree );
					string_literal31 = (IToken)Match( input, 59, FOLLOW_59_in_relationshipJoinDeclaration516 );
					stream_59.Add( string_literal31 );

					PushFollow( FOLLOW_expression_in_relationshipJoinDeclaration518 );
					expression32 = expression();
					state.followingStackPointer--;

					stream_expression.Add( expression32.Tree );


					// AST REWRITE
					// elements:          name, expression
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 117:28: -> ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:31: ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( JOIN, "JOIN" ), root_1 );

							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:39: ^( TARGET name )
							{
								var root_2 = (CommonTree)adaptor.GetNilNode();
								root_2 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( TARGET, "TARGET" ), root_2 );

								adaptor.AddChild( root_2, stream_name.NextTree() );

								adaptor.AddChild( root_1, root_2 );
							}
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:56: ^( CRITERIA expression )
							{
								var root_2 = (CommonTree)adaptor.GetNilNode();
								root_2 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CRITERIA, "CRITERIA" ), root_2 );

								adaptor.AddChild( root_2, stream_expression.NextTree() );

								adaptor.AddChild( root_1, root_2 );
							}

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
		// $ANTLR start "classDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:79:1: classDeclaration : 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) ;
		public classDeclaration_return classDeclaration() // throws RecognitionException [1]
		{
			var retval = new classDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken string_literal4 = null;
			name_return name5 = default( name_return );

			baseClassDeclaration_return baseClassDeclaration6 = default( baseClassDeclaration_return );

			classStatementBlock_return classStatementBlock7 = default( classStatementBlock_return );


			CommonTree string_literal4_tree = null;
			var stream_57 = new RewriteRuleTokenStream( adaptor, "token 57" );
			var stream_classStatementBlock = new RewriteRuleSubtreeStream( adaptor, "rule classStatementBlock" );
			var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
			var stream_baseClassDeclaration = new RewriteRuleSubtreeStream( adaptor, "rule baseClassDeclaration" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:2: ( 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:4: 'class' name ( baseClassDeclaration )? classStatementBlock
				{
					string_literal4 = (IToken)Match( input, 57, FOLLOW_57_in_classDeclaration262 );
					stream_57.Add( string_literal4 );

					PushFollow( FOLLOW_name_in_classDeclaration264 );
					name5 = name();
					state.followingStackPointer--;

					stream_name.Add( name5.Tree );
					// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: ( baseClassDeclaration )?
					int alt3 = 2;
					int LA3_0 = input.LA( 1 );

					if ( ( LA3_0 == 58 ) )
						alt3 = 1;
					switch ( alt3 )
					{
						case 1:
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: baseClassDeclaration
							{
								PushFollow( FOLLOW_baseClassDeclaration_in_classDeclaration266 );
								baseClassDeclaration6 = baseClassDeclaration();
								state.followingStackPointer--;

								stream_baseClassDeclaration.Add( baseClassDeclaration6.Tree );
							}
							break;
					}

					PushFollow( FOLLOW_classStatementBlock_in_classDeclaration269 );
					classStatementBlock7 = classStatementBlock();
					state.followingStackPointer--;

					stream_classStatementBlock.Add( classStatementBlock7.Tree );


					// AST REWRITE
					// elements:          name, classStatementBlock, baseClassDeclaration
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 80:59: -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:62: ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CLASS, "CLASS" ), root_1 );

							adaptor.AddChild( root_1, stream_name.NextTree() );
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:76: ( baseClassDeclaration )?
							if ( stream_baseClassDeclaration.HasNext() )
								adaptor.AddChild( root_1, stream_baseClassDeclaration.NextTree() );
							stream_baseClassDeclaration.Reset();
							adaptor.AddChild( root_1, stream_classStatementBlock.NextTree() );

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #6
0
	private AstParserRuleReturnScope<object, IToken> or_expression()
	{
		EnterRule_or_expression();
		EnterRule("or_expression", 5);
		TraceIn("or_expression", 5);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken string_literal11 = default(IToken);
		IToken string_literal12 = default(IToken);
		AstParserRuleReturnScope<object, IToken> and_expression10 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> and_expression13 = default(AstParserRuleReturnScope<object, IToken>);

		object string_literal11_tree = default(object);
		object string_literal12_tree = default(object);
		RewriteRuleITokenStream stream_75=new RewriteRuleITokenStream(adaptor,"token 75");
		RewriteRuleITokenStream stream_77=new RewriteRuleITokenStream(adaptor,"token 77");
		RewriteRuleSubtreeStream stream_and_expression=new RewriteRuleSubtreeStream(adaptor,"rule and_expression");
		try { DebugEnterRule(GrammarFileName, "or_expression");
		DebugLocation(93, 1);
		try
		{
			// Queries\\PomonaQuery.g:94:2: ( and_expression ( ( 'or' | '||' ) and_expression )* -> ^( OR_OP ( and_expression )+ ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:94:4: and_expression ( ( 'or' | '||' ) and_expression )*
			{
			DebugLocation(94, 4);
			PushFollow(Follow._and_expression_in_or_expression588);
			and_expression10=and_expression();
			PopFollow();

			stream_and_expression.Add(and_expression10.Tree);
			DebugLocation(94, 19);
			// Queries\\PomonaQuery.g:94:19: ( ( 'or' | '||' ) and_expression )*
			try { DebugEnterSubRule(4);
			while (true)
			{
				int alt4=2;
				try { DebugEnterDecision(4, false);
				int LA4_1 = input.LA(1);

				if ((LA4_1==75||LA4_1==77))
				{
					alt4 = 1;
				}


				} finally { DebugExitDecision(4); }
				switch ( alt4 )
				{
				case 1:
					DebugEnterAlt(1);
					// Queries\\PomonaQuery.g:94:21: ( 'or' | '||' ) and_expression
					{
					DebugLocation(94, 21);
					// Queries\\PomonaQuery.g:94:21: ( 'or' | '||' )
					int alt3=2;
					try { DebugEnterSubRule(3);
					try { DebugEnterDecision(3, false);
					int LA3_1 = input.LA(1);

					if ((LA3_1==75))
					{
						alt3 = 1;
					}
					else if ((LA3_1==77))
					{
						alt3 = 2;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 3, 0, input, 1);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					} finally { DebugExitDecision(3); }
					switch (alt3)
					{
					case 1:
						DebugEnterAlt(1);
						// Queries\\PomonaQuery.g:94:22: 'or'
						{
						DebugLocation(94, 22);
						string_literal11=(IToken)Match(input,75,Follow._75_in_or_expression593);  
						stream_75.Add(string_literal11);


						}
						break;
					case 2:
						DebugEnterAlt(2);
						// Queries\\PomonaQuery.g:94:27: '||'
						{
						DebugLocation(94, 27);
						string_literal12=(IToken)Match(input,77,Follow._77_in_or_expression595);  
						stream_77.Add(string_literal12);


						}
						break;

					}
					} finally { DebugExitSubRule(3); }

					DebugLocation(94, 33);
					PushFollow(Follow._and_expression_in_or_expression598);
					and_expression13=and_expression();
					PopFollow();

					stream_and_expression.Add(and_expression13.Tree);

					}
					break;

				default:
					goto loop4;
				}
			}

			loop4:
				;

			} finally { DebugExitSubRule(4); }



			{
			// AST REWRITE
			// elements: and_expression
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 94:51: -> ^( OR_OP ( and_expression )+ )
			{
				DebugLocation(94, 54);
				// Queries\\PomonaQuery.g:94:54: ^( OR_OP ( and_expression )+ )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(94, 56);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(OR_OP, "OR_OP"), root_1);

				DebugLocation(94, 62);
				if (!(stream_and_expression.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_and_expression.HasNext )
				{
					DebugLocation(94, 62);
					adaptor.AddChild(root_1, stream_and_expression.NextTree());

				}
				stream_and_expression.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("or_expression", 5);
			LeaveRule("or_expression", 5);
			LeaveRule_or_expression();
		}
		DebugLocation(95, 1);
		} finally { DebugExitRule(GrammarFileName, "or_expression"); }
		return retval;

	}
		// $ANTLR start "propertyModifiers"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:100:1: propertyModifiers : ( exclusivePropertyModifier -> ^( MODIFIERS exclusivePropertyModifier ) | ( propertyModifier )+ -> ^( MODIFIERS ( propertyModifier )+ ) );
		public propertyModifiers_return propertyModifiers() // throws RecognitionException [1]
		{
			var retval = new propertyModifiers_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			exclusivePropertyModifier_return exclusivePropertyModifier21 = default( exclusivePropertyModifier_return );

			propertyModifier_return propertyModifier22 = default( propertyModifier_return );


			var stream_propertyModifier = new RewriteRuleSubtreeStream( adaptor, "rule propertyModifier" );
			var stream_exclusivePropertyModifier = new RewriteRuleSubtreeStream( adaptor, "rule exclusivePropertyModifier" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:101:2: ( exclusivePropertyModifier -> ^( MODIFIERS exclusivePropertyModifier ) | ( propertyModifier )+ -> ^( MODIFIERS ( propertyModifier )+ ) )
				int alt8 = 2;
				int LA8_0 = input.LA( 1 );

				if ( ( LA8_0 == 64 ) )
					alt8 = 1;
				else if ( ( ( LA8_0 >= 65 && LA8_0 <= 66 ) ) )
					alt8 = 2;
				else
				{
					var nvae_d8s0 =
							new NoViableAltException( "", 8, 0, input );

					throw nvae_d8s0;
				}
				switch ( alt8 )
				{
					case 1:
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:101:4: exclusivePropertyModifier
						{
							PushFollow( FOLLOW_exclusivePropertyModifier_in_propertyModifiers419 );
							exclusivePropertyModifier21 = exclusivePropertyModifier();
							state.followingStackPointer--;

							stream_exclusivePropertyModifier.Add( exclusivePropertyModifier21.Tree );


							// AST REWRITE
							// elements:          exclusivePropertyModifier
							// token labels:      
							// rule labels:       retval
							// token list labels: 
							// rule list labels:  
							// wildcard labels: 
							retval.Tree = root_0;
							var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

							root_0 = (CommonTree)adaptor.GetNilNode();
							// 101:30: -> ^( MODIFIERS exclusivePropertyModifier )
							{
								// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:101:33: ^( MODIFIERS exclusivePropertyModifier )
								{
									var root_1 = (CommonTree)adaptor.GetNilNode();
									root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( MODIFIERS, "MODIFIERS" ), root_1 );

									adaptor.AddChild( root_1, stream_exclusivePropertyModifier.NextTree() );

									adaptor.AddChild( root_0, root_1 );
								}
							}

							retval.Tree = root_0;
							retval.Tree = root_0;
						}
						break;
					case 2:
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:102:4: ( propertyModifier )+
						{
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:102:4: ( propertyModifier )+
							int cnt7 = 0;
							do
							{
								int alt7 = 2;
								int LA7_0 = input.LA( 1 );

								if ( ( ( LA7_0 >= 65 && LA7_0 <= 66 ) ) )
									alt7 = 1;


								switch ( alt7 )
								{
									case 1:
										// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:102:4: propertyModifier
										{
											PushFollow( FOLLOW_propertyModifier_in_propertyModifiers434 );
											propertyModifier22 = propertyModifier();
											state.followingStackPointer--;

											stream_propertyModifier.Add( propertyModifier22.Tree );
										}
										break;

									default:
										if ( cnt7 >= 1 ) goto loop7;
										var eee7 =
												new EarlyExitException( 7, input );
										throw eee7;
								}
								cnt7++;
							} while ( true );

							loop7:
							; // Stops C# compiler whining that label 'loop7' has no statements


							// AST REWRITE
							// elements:          propertyModifier
							// token labels:      
							// rule labels:       retval
							// token list labels: 
							// rule list labels:  
							// wildcard labels: 
							retval.Tree = root_0;
							var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

							root_0 = (CommonTree)adaptor.GetNilNode();
							// 102:22: -> ^( MODIFIERS ( propertyModifier )+ )
							{
								// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:102:25: ^( MODIFIERS ( propertyModifier )+ )
								{
									var root_1 = (CommonTree)adaptor.GetNilNode();
									root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( MODIFIERS, "MODIFIERS" ), root_1 );

									if ( !( stream_propertyModifier.HasNext() ) ) throw new RewriteEarlyExitException();
									while ( stream_propertyModifier.HasNext() )
										adaptor.AddChild( root_1, stream_propertyModifier.NextTree() );
									stream_propertyModifier.Reset();

									adaptor.AddChild( root_0, root_1 );
								}
							}

							retval.Tree = root_0;
							retval.Tree = root_0;
						}
						break;
				}
				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #8
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_name()
	{
		EnterRule_type_name();
		EnterRule("type_name", 17);
		TraceIn("type_name", 17);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS178 = default(IToken);
		IToken string_literal179 = default(IToken);
		IToken WS180 = default(IToken);
		IToken char_literal182 = default(IToken);
		IToken WS183 = default(IToken);
		IToken char_literal184 = default(IToken);
		IToken char_literal185 = default(IToken);
		IToken WS186 = default(IToken);
		IToken WS188 = default(IToken);
		IToken char_literal189 = default(IToken);
		IToken WS190 = default(IToken);
		IToken string_literal191 = default(IToken);
		IToken WS192 = default(IToken);
		IToken char_literal194 = default(IToken);
		IToken WS195 = default(IToken);
		IToken char_literal196 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_single177 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name181 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_list187 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name193 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS178_tree = default(CommonTree);
		CommonTree string_literal179_tree = default(CommonTree);
		CommonTree WS180_tree = default(CommonTree);
		CommonTree char_literal182_tree = default(CommonTree);
		CommonTree WS183_tree = default(CommonTree);
		CommonTree char_literal184_tree = default(CommonTree);
		CommonTree char_literal185_tree = default(CommonTree);
		CommonTree WS186_tree = default(CommonTree);
		CommonTree WS188_tree = default(CommonTree);
		CommonTree char_literal189_tree = default(CommonTree);
		CommonTree WS190_tree = default(CommonTree);
		CommonTree string_literal191_tree = default(CommonTree);
		CommonTree WS192_tree = default(CommonTree);
		CommonTree char_literal194_tree = default(CommonTree);
		CommonTree WS195_tree = default(CommonTree);
		CommonTree char_literal196_tree = default(CommonTree);
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_105=new RewriteRuleITokenStream(adaptor,"token 105");
		RewriteRuleSubtreeStream stream_type_name=new RewriteRuleSubtreeStream(adaptor,"rule type_name");
		RewriteRuleSubtreeStream stream_type_list=new RewriteRuleSubtreeStream(adaptor,"rule type_list");
		RewriteRuleSubtreeStream stream_type_single=new RewriteRuleSubtreeStream(adaptor,"rule type_single");
		try { DebugEnterRule(GrammarFileName, "type_name");
		DebugLocation(300, 1);
		try
		{
			// SugarCpp.g:301:2: ( type_single ( ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' ) -> ^( Type_Func ^( Type_List type_single ) ( type_name )? ) | -> type_single ) | '(' ( ( WS )* type_list )? ( WS )* ')' ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' ) -> ^( Type_Func ( type_list )? ( type_name )? ) )
			int alt128=2;
			try { DebugEnterDecision(128, false);
			int LA128_0 = input.LA(1);

			if ((LA128_0==IDENT||LA128_0==142||LA128_0==156||(LA128_0>=166 && LA128_0<=167)||LA128_0==170))
			{
				alt128 = 1;
			}
			else if ((LA128_0==93))
			{
				alt128 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 128, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(128); }
			switch (alt128)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:301:4: type_single ( ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' ) -> ^( Type_Func ^( Type_List type_single ) ( type_name )? ) | -> type_single )
				{
				DebugLocation(301, 4);
				PushFollow(Follow._type_single_in_type_name1777);
				type_single177=type_single();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_type_single.Add(type_single177.Tree);
				DebugLocation(301, 16);
				// SugarCpp.g:301:16: ( ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' ) -> ^( Type_Func ^( Type_List type_single ) ( type_name )? ) | -> type_single )
				int alt120=2;
				try { DebugEnterSubRule(120);
				try { DebugEnterDecision(120, false);
				try
				{
					alt120 = dfa120.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(120); }
				switch (alt120)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:301:18: ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' )
					{
					DebugLocation(301, 18);
					// SugarCpp.g:301:18: ( WS )*
					try { DebugEnterSubRule(116);
					while (true)
					{
						int alt116=2;
						try { DebugEnterDecision(116, false);
						int LA116_0 = input.LA(1);

						if ((LA116_0==WS))
						{
							alt116 = 1;
						}


						} finally { DebugExitDecision(116); }
						switch ( alt116 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:301:18: WS
							{
							DebugLocation(301, 18);
							WS178=(IToken)Match(input,WS,Follow._WS_in_type_name1781); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS178);


							}
							break;

						default:
							goto loop116;
						}
					}

					loop116:
						;

					} finally { DebugExitSubRule(116); }

					DebugLocation(301, 22);
					string_literal179=(IToken)Match(input,105,Follow._105_in_type_name1784); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_105.Add(string_literal179);

					DebugLocation(301, 27);
					// SugarCpp.g:301:27: ( WS )*
					try { DebugEnterSubRule(117);
					while (true)
					{
						int alt117=2;
						try { DebugEnterDecision(117, false);
						int LA117_0 = input.LA(1);

						if ((LA117_0==WS))
						{
							alt117 = 1;
						}


						} finally { DebugExitDecision(117); }
						switch ( alt117 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:301:27: WS
							{
							DebugLocation(301, 27);
							WS180=(IToken)Match(input,WS,Follow._WS_in_type_name1786); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS180);


							}
							break;

						default:
							goto loop117;
						}
					}

					loop117:
						;

					} finally { DebugExitSubRule(117); }

					DebugLocation(301, 31);
					// SugarCpp.g:301:31: ( type_name | '(' ( WS )* ')' )
					int alt119=2;
					try { DebugEnterSubRule(119);
					try { DebugEnterDecision(119, false);
					try
					{
						alt119 = dfa119.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(119); }
					switch (alt119)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:301:32: type_name
						{
						DebugLocation(301, 32);
						PushFollow(Follow._type_name_in_type_name1790);
						type_name181=type_name();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_type_name.Add(type_name181.Tree);

						}
						break;
					case 2:
						DebugEnterAlt(2);
						// SugarCpp.g:301:44: '(' ( WS )* ')'
						{
						DebugLocation(301, 44);
						char_literal182=(IToken)Match(input,93,Follow._93_in_type_name1794); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_93.Add(char_literal182);

						DebugLocation(301, 48);
						// SugarCpp.g:301:48: ( WS )*
						try { DebugEnterSubRule(118);
						while (true)
						{
							int alt118=2;
							try { DebugEnterDecision(118, false);
							int LA118_0 = input.LA(1);

							if ((LA118_0==WS))
							{
								alt118 = 1;
							}


							} finally { DebugExitDecision(118); }
							switch ( alt118 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:301:48: WS
								{
								DebugLocation(301, 48);
								WS183=(IToken)Match(input,WS,Follow._WS_in_type_name1796); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS183);


								}
								break;

							default:
								goto loop118;
							}
						}

						loop118:
							;

						} finally { DebugExitSubRule(118); }

						DebugLocation(301, 52);
						char_literal184=(IToken)Match(input,94,Follow._94_in_type_name1799); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_94.Add(char_literal184);


						}
						break;

					}
					} finally { DebugExitSubRule(119); }



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

					root_0 = (CommonTree)adaptor.Nil();
					// 301:57: -> ^( Type_Func ^( Type_List type_single ) ( type_name )? )
					{
						DebugLocation(301, 60);
						// SugarCpp.g:301:60: ^( Type_Func ^( Type_List type_single ) ( type_name )? )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(301, 62);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Func, "Type_Func"), root_1);

						DebugLocation(301, 72);
						// SugarCpp.g:301:72: ^( Type_List type_single )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(301, 74);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_List, "Type_List"), root_2);

						DebugLocation(301, 84);
						adaptor.AddChild(root_2, stream_type_single.NextTree());

						adaptor.AddChild(root_1, root_2);
						}
						DebugLocation(301, 97);
						// SugarCpp.g:301:97: ( type_name )?
						if (stream_type_name.HasNext)
						{
							DebugLocation(301, 97);
							adaptor.AddChild(root_1, stream_type_name.NextTree());

						}
						stream_type_name.Reset();

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SugarCpp.g:302:9: 
					{

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

					root_0 = (CommonTree)adaptor.Nil();
					// 302:9: -> type_single
					{
						DebugLocation(302, 12);
						adaptor.AddChild(root_0, stream_type_single.NextTree());

					}

					retval.Tree = root_0;
					}
					}

					}
					break;

				}
				} finally { DebugExitSubRule(120); }


				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:304:4: '(' ( ( WS )* type_list )? ( WS )* ')' ( WS )* '->' ( WS )* ( type_name | '(' ( WS )* ')' )
				{
				DebugLocation(304, 4);
				char_literal185=(IToken)Match(input,93,Follow._93_in_type_name1840); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_93.Add(char_literal185);

				DebugLocation(304, 8);
				// SugarCpp.g:304:8: ( ( WS )* type_list )?
				int alt122=2;
				try { DebugEnterSubRule(122);
				try { DebugEnterDecision(122, false);
				try
				{
					alt122 = dfa122.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(122); }
				switch (alt122)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:304:9: ( WS )* type_list
					{
					DebugLocation(304, 9);
					// SugarCpp.g:304:9: ( WS )*
					try { DebugEnterSubRule(121);
					while (true)
					{
						int alt121=2;
						try { DebugEnterDecision(121, false);
						int LA121_0 = input.LA(1);

						if ((LA121_0==WS))
						{
							alt121 = 1;
						}


						} finally { DebugExitDecision(121); }
						switch ( alt121 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:304:9: WS
							{
							DebugLocation(304, 9);
							WS186=(IToken)Match(input,WS,Follow._WS_in_type_name1843); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS186);


							}
							break;

						default:
							goto loop121;
						}
					}

					loop121:
						;

					} finally { DebugExitSubRule(121); }

					DebugLocation(304, 13);
					PushFollow(Follow._type_list_in_type_name1846);
					type_list187=type_list();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_type_list.Add(type_list187.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(122); }

				DebugLocation(304, 25);
				// SugarCpp.g:304:25: ( WS )*
				try { DebugEnterSubRule(123);
				while (true)
				{
					int alt123=2;
					try { DebugEnterDecision(123, false);
					int LA123_0 = input.LA(1);

					if ((LA123_0==WS))
					{
						alt123 = 1;
					}


					} finally { DebugExitDecision(123); }
					switch ( alt123 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:304:25: WS
						{
						DebugLocation(304, 25);
						WS188=(IToken)Match(input,WS,Follow._WS_in_type_name1850); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS188);


						}
						break;

					default:
						goto loop123;
					}
				}

				loop123:
					;

				} finally { DebugExitSubRule(123); }

				DebugLocation(304, 29);
				char_literal189=(IToken)Match(input,94,Follow._94_in_type_name1853); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_94.Add(char_literal189);

				DebugLocation(304, 33);
				// SugarCpp.g:304:33: ( WS )*
				try { DebugEnterSubRule(124);
				while (true)
				{
					int alt124=2;
					try { DebugEnterDecision(124, false);
					int LA124_0 = input.LA(1);

					if ((LA124_0==WS))
					{
						alt124 = 1;
					}


					} finally { DebugExitDecision(124); }
					switch ( alt124 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:304:33: WS
						{
						DebugLocation(304, 33);
						WS190=(IToken)Match(input,WS,Follow._WS_in_type_name1855); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS190);


						}
						break;

					default:
						goto loop124;
					}
				}

				loop124:
					;

				} finally { DebugExitSubRule(124); }

				DebugLocation(304, 37);
				string_literal191=(IToken)Match(input,105,Follow._105_in_type_name1858); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_105.Add(string_literal191);

				DebugLocation(304, 42);
				// SugarCpp.g:304:42: ( WS )*
				try { DebugEnterSubRule(125);
				while (true)
				{
					int alt125=2;
					try { DebugEnterDecision(125, false);
					int LA125_0 = input.LA(1);

					if ((LA125_0==WS))
					{
						alt125 = 1;
					}


					} finally { DebugExitDecision(125); }
					switch ( alt125 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:304:42: WS
						{
						DebugLocation(304, 42);
						WS192=(IToken)Match(input,WS,Follow._WS_in_type_name1860); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS192);


						}
						break;

					default:
						goto loop125;
					}
				}

				loop125:
					;

				} finally { DebugExitSubRule(125); }

				DebugLocation(304, 46);
				// SugarCpp.g:304:46: ( type_name | '(' ( WS )* ')' )
				int alt127=2;
				try { DebugEnterSubRule(127);
				try { DebugEnterDecision(127, false);
				try
				{
					alt127 = dfa127.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(127); }
				switch (alt127)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:304:47: type_name
					{
					DebugLocation(304, 47);
					PushFollow(Follow._type_name_in_type_name1864);
					type_name193=type_name();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_type_name.Add(type_name193.Tree);

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SugarCpp.g:304:59: '(' ( WS )* ')'
					{
					DebugLocation(304, 59);
					char_literal194=(IToken)Match(input,93,Follow._93_in_type_name1868); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_93.Add(char_literal194);

					DebugLocation(304, 63);
					// SugarCpp.g:304:63: ( WS )*
					try { DebugEnterSubRule(126);
					while (true)
					{
						int alt126=2;
						try { DebugEnterDecision(126, false);
						int LA126_0 = input.LA(1);

						if ((LA126_0==WS))
						{
							alt126 = 1;
						}


						} finally { DebugExitDecision(126); }
						switch ( alt126 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:304:63: WS
							{
							DebugLocation(304, 63);
							WS195=(IToken)Match(input,WS,Follow._WS_in_type_name1870); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS195);


							}
							break;

						default:
							goto loop126;
						}
					}

					loop126:
						;

					} finally { DebugExitSubRule(126); }

					DebugLocation(304, 67);
					char_literal196=(IToken)Match(input,94,Follow._94_in_type_name1873); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_94.Add(char_literal196);


					}
					break;

				}
				} finally { DebugExitSubRule(127); }



				{
				// AST REWRITE
				// elements: type_name, type_list
				// 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();
				// 304:72: -> ^( Type_Func ( type_list )? ( type_name )? )
				{
					DebugLocation(304, 75);
					// SugarCpp.g:304:75: ^( Type_Func ( type_list )? ( type_name )? )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(304, 77);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Func, "Type_Func"), root_1);

					DebugLocation(304, 87);
					// SugarCpp.g:304:87: ( type_list )?
					if (stream_type_list.HasNext)
					{
						DebugLocation(304, 87);
						adaptor.AddChild(root_1, stream_type_list.NextTree());

					}
					stream_type_list.Reset();
					DebugLocation(304, 98);
					// SugarCpp.g:304:98: ( type_name )?
					if (stream_type_name.HasNext)
					{
						DebugLocation(304, 98);
						adaptor.AddChild(root_1, stream_type_name.NextTree());

					}
					stream_type_name.Reset();

					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("type_name", 17);
			LeaveRule("type_name", 17);
			LeaveRule_type_name();
		}
		DebugLocation(305, 1);
		} finally { DebugExitRule(GrammarFileName, "type_name"); }
		return retval;

	}
Пример #9
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_single()
	{
		EnterRule_type_single();
		EnterRule("type_single", 18);
		TraceIn("type_single", 18);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS198 = default(IToken);
		IToken char_literal199 = default(IToken);
		IToken WS200 = default(IToken);
		IToken char_literal201 = default(IToken);
		IToken WS202 = default(IToken);
		IToken WS204 = default(IToken);
		IToken char_literal205 = default(IToken);
		IToken WS206 = default(IToken);
		IToken WS208 = default(IToken);
		IToken char_literal209 = default(IToken);
		IToken WS210 = default(IToken);
		IToken char_literal211 = default(IToken);
		IToken WS212 = default(IToken);
		IToken char_literal213 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_star197 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> expr203 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> expr207 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS198_tree = default(CommonTree);
		CommonTree char_literal199_tree = default(CommonTree);
		CommonTree WS200_tree = default(CommonTree);
		CommonTree char_literal201_tree = default(CommonTree);
		CommonTree WS202_tree = default(CommonTree);
		CommonTree WS204_tree = default(CommonTree);
		CommonTree char_literal205_tree = default(CommonTree);
		CommonTree WS206_tree = default(CommonTree);
		CommonTree WS208_tree = default(CommonTree);
		CommonTree char_literal209_tree = default(CommonTree);
		CommonTree WS210_tree = default(CommonTree);
		CommonTree char_literal211_tree = default(CommonTree);
		CommonTree WS212_tree = default(CommonTree);
		CommonTree char_literal213_tree = default(CommonTree);
		RewriteRuleITokenStream stream_132=new RewriteRuleITokenStream(adaptor,"token 132");
		RewriteRuleITokenStream stream_133=new RewriteRuleITokenStream(adaptor,"token 133");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_91=new RewriteRuleITokenStream(adaptor,"token 91");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
		RewriteRuleSubtreeStream stream_type_star=new RewriteRuleSubtreeStream(adaptor,"rule type_star");
		try { DebugEnterRule(GrammarFileName, "type_single");
		DebugLocation(307, 1);
		try
		{
			// SugarCpp.g:308:2: ( type_star ( ( WS )* '&' -> ^( Type_Ref type_star ) | ( WS )* '[' ( ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) | ( ( WS )* ',' )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) ) | -> type_star ) )
			DebugEnterAlt(1);
			// SugarCpp.g:308:4: type_star ( ( WS )* '&' -> ^( Type_Ref type_star ) | ( WS )* '[' ( ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) | ( ( WS )* ',' )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) ) | -> type_star )
			{
			DebugLocation(308, 4);
			PushFollow(Follow._type_star_in_type_single1897);
			type_star197=type_star();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_star.Add(type_star197.Tree);
			DebugLocation(308, 14);
			// SugarCpp.g:308:14: ( ( WS )* '&' -> ^( Type_Ref type_star ) | ( WS )* '[' ( ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) | ( ( WS )* ',' )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) ) | -> type_star )
			int alt140=3;
			try { DebugEnterSubRule(140);
			try { DebugEnterDecision(140, false);
			try
			{
				alt140 = dfa140.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(140); }
			switch (alt140)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:308:16: ( WS )* '&'
				{
				DebugLocation(308, 16);
				// SugarCpp.g:308:16: ( WS )*
				try { DebugEnterSubRule(129);
				while (true)
				{
					int alt129=2;
					try { DebugEnterDecision(129, false);
					int LA129_0 = input.LA(1);

					if ((LA129_0==WS))
					{
						alt129 = 1;
					}


					} finally { DebugExitDecision(129); }
					switch ( alt129 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:308:16: WS
						{
						DebugLocation(308, 16);
						WS198=(IToken)Match(input,WS,Follow._WS_in_type_single1901); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS198);


						}
						break;

					default:
						goto loop129;
					}
				}

				loop129:
					;

				} finally { DebugExitSubRule(129); }

				DebugLocation(308, 20);
				char_literal199=(IToken)Match(input,91,Follow._91_in_type_single1904); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_91.Add(char_literal199);



				{
				// AST REWRITE
				// elements: type_star
				// 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();
				// 308:24: -> ^( Type_Ref type_star )
				{
					DebugLocation(308, 27);
					// SugarCpp.g:308:27: ^( Type_Ref type_star )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(308, 29);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Ref, "Type_Ref"), root_1);

					DebugLocation(308, 38);
					adaptor.AddChild(root_1, stream_type_star.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:309:7: ( WS )* '[' ( ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) | ( ( WS )* ',' )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) )
				{
				DebugLocation(309, 7);
				// SugarCpp.g:309:7: ( WS )*
				try { DebugEnterSubRule(130);
				while (true)
				{
					int alt130=2;
					try { DebugEnterDecision(130, false);
					int LA130_0 = input.LA(1);

					if ((LA130_0==WS))
					{
						alt130 = 1;
					}


					} finally { DebugExitDecision(130); }
					switch ( alt130 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:309:7: WS
						{
						DebugLocation(309, 7);
						WS200=(IToken)Match(input,WS,Follow._WS_in_type_single1920); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS200);


						}
						break;

					default:
						goto loop130;
					}
				}

				loop130:
					;

				} finally { DebugExitSubRule(130); }

				DebugLocation(309, 11);
				char_literal201=(IToken)Match(input,132,Follow._132_in_type_single1923); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_132.Add(char_literal201);

				DebugLocation(309, 15);
				// SugarCpp.g:309:15: ( ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) | ( ( WS )* ',' )* ( WS )* ']' -> ^( Type_Array type_star ( expr )+ ) )
				int alt139=2;
				try { DebugEnterSubRule(139);
				try { DebugEnterDecision(139, false);
				try
				{
					alt139 = dfa139.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(139); }
				switch (alt139)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:309:17: ( WS )* expr ( ( WS )* ',' ( WS )* expr )* ( WS )* ']'
					{
					DebugLocation(309, 17);
					// SugarCpp.g:309:17: ( WS )*
					try { DebugEnterSubRule(131);
					while (true)
					{
						int alt131=2;
						try { DebugEnterDecision(131, false);
						int LA131_0 = input.LA(1);

						if ((LA131_0==WS))
						{
							alt131 = 1;
						}


						} finally { DebugExitDecision(131); }
						switch ( alt131 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:309:17: WS
							{
							DebugLocation(309, 17);
							WS202=(IToken)Match(input,WS,Follow._WS_in_type_single1927); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS202);


							}
							break;

						default:
							goto loop131;
						}
					}

					loop131:
						;

					} finally { DebugExitSubRule(131); }

					DebugLocation(309, 21);
					PushFollow(Follow._expr_in_type_single1930);
					expr203=expr();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_expr.Add(expr203.Tree);
					DebugLocation(309, 26);
					// SugarCpp.g:309:26: ( ( WS )* ',' ( WS )* expr )*
					try { DebugEnterSubRule(134);
					while (true)
					{
						int alt134=2;
						try { DebugEnterDecision(134, false);
						try
						{
							alt134 = dfa134.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(134); }
						switch ( alt134 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:309:27: ( WS )* ',' ( WS )* expr
							{
							DebugLocation(309, 27);
							// SugarCpp.g:309:27: ( WS )*
							try { DebugEnterSubRule(132);
							while (true)
							{
								int alt132=2;
								try { DebugEnterDecision(132, false);
								int LA132_0 = input.LA(1);

								if ((LA132_0==WS))
								{
									alt132 = 1;
								}


								} finally { DebugExitDecision(132); }
								switch ( alt132 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:309:27: WS
									{
									DebugLocation(309, 27);
									WS204=(IToken)Match(input,WS,Follow._WS_in_type_single1933); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS204);


									}
									break;

								default:
									goto loop132;
								}
							}

							loop132:
								;

							} finally { DebugExitSubRule(132); }

							DebugLocation(309, 31);
							char_literal205=(IToken)Match(input,100,Follow._100_in_type_single1936); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal205);

							DebugLocation(309, 35);
							// SugarCpp.g:309:35: ( WS )*
							try { DebugEnterSubRule(133);
							while (true)
							{
								int alt133=2;
								try { DebugEnterDecision(133, false);
								int LA133_0 = input.LA(1);

								if ((LA133_0==WS))
								{
									alt133 = 1;
								}


								} finally { DebugExitDecision(133); }
								switch ( alt133 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:309:35: WS
									{
									DebugLocation(309, 35);
									WS206=(IToken)Match(input,WS,Follow._WS_in_type_single1938); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS206);


									}
									break;

								default:
									goto loop133;
								}
							}

							loop133:
								;

							} finally { DebugExitSubRule(133); }

							DebugLocation(309, 39);
							PushFollow(Follow._expr_in_type_single1941);
							expr207=expr();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_expr.Add(expr207.Tree);

							}
							break;

						default:
							goto loop134;
						}
					}

					loop134:
						;

					} finally { DebugExitSubRule(134); }

					DebugLocation(309, 46);
					// SugarCpp.g:309:46: ( WS )*
					try { DebugEnterSubRule(135);
					while (true)
					{
						int alt135=2;
						try { DebugEnterDecision(135, false);
						int LA135_0 = input.LA(1);

						if ((LA135_0==WS))
						{
							alt135 = 1;
						}


						} finally { DebugExitDecision(135); }
						switch ( alt135 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:309:46: WS
							{
							DebugLocation(309, 46);
							WS208=(IToken)Match(input,WS,Follow._WS_in_type_single1945); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS208);


							}
							break;

						default:
							goto loop135;
						}
					}

					loop135:
						;

					} finally { DebugExitSubRule(135); }

					DebugLocation(309, 50);
					char_literal209=(IToken)Match(input,133,Follow._133_in_type_single1948); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_133.Add(char_literal209);



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

					root_0 = (CommonTree)adaptor.Nil();
					// 309:54: -> ^( Type_Array type_star ( expr )+ )
					{
						DebugLocation(309, 57);
						// SugarCpp.g:309:57: ^( Type_Array type_star ( expr )+ )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(309, 59);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Array, "Type_Array"), root_1);

						DebugLocation(309, 70);
						adaptor.AddChild(root_1, stream_type_star.NextTree());
						DebugLocation(309, 80);
						if (!(stream_expr.HasNext))
						{
							throw new RewriteEarlyExitException();
						}
						while ( stream_expr.HasNext )
						{
							DebugLocation(309, 80);
							adaptor.AddChild(root_1, stream_expr.NextTree());

						}
						stream_expr.Reset();

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;
				case 2:
					DebugEnterAlt(2);
					// SugarCpp.g:310:17: ( ( WS )* ',' )* ( WS )* ']'
					{
					DebugLocation(310, 17);
					// SugarCpp.g:310:17: ( ( WS )* ',' )*
					try { DebugEnterSubRule(137);
					while (true)
					{
						int alt137=2;
						try { DebugEnterDecision(137, false);
						try
						{
							alt137 = dfa137.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(137); }
						switch ( alt137 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:310:18: ( WS )* ','
							{
							DebugLocation(310, 18);
							// SugarCpp.g:310:18: ( WS )*
							try { DebugEnterSubRule(136);
							while (true)
							{
								int alt136=2;
								try { DebugEnterDecision(136, false);
								int LA136_0 = input.LA(1);

								if ((LA136_0==WS))
								{
									alt136 = 1;
								}


								} finally { DebugExitDecision(136); }
								switch ( alt136 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:310:18: WS
									{
									DebugLocation(310, 18);
									WS210=(IToken)Match(input,WS,Follow._WS_in_type_single1978); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS210);


									}
									break;

								default:
									goto loop136;
								}
							}

							loop136:
								;

							} finally { DebugExitSubRule(136); }

							DebugLocation(310, 22);
							char_literal211=(IToken)Match(input,100,Follow._100_in_type_single1981); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal211);


							}
							break;

						default:
							goto loop137;
						}
					}

					loop137:
						;

					} finally { DebugExitSubRule(137); }

					DebugLocation(310, 28);
					// SugarCpp.g:310:28: ( WS )*
					try { DebugEnterSubRule(138);
					while (true)
					{
						int alt138=2;
						try { DebugEnterDecision(138, false);
						int LA138_0 = input.LA(1);

						if ((LA138_0==WS))
						{
							alt138 = 1;
						}


						} finally { DebugExitDecision(138); }
						switch ( alt138 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:310:28: WS
							{
							DebugLocation(310, 28);
							WS212=(IToken)Match(input,WS,Follow._WS_in_type_single1985); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS212);


							}
							break;

						default:
							goto loop138;
						}
					}

					loop138:
						;

					} finally { DebugExitSubRule(138); }

					DebugLocation(310, 32);
					char_literal213=(IToken)Match(input,133,Follow._133_in_type_single1988); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_133.Add(char_literal213);



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

					root_0 = (CommonTree)adaptor.Nil();
					// 310:36: -> ^( Type_Array type_star ( expr )+ )
					{
						DebugLocation(310, 39);
						// SugarCpp.g:310:39: ^( Type_Array type_star ( expr )+ )
						{
						CommonTree root_1 = (CommonTree)adaptor.Nil();
						DebugLocation(310, 41);
						root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Array, "Type_Array"), root_1);

						DebugLocation(310, 52);
						adaptor.AddChild(root_1, stream_type_star.NextTree());
						DebugLocation(310, 62);
						if (!(stream_expr.HasNext))
						{
							throw new RewriteEarlyExitException();
						}
						while ( stream_expr.HasNext )
						{
							DebugLocation(310, 62);
							adaptor.AddChild(root_1, stream_expr.NextTree());

						}
						stream_expr.Reset();

						adaptor.AddChild(root_0, root_1);
						}

					}

					retval.Tree = root_0;
					}
					}

					}
					break;

				}
				} finally { DebugExitSubRule(139); }


				}
				break;
			case 3:
				DebugEnterAlt(3);
				// SugarCpp.g:312:7: 
				{

				{
				// AST REWRITE
				// elements: type_star
				// 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();
				// 312:7: -> type_star
				{
					DebugLocation(312, 10);
					adaptor.AddChild(root_0, stream_type_star.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(140); }


			}

			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("type_single", 18);
			LeaveRule("type_single", 18);
			LeaveRule_type_single();
		}
		DebugLocation(314, 1);
		} finally { DebugExitRule(GrammarFileName, "type_single"); }
		return retval;

	}
Пример #10
0
	private AstParserRuleReturnScope<CommonTree, IToken> class_def()
	{
		EnterRule_class_def();
		EnterRule("class_def", 15);
		TraceIn("class_def", 15);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal130 = default(IToken);
		IToken WS131 = default(IToken);
		IToken string_literal132 = default(IToken);
		IToken WS133 = default(IToken);
		IToken WS136 = default(IToken);
		IToken char_literal137 = default(IToken);
		IToken WS138 = default(IToken);
		IToken WS140 = default(IToken);
		IToken char_literal141 = default(IToken);
		IToken WS142 = default(IToken);
		IToken WS144 = default(IToken);
		IToken NEWLINE145 = default(IToken);
		IToken INDENT146 = default(IToken);
		IToken NEWLINE147 = default(IToken);
		IToken DEDENT149 = default(IToken);
		IToken string_literal150 = default(IToken);
		IToken WS151 = default(IToken);
		IToken string_literal152 = default(IToken);
		IToken WS153 = default(IToken);
		IToken WS156 = default(IToken);
		IToken WS158 = default(IToken);
		IToken char_literal159 = default(IToken);
		IToken WS160 = default(IToken);
		IToken WS162 = default(IToken);
		IToken char_literal163 = default(IToken);
		IToken WS164 = default(IToken);
		IToken WS166 = default(IToken);
		IToken NEWLINE167 = default(IToken);
		IToken INDENT168 = default(IToken);
		IToken NEWLINE169 = default(IToken);
		IToken DEDENT171 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute129 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident134 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> generic_parameter135 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident139 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident143 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> global_block148 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident154 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> generic_parameter155 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> class_args157 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident161 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident165 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> global_block170 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal130_tree = default(CommonTree);
		CommonTree WS131_tree = default(CommonTree);
		CommonTree string_literal132_tree = default(CommonTree);
		CommonTree WS133_tree = default(CommonTree);
		CommonTree WS136_tree = default(CommonTree);
		CommonTree char_literal137_tree = default(CommonTree);
		CommonTree WS138_tree = default(CommonTree);
		CommonTree WS140_tree = default(CommonTree);
		CommonTree char_literal141_tree = default(CommonTree);
		CommonTree WS142_tree = default(CommonTree);
		CommonTree WS144_tree = default(CommonTree);
		CommonTree NEWLINE145_tree = default(CommonTree);
		CommonTree INDENT146_tree = default(CommonTree);
		CommonTree NEWLINE147_tree = default(CommonTree);
		CommonTree DEDENT149_tree = default(CommonTree);
		CommonTree string_literal150_tree = default(CommonTree);
		CommonTree WS151_tree = default(CommonTree);
		CommonTree string_literal152_tree = default(CommonTree);
		CommonTree WS153_tree = default(CommonTree);
		CommonTree WS156_tree = default(CommonTree);
		CommonTree WS158_tree = default(CommonTree);
		CommonTree char_literal159_tree = default(CommonTree);
		CommonTree WS160_tree = default(CommonTree);
		CommonTree WS162_tree = default(CommonTree);
		CommonTree char_literal163_tree = default(CommonTree);
		CommonTree WS164_tree = default(CommonTree);
		CommonTree WS166_tree = default(CommonTree);
		CommonTree NEWLINE167_tree = default(CommonTree);
		CommonTree INDENT168_tree = default(CommonTree);
		CommonTree NEWLINE169_tree = default(CommonTree);
		CommonTree DEDENT171_tree = default(CommonTree);
		RewriteRuleITokenStream stream_163=new RewriteRuleITokenStream(adaptor,"token 163");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_DEDENT=new RewriteRuleITokenStream(adaptor,"token DEDENT");
		RewriteRuleITokenStream stream_139=new RewriteRuleITokenStream(adaptor,"token 139");
		RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
		RewriteRuleITokenStream stream_111=new RewriteRuleITokenStream(adaptor,"token 111");
		RewriteRuleITokenStream stream_INDENT=new RewriteRuleITokenStream(adaptor,"token INDENT");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleITokenStream stream_141=new RewriteRuleITokenStream(adaptor,"token 141");
		RewriteRuleSubtreeStream stream_class_args=new RewriteRuleSubtreeStream(adaptor,"rule class_args");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		RewriteRuleSubtreeStream stream_global_block=new RewriteRuleSubtreeStream(adaptor,"rule global_block");
		RewriteRuleSubtreeStream stream_generic_parameter=new RewriteRuleSubtreeStream(adaptor,"rule generic_parameter");
		try { DebugEnterRule(GrammarFileName, "class_def");
		DebugLocation(290, 1);
		try
		{
			// SugarCpp.g:291:2: ( ( attribute )? ( 'public' ( WS )* )? ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:291:5: ( attribute )? ( 'public' ( WS )* )? ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) )
			{
			DebugLocation(291, 5);
			// SugarCpp.g:291:5: ( attribute )?
			int alt82=2;
			try { DebugEnterSubRule(82);
			try { DebugEnterDecision(82, false);
			int LA82_0 = input.LA(1);

			if ((LA82_0==132))
			{
				alt82 = 1;
			}
			} finally { DebugExitDecision(82); }
			switch (alt82)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:5: attribute
				{
				DebugLocation(291, 5);
				PushFollow(Follow._attribute_in_class_def1504);
				attribute129=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute129.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(82); }

			DebugLocation(291, 16);
			// SugarCpp.g:291:16: ( 'public' ( WS )* )?
			int alt84=2;
			try { DebugEnterSubRule(84);
			try { DebugEnterDecision(84, false);
			int LA84_0 = input.LA(1);

			if ((LA84_0==163))
			{
				alt84 = 1;
			}
			} finally { DebugExitDecision(84); }
			switch (alt84)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:17: 'public' ( WS )*
				{
				DebugLocation(291, 17);
				string_literal130=(IToken)Match(input,163,Follow._163_in_class_def1508); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_163.Add(string_literal130);

				DebugLocation(291, 26);
				// SugarCpp.g:291:26: ( WS )*
				try { DebugEnterSubRule(83);
				while (true)
				{
					int alt83=2;
					try { DebugEnterDecision(83, false);
					int LA83_0 = input.LA(1);

					if ((LA83_0==WS))
					{
						alt83 = 1;
					}


					} finally { DebugExitDecision(83); }
					switch ( alt83 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:291:26: WS
						{
						DebugLocation(291, 26);
						WS131=(IToken)Match(input,WS,Follow._WS_in_class_def1510); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS131);


						}
						break;

					default:
						goto loop83;
					}
				}

				loop83:
					;

				} finally { DebugExitSubRule(83); }


				}
				break;

			}
			} finally { DebugExitSubRule(84); }

			DebugLocation(291, 32);
			// SugarCpp.g:291:32: ( 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) | 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? ) )
			int alt112=2;
			try { DebugEnterSubRule(112);
			try { DebugEnterDecision(112, false);
			int LA112_0 = input.LA(1);

			if ((LA112_0==141))
			{
				alt112 = 1;
			}
			else if ((LA112_0==139))
			{
				alt112 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 112, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(112); }
			switch (alt112)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:291:34: 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				{
				DebugLocation(291, 34);
				string_literal132=(IToken)Match(input,141,Follow._141_in_class_def1517); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_141.Add(string_literal132);

				DebugLocation(291, 42);
				// SugarCpp.g:291:42: ( WS )*
				try { DebugEnterSubRule(85);
				while (true)
				{
					int alt85=2;
					try { DebugEnterDecision(85, false);
					int LA85_0 = input.LA(1);

					if ((LA85_0==WS))
					{
						alt85 = 1;
					}


					} finally { DebugExitDecision(85); }
					switch ( alt85 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:291:42: WS
						{
						DebugLocation(291, 42);
						WS133=(IToken)Match(input,WS,Follow._WS_in_class_def1519); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS133);


						}
						break;

					default:
						goto loop85;
					}
				}

				loop85:
					;

				} finally { DebugExitSubRule(85); }

				DebugLocation(291, 46);
				PushFollow(Follow._ident_in_class_def1522);
				ident134=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident134.Tree);
				DebugLocation(291, 52);
				// SugarCpp.g:291:52: ( generic_parameter )?
				int alt86=2;
				try { DebugEnterSubRule(86);
				try { DebugEnterDecision(86, false);
				int LA86_0 = input.LA(1);

				if ((LA86_0==115))
				{
					alt86 = 1;
				}
				} finally { DebugExitDecision(86); }
				switch (alt86)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:53: generic_parameter
					{
					DebugLocation(291, 53);
					PushFollow(Follow._generic_parameter_in_class_def1525);
					generic_parameter135=generic_parameter();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_generic_parameter.Add(generic_parameter135.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(86); }

				DebugLocation(291, 73);
				// SugarCpp.g:291:73: ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )?
				int alt92=2;
				try { DebugEnterSubRule(92);
				try { DebugEnterDecision(92, false);
				try
				{
					alt92 = dfa92.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(92); }
				switch (alt92)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:74: ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )*
					{
					DebugLocation(291, 74);
					// SugarCpp.g:291:74: ( WS )*
					try { DebugEnterSubRule(87);
					while (true)
					{
						int alt87=2;
						try { DebugEnterDecision(87, false);
						int LA87_0 = input.LA(1);

						if ((LA87_0==WS))
						{
							alt87 = 1;
						}


						} finally { DebugExitDecision(87); }
						switch ( alt87 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:74: WS
							{
							DebugLocation(291, 74);
							WS136=(IToken)Match(input,WS,Follow._WS_in_class_def1530); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS136);


							}
							break;

						default:
							goto loop87;
						}
					}

					loop87:
						;

					} finally { DebugExitSubRule(87); }

					DebugLocation(291, 78);
					char_literal137=(IToken)Match(input,111,Follow._111_in_class_def1533); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_111.Add(char_literal137);

					DebugLocation(291, 82);
					// SugarCpp.g:291:82: ( WS )*
					try { DebugEnterSubRule(88);
					while (true)
					{
						int alt88=2;
						try { DebugEnterDecision(88, false);
						int LA88_0 = input.LA(1);

						if ((LA88_0==WS))
						{
							alt88 = 1;
						}


						} finally { DebugExitDecision(88); }
						switch ( alt88 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:82: WS
							{
							DebugLocation(291, 82);
							WS138=(IToken)Match(input,WS,Follow._WS_in_class_def1535); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS138);


							}
							break;

						default:
							goto loop88;
						}
					}

					loop88:
						;

					} finally { DebugExitSubRule(88); }

					DebugLocation(291, 86);
					PushFollow(Follow._ident_in_class_def1538);
					ident139=ident();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_ident.Add(ident139.Tree);
					DebugLocation(291, 92);
					// SugarCpp.g:291:92: ( ( WS )* ',' ( WS )* ident )*
					try { DebugEnterSubRule(91);
					while (true)
					{
						int alt91=2;
						try { DebugEnterDecision(91, false);
						try
						{
							alt91 = dfa91.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(91); }
						switch ( alt91 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:93: ( WS )* ',' ( WS )* ident
							{
							DebugLocation(291, 93);
							// SugarCpp.g:291:93: ( WS )*
							try { DebugEnterSubRule(89);
							while (true)
							{
								int alt89=2;
								try { DebugEnterDecision(89, false);
								int LA89_0 = input.LA(1);

								if ((LA89_0==WS))
								{
									alt89 = 1;
								}


								} finally { DebugExitDecision(89); }
								switch ( alt89 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:291:93: WS
									{
									DebugLocation(291, 93);
									WS140=(IToken)Match(input,WS,Follow._WS_in_class_def1541); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS140);


									}
									break;

								default:
									goto loop89;
								}
							}

							loop89:
								;

							} finally { DebugExitSubRule(89); }

							DebugLocation(291, 97);
							char_literal141=(IToken)Match(input,100,Follow._100_in_class_def1544); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal141);

							DebugLocation(291, 101);
							// SugarCpp.g:291:101: ( WS )*
							try { DebugEnterSubRule(90);
							while (true)
							{
								int alt90=2;
								try { DebugEnterDecision(90, false);
								int LA90_0 = input.LA(1);

								if ((LA90_0==WS))
								{
									alt90 = 1;
								}


								} finally { DebugExitDecision(90); }
								switch ( alt90 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:291:101: WS
									{
									DebugLocation(291, 101);
									WS142=(IToken)Match(input,WS,Follow._WS_in_class_def1546); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS142);


									}
									break;

								default:
									goto loop90;
								}
							}

							loop90:
								;

							} finally { DebugExitSubRule(90); }

							DebugLocation(291, 105);
							PushFollow(Follow._ident_in_class_def1549);
							ident143=ident();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_ident.Add(ident143.Tree);

							}
							break;

						default:
							goto loop91;
						}
					}

					loop91:
						;

					} finally { DebugExitSubRule(91); }


					}
					break;

				}
				} finally { DebugExitSubRule(92); }

				DebugLocation(291, 115);
				// SugarCpp.g:291:115: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				int alt96=2;
				try { DebugEnterSubRule(96);
				try { DebugEnterDecision(96, false);
				try
				{
					alt96 = dfa96.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(96); }
				switch (alt96)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:291:116: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT
					{
					DebugLocation(291, 116);
					// SugarCpp.g:291:116: ( WS )*
					try { DebugEnterSubRule(93);
					while (true)
					{
						int alt93=2;
						try { DebugEnterDecision(93, false);
						int LA93_0 = input.LA(1);

						if ((LA93_0==WS))
						{
							alt93 = 1;
						}


						} finally { DebugExitDecision(93); }
						switch ( alt93 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:116: WS
							{
							DebugLocation(291, 116);
							WS144=(IToken)Match(input,WS,Follow._WS_in_class_def1556); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS144);


							}
							break;

						default:
							goto loop93;
						}
					}

					loop93:
						;

					} finally { DebugExitSubRule(93); }

					DebugLocation(291, 120);
					// SugarCpp.g:291:120: ( NEWLINE )+
					int cnt94=0;
					try { DebugEnterSubRule(94);
					while (true)
					{
						int alt94=2;
						try { DebugEnterDecision(94, false);
						int LA94_0 = input.LA(1);

						if ((LA94_0==NEWLINE))
						{
							alt94 = 1;
						}


						} finally { DebugExitDecision(94); }
						switch (alt94)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:120: NEWLINE
							{
							DebugLocation(291, 120);
							NEWLINE145=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1559); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE145);


							}
							break;

						default:
							if (cnt94 >= 1)
								goto loop94;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee94 = new EarlyExitException( 94, input );
							DebugRecognitionException(eee94);
							throw eee94;
						}
						cnt94++;
					}
					loop94:
						;

					} finally { DebugExitSubRule(94); }

					DebugLocation(291, 129);
					INDENT146=(IToken)Match(input,INDENT,Follow._INDENT_in_class_def1562); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_INDENT.Add(INDENT146);

					DebugLocation(291, 136);
					// SugarCpp.g:291:136: ( NEWLINE )*
					try { DebugEnterSubRule(95);
					while (true)
					{
						int alt95=2;
						try { DebugEnterDecision(95, false);
						int LA95_0 = input.LA(1);

						if ((LA95_0==NEWLINE))
						{
							alt95 = 1;
						}


						} finally { DebugExitDecision(95); }
						switch ( alt95 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:291:136: NEWLINE
							{
							DebugLocation(291, 136);
							NEWLINE147=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1564); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE147);


							}
							break;

						default:
							goto loop95;
						}
					}

					loop95:
						;

					} finally { DebugExitSubRule(95); }

					DebugLocation(291, 145);
					PushFollow(Follow._global_block_in_class_def1567);
					global_block148=global_block();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_global_block.Add(global_block148.Tree);
					DebugLocation(291, 158);
					DEDENT149=(IToken)Match(input,DEDENT,Follow._DEDENT_in_class_def1569); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_DEDENT.Add(DEDENT149);


					}
					break;

				}
				} finally { DebugExitSubRule(96); }



				{
				// AST REWRITE
				// elements: class_args, generic_parameter, ident, 163, attribute, global_block, ident
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				if (state.backtracking == 0) {
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (CommonTree)adaptor.Nil();
				// 291:167: -> ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
				{
					DebugLocation(291, 170);
					// SugarCpp.g:291:170: ^( Class ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(291, 172);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Class, "Class"), root_1);

					DebugLocation(291, 178);
					// SugarCpp.g:291:178: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(291, 178);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(291, 188);
					// SugarCpp.g:291:188: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(291, 188);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(291, 199);
					adaptor.AddChild(root_1, stream_ident.NextTree());
					DebugLocation(291, 205);
					// SugarCpp.g:291:205: ( generic_parameter )?
					if (stream_generic_parameter.HasNext)
					{
						DebugLocation(291, 205);
						adaptor.AddChild(root_1, stream_generic_parameter.NextTree());

					}
					stream_generic_parameter.Reset();
					DebugLocation(291, 224);
					// SugarCpp.g:291:224: ( class_args )?
					if (stream_class_args.HasNext)
					{
						DebugLocation(291, 224);
						adaptor.AddChild(root_1, stream_class_args.NextTree());

					}
					stream_class_args.Reset();
					DebugLocation(291, 236);
					// SugarCpp.g:291:236: ( ^( Ident_List ( ident )* ) )?
					if (stream_ident.HasNext)
					{
						DebugLocation(291, 237);
						// SugarCpp.g:291:237: ^( Ident_List ( ident )* )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(291, 239);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Ident_List, "Ident_List"), root_2);

						DebugLocation(291, 250);
						// SugarCpp.g:291:250: ( ident )*
						while ( stream_ident.HasNext )
						{
							DebugLocation(291, 250);
							adaptor.AddChild(root_2, stream_ident.NextTree());

						}
						stream_ident.Reset();

						adaptor.AddChild(root_1, root_2);
						}

					}
					stream_ident.Reset();
					DebugLocation(291, 260);
					// SugarCpp.g:291:260: ( global_block )?
					if (stream_global_block.HasNext)
					{
						DebugLocation(291, 260);
						adaptor.AddChild(root_1, stream_global_block.NextTree());

					}
					stream_global_block.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:292:13: 'case' ( WS )* 'class' ( WS )* ident ( generic_parameter )? ( ( WS )* class_args )? ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )? ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				{
				DebugLocation(292, 13);
				string_literal150=(IToken)Match(input,139,Follow._139_in_class_def1618); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_139.Add(string_literal150);

				DebugLocation(292, 20);
				// SugarCpp.g:292:20: ( WS )*
				try { DebugEnterSubRule(97);
				while (true)
				{
					int alt97=2;
					try { DebugEnterDecision(97, false);
					int LA97_0 = input.LA(1);

					if ((LA97_0==WS))
					{
						alt97 = 1;
					}


					} finally { DebugExitDecision(97); }
					switch ( alt97 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:292:20: WS
						{
						DebugLocation(292, 20);
						WS151=(IToken)Match(input,WS,Follow._WS_in_class_def1620); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS151);


						}
						break;

					default:
						goto loop97;
					}
				}

				loop97:
					;

				} finally { DebugExitSubRule(97); }

				DebugLocation(292, 24);
				string_literal152=(IToken)Match(input,141,Follow._141_in_class_def1623); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_141.Add(string_literal152);

				DebugLocation(292, 32);
				// SugarCpp.g:292:32: ( WS )*
				try { DebugEnterSubRule(98);
				while (true)
				{
					int alt98=2;
					try { DebugEnterDecision(98, false);
					int LA98_0 = input.LA(1);

					if ((LA98_0==WS))
					{
						alt98 = 1;
					}


					} finally { DebugExitDecision(98); }
					switch ( alt98 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:292:32: WS
						{
						DebugLocation(292, 32);
						WS153=(IToken)Match(input,WS,Follow._WS_in_class_def1625); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS153);


						}
						break;

					default:
						goto loop98;
					}
				}

				loop98:
					;

				} finally { DebugExitSubRule(98); }

				DebugLocation(292, 36);
				PushFollow(Follow._ident_in_class_def1628);
				ident154=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident154.Tree);
				DebugLocation(292, 42);
				// SugarCpp.g:292:42: ( generic_parameter )?
				int alt99=2;
				try { DebugEnterSubRule(99);
				try { DebugEnterDecision(99, false);
				int LA99_0 = input.LA(1);

				if ((LA99_0==115))
				{
					alt99 = 1;
				}
				} finally { DebugExitDecision(99); }
				switch (alt99)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:43: generic_parameter
					{
					DebugLocation(292, 43);
					PushFollow(Follow._generic_parameter_in_class_def1631);
					generic_parameter155=generic_parameter();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_generic_parameter.Add(generic_parameter155.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(99); }

				DebugLocation(292, 63);
				// SugarCpp.g:292:63: ( ( WS )* class_args )?
				int alt101=2;
				try { DebugEnterSubRule(101);
				try { DebugEnterDecision(101, false);
				try
				{
					alt101 = dfa101.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(101); }
				switch (alt101)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:64: ( WS )* class_args
					{
					DebugLocation(292, 64);
					// SugarCpp.g:292:64: ( WS )*
					try { DebugEnterSubRule(100);
					while (true)
					{
						int alt100=2;
						try { DebugEnterDecision(100, false);
						int LA100_0 = input.LA(1);

						if ((LA100_0==WS))
						{
							alt100 = 1;
						}


						} finally { DebugExitDecision(100); }
						switch ( alt100 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:64: WS
							{
							DebugLocation(292, 64);
							WS156=(IToken)Match(input,WS,Follow._WS_in_class_def1636); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS156);


							}
							break;

						default:
							goto loop100;
						}
					}

					loop100:
						;

					} finally { DebugExitSubRule(100); }

					DebugLocation(292, 68);
					PushFollow(Follow._class_args_in_class_def1639);
					class_args157=class_args();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_class_args.Add(class_args157.Tree);

					}
					break;

				}
				} finally { DebugExitSubRule(101); }

				DebugLocation(292, 81);
				// SugarCpp.g:292:81: ( ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )* )?
				int alt107=2;
				try { DebugEnterSubRule(107);
				try { DebugEnterDecision(107, false);
				try
				{
					alt107 = dfa107.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(107); }
				switch (alt107)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:82: ( WS )* ':' ( WS )* ident ( ( WS )* ',' ( WS )* ident )*
					{
					DebugLocation(292, 82);
					// SugarCpp.g:292:82: ( WS )*
					try { DebugEnterSubRule(102);
					while (true)
					{
						int alt102=2;
						try { DebugEnterDecision(102, false);
						int LA102_0 = input.LA(1);

						if ((LA102_0==WS))
						{
							alt102 = 1;
						}


						} finally { DebugExitDecision(102); }
						switch ( alt102 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:82: WS
							{
							DebugLocation(292, 82);
							WS158=(IToken)Match(input,WS,Follow._WS_in_class_def1644); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS158);


							}
							break;

						default:
							goto loop102;
						}
					}

					loop102:
						;

					} finally { DebugExitSubRule(102); }

					DebugLocation(292, 86);
					char_literal159=(IToken)Match(input,111,Follow._111_in_class_def1647); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_111.Add(char_literal159);

					DebugLocation(292, 90);
					// SugarCpp.g:292:90: ( WS )*
					try { DebugEnterSubRule(103);
					while (true)
					{
						int alt103=2;
						try { DebugEnterDecision(103, false);
						int LA103_0 = input.LA(1);

						if ((LA103_0==WS))
						{
							alt103 = 1;
						}


						} finally { DebugExitDecision(103); }
						switch ( alt103 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:90: WS
							{
							DebugLocation(292, 90);
							WS160=(IToken)Match(input,WS,Follow._WS_in_class_def1649); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS160);


							}
							break;

						default:
							goto loop103;
						}
					}

					loop103:
						;

					} finally { DebugExitSubRule(103); }

					DebugLocation(292, 94);
					PushFollow(Follow._ident_in_class_def1652);
					ident161=ident();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_ident.Add(ident161.Tree);
					DebugLocation(292, 100);
					// SugarCpp.g:292:100: ( ( WS )* ',' ( WS )* ident )*
					try { DebugEnterSubRule(106);
					while (true)
					{
						int alt106=2;
						try { DebugEnterDecision(106, false);
						try
						{
							alt106 = dfa106.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(106); }
						switch ( alt106 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:101: ( WS )* ',' ( WS )* ident
							{
							DebugLocation(292, 101);
							// SugarCpp.g:292:101: ( WS )*
							try { DebugEnterSubRule(104);
							while (true)
							{
								int alt104=2;
								try { DebugEnterDecision(104, false);
								int LA104_0 = input.LA(1);

								if ((LA104_0==WS))
								{
									alt104 = 1;
								}


								} finally { DebugExitDecision(104); }
								switch ( alt104 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:292:101: WS
									{
									DebugLocation(292, 101);
									WS162=(IToken)Match(input,WS,Follow._WS_in_class_def1655); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS162);


									}
									break;

								default:
									goto loop104;
								}
							}

							loop104:
								;

							} finally { DebugExitSubRule(104); }

							DebugLocation(292, 105);
							char_literal163=(IToken)Match(input,100,Follow._100_in_class_def1658); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal163);

							DebugLocation(292, 109);
							// SugarCpp.g:292:109: ( WS )*
							try { DebugEnterSubRule(105);
							while (true)
							{
								int alt105=2;
								try { DebugEnterDecision(105, false);
								int LA105_0 = input.LA(1);

								if ((LA105_0==WS))
								{
									alt105 = 1;
								}


								} finally { DebugExitDecision(105); }
								switch ( alt105 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:292:109: WS
									{
									DebugLocation(292, 109);
									WS164=(IToken)Match(input,WS,Follow._WS_in_class_def1660); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS164);


									}
									break;

								default:
									goto loop105;
								}
							}

							loop105:
								;

							} finally { DebugExitSubRule(105); }

							DebugLocation(292, 113);
							PushFollow(Follow._ident_in_class_def1663);
							ident165=ident();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_ident.Add(ident165.Tree);

							}
							break;

						default:
							goto loop106;
						}
					}

					loop106:
						;

					} finally { DebugExitSubRule(106); }


					}
					break;

				}
				} finally { DebugExitSubRule(107); }

				DebugLocation(292, 123);
				// SugarCpp.g:292:123: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
				int alt111=2;
				try { DebugEnterSubRule(111);
				try { DebugEnterDecision(111, false);
				try
				{
					alt111 = dfa111.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(111); }
				switch (alt111)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:292:124: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT
					{
					DebugLocation(292, 124);
					// SugarCpp.g:292:124: ( WS )*
					try { DebugEnterSubRule(108);
					while (true)
					{
						int alt108=2;
						try { DebugEnterDecision(108, false);
						int LA108_0 = input.LA(1);

						if ((LA108_0==WS))
						{
							alt108 = 1;
						}


						} finally { DebugExitDecision(108); }
						switch ( alt108 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:124: WS
							{
							DebugLocation(292, 124);
							WS166=(IToken)Match(input,WS,Follow._WS_in_class_def1670); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS166);


							}
							break;

						default:
							goto loop108;
						}
					}

					loop108:
						;

					} finally { DebugExitSubRule(108); }

					DebugLocation(292, 128);
					// SugarCpp.g:292:128: ( NEWLINE )+
					int cnt109=0;
					try { DebugEnterSubRule(109);
					while (true)
					{
						int alt109=2;
						try { DebugEnterDecision(109, false);
						int LA109_0 = input.LA(1);

						if ((LA109_0==NEWLINE))
						{
							alt109 = 1;
						}


						} finally { DebugExitDecision(109); }
						switch (alt109)
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:128: NEWLINE
							{
							DebugLocation(292, 128);
							NEWLINE167=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1673); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE167);


							}
							break;

						default:
							if (cnt109 >= 1)
								goto loop109;

							if (state.backtracking>0) {state.failed=true; return retval;}
							EarlyExitException eee109 = new EarlyExitException( 109, input );
							DebugRecognitionException(eee109);
							throw eee109;
						}
						cnt109++;
					}
					loop109:
						;

					} finally { DebugExitSubRule(109); }

					DebugLocation(292, 137);
					INDENT168=(IToken)Match(input,INDENT,Follow._INDENT_in_class_def1676); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_INDENT.Add(INDENT168);

					DebugLocation(292, 144);
					// SugarCpp.g:292:144: ( NEWLINE )*
					try { DebugEnterSubRule(110);
					while (true)
					{
						int alt110=2;
						try { DebugEnterDecision(110, false);
						int LA110_0 = input.LA(1);

						if ((LA110_0==NEWLINE))
						{
							alt110 = 1;
						}


						} finally { DebugExitDecision(110); }
						switch ( alt110 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:292:144: NEWLINE
							{
							DebugLocation(292, 144);
							NEWLINE169=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_class_def1678); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE169);


							}
							break;

						default:
							goto loop110;
						}
					}

					loop110:
						;

					} finally { DebugExitSubRule(110); }

					DebugLocation(292, 153);
					PushFollow(Follow._global_block_in_class_def1681);
					global_block170=global_block();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_global_block.Add(global_block170.Tree);
					DebugLocation(292, 166);
					DEDENT171=(IToken)Match(input,DEDENT,Follow._DEDENT_in_class_def1683); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_DEDENT.Add(DEDENT171);


					}
					break;

				}
				} finally { DebugExitSubRule(111); }



				{
				// AST REWRITE
				// elements: ident, attribute, generic_parameter, 163, global_block, 139, class_args, ident
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				if (state.backtracking == 0) {
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (CommonTree)adaptor.Nil();
				// 292:175: -> ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
				{
					DebugLocation(292, 178);
					// SugarCpp.g:292:178: ^( Class 'case' ( 'public' )? ( attribute )? ident ( generic_parameter )? ( class_args )? ( ^( Ident_List ( ident )* ) )? ( global_block )? )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(292, 180);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Class, "Class"), root_1);

					DebugLocation(292, 186);
					adaptor.AddChild(root_1, stream_139.NextNode());
					DebugLocation(292, 193);
					// SugarCpp.g:292:193: ( 'public' )?
					if (stream_163.HasNext)
					{
						DebugLocation(292, 193);
						adaptor.AddChild(root_1, stream_163.NextNode());

					}
					stream_163.Reset();
					DebugLocation(292, 203);
					// SugarCpp.g:292:203: ( attribute )?
					if (stream_attribute.HasNext)
					{
						DebugLocation(292, 203);
						adaptor.AddChild(root_1, stream_attribute.NextTree());

					}
					stream_attribute.Reset();
					DebugLocation(292, 214);
					adaptor.AddChild(root_1, stream_ident.NextTree());
					DebugLocation(292, 220);
					// SugarCpp.g:292:220: ( generic_parameter )?
					if (stream_generic_parameter.HasNext)
					{
						DebugLocation(292, 220);
						adaptor.AddChild(root_1, stream_generic_parameter.NextTree());

					}
					stream_generic_parameter.Reset();
					DebugLocation(292, 239);
					// SugarCpp.g:292:239: ( class_args )?
					if (stream_class_args.HasNext)
					{
						DebugLocation(292, 239);
						adaptor.AddChild(root_1, stream_class_args.NextTree());

					}
					stream_class_args.Reset();
					DebugLocation(292, 251);
					// SugarCpp.g:292:251: ( ^( Ident_List ( ident )* ) )?
					if (stream_ident.HasNext)
					{
						DebugLocation(292, 252);
						// SugarCpp.g:292:252: ^( Ident_List ( ident )* )
						{
						CommonTree root_2 = (CommonTree)adaptor.Nil();
						DebugLocation(292, 254);
						root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Ident_List, "Ident_List"), root_2);

						DebugLocation(292, 265);
						// SugarCpp.g:292:265: ( ident )*
						while ( stream_ident.HasNext )
						{
							DebugLocation(292, 265);
							adaptor.AddChild(root_2, stream_ident.NextTree());

						}
						stream_ident.Reset();

						adaptor.AddChild(root_1, root_2);
						}

					}
					stream_ident.Reset();
					DebugLocation(292, 275);
					// SugarCpp.g:292:275: ( global_block )?
					if (stream_global_block.HasNext)
					{
						DebugLocation(292, 275);
						adaptor.AddChild(root_1, stream_global_block.NextTree());

					}
					stream_global_block.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(112); }


			}

			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("class_def", 15);
			LeaveRule("class_def", 15);
			LeaveRule_class_def();
		}
		DebugLocation(294, 1);
		} finally { DebugExitRule(GrammarFileName, "class_def"); }
		return retval;

	}
Пример #11
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_list()
	{
		EnterRule_type_list();
		EnterRule("type_list", 16);
		TraceIn("type_list", 16);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS173 = default(IToken);
		IToken char_literal174 = default(IToken);
		IToken WS175 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_name172 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name176 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS173_tree = default(CommonTree);
		CommonTree char_literal174_tree = default(CommonTree);
		CommonTree WS175_tree = default(CommonTree);
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_type_name=new RewriteRuleSubtreeStream(adaptor,"rule type_name");
		try { DebugEnterRule(GrammarFileName, "type_list");
		DebugLocation(296, 1);
		try
		{
			// SugarCpp.g:297:2: ( type_name ( ( WS )* ',' ( WS )* type_name )* -> ^( Type_List ( type_name )* ) )
			DebugEnterAlt(1);
			// SugarCpp.g:297:4: type_name ( ( WS )* ',' ( WS )* type_name )*
			{
			DebugLocation(297, 4);
			PushFollow(Follow._type_name_in_type_list1743);
			type_name172=type_name();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_name.Add(type_name172.Tree);
			DebugLocation(297, 14);
			// SugarCpp.g:297:14: ( ( WS )* ',' ( WS )* type_name )*
			try { DebugEnterSubRule(115);
			while (true)
			{
				int alt115=2;
				try { DebugEnterDecision(115, false);
				try
				{
					alt115 = dfa115.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(115); }
				switch ( alt115 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:297:15: ( WS )* ',' ( WS )* type_name
					{
					DebugLocation(297, 15);
					// SugarCpp.g:297:15: ( WS )*
					try { DebugEnterSubRule(113);
					while (true)
					{
						int alt113=2;
						try { DebugEnterDecision(113, false);
						int LA113_0 = input.LA(1);

						if ((LA113_0==WS))
						{
							alt113 = 1;
						}


						} finally { DebugExitDecision(113); }
						switch ( alt113 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:297:15: WS
							{
							DebugLocation(297, 15);
							WS173=(IToken)Match(input,WS,Follow._WS_in_type_list1746); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS173);


							}
							break;

						default:
							goto loop113;
						}
					}

					loop113:
						;

					} finally { DebugExitSubRule(113); }

					DebugLocation(297, 19);
					char_literal174=(IToken)Match(input,100,Follow._100_in_type_list1749); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_100.Add(char_literal174);

					DebugLocation(297, 24);
					// SugarCpp.g:297:24: ( WS )*
					try { DebugEnterSubRule(114);
					while (true)
					{
						int alt114=2;
						try { DebugEnterDecision(114, false);
						int LA114_0 = input.LA(1);

						if ((LA114_0==WS))
						{
							alt114 = 1;
						}


						} finally { DebugExitDecision(114); }
						switch ( alt114 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:297:24: WS
							{
							DebugLocation(297, 24);
							WS175=(IToken)Match(input,WS,Follow._WS_in_type_list1752); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS175);


							}
							break;

						default:
							goto loop114;
						}
					}

					loop114:
						;

					} finally { DebugExitSubRule(114); }

					DebugLocation(297, 28);
					PushFollow(Follow._type_name_in_type_list1755);
					type_name176=type_name();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_type_name.Add(type_name176.Tree);

					}
					break;

				default:
					goto loop115;
				}
			}

			loop115:
				;

			} finally { DebugExitSubRule(115); }



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

			root_0 = (CommonTree)adaptor.Nil();
			// 297:40: -> ^( Type_List ( type_name )* )
			{
				DebugLocation(297, 43);
				// SugarCpp.g:297:43: ^( Type_List ( type_name )* )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(297, 45);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_List, "Type_List"), root_1);

				DebugLocation(297, 55);
				// SugarCpp.g:297:55: ( type_name )*
				while ( stream_type_name.HasNext )
				{
					DebugLocation(297, 55);
					adaptor.AddChild(root_1, stream_type_name.NextTree());

				}
				stream_type_name.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("type_list", 16);
			LeaveRule("type_list", 16);
			LeaveRule_type_list();
		}
		DebugLocation(298, 1);
		} finally { DebugExitRule(GrammarFileName, "type_list"); }
		return retval;

	}
Пример #12
0
	private AstParserRuleReturnScope<CommonTree, IToken> class_args()
	{
		EnterRule_class_args();
		EnterRule("class_args", 14);
		TraceIn("class_args", 14);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken char_literal122 = default(IToken);
		IToken WS123 = default(IToken);
		IToken WS125 = default(IToken);
		IToken char_literal126 = default(IToken);
		IToken WS127 = default(IToken);
		IToken char_literal128 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> func_args124 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal122_tree = default(CommonTree);
		CommonTree WS123_tree = default(CommonTree);
		CommonTree WS125_tree = default(CommonTree);
		CommonTree char_literal126_tree = default(CommonTree);
		CommonTree WS127_tree = default(CommonTree);
		CommonTree char_literal128_tree = default(CommonTree);
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleSubtreeStream stream_func_args=new RewriteRuleSubtreeStream(adaptor,"rule func_args");
		try { DebugEnterRule(GrammarFileName, "class_args");
		DebugLocation(284, 1);
		try
		{
			// SugarCpp.g:285:2: ( '(' ( ( WS )* func_args ( WS )* ')' -> func_args | ( WS )* ')' -> ^( Func_Args ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:285:4: '(' ( ( WS )* func_args ( WS )* ')' -> func_args | ( WS )* ')' -> ^( Func_Args ) )
			{
			DebugLocation(285, 4);
			char_literal122=(IToken)Match(input,93,Follow._93_in_class_args1453); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_93.Add(char_literal122);

			DebugLocation(285, 8);
			// SugarCpp.g:285:8: ( ( WS )* func_args ( WS )* ')' -> func_args | ( WS )* ')' -> ^( Func_Args ) )
			int alt81=2;
			try { DebugEnterSubRule(81);
			try { DebugEnterDecision(81, false);
			try
			{
				alt81 = dfa81.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(81); }
			switch (alt81)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:285:10: ( WS )* func_args ( WS )* ')'
				{
				DebugLocation(285, 10);
				// SugarCpp.g:285:10: ( WS )*
				try { DebugEnterSubRule(78);
				while (true)
				{
					int alt78=2;
					try { DebugEnterDecision(78, false);
					int LA78_0 = input.LA(1);

					if ((LA78_0==WS))
					{
						alt78 = 1;
					}


					} finally { DebugExitDecision(78); }
					switch ( alt78 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:285:10: WS
						{
						DebugLocation(285, 10);
						WS123=(IToken)Match(input,WS,Follow._WS_in_class_args1457); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS123);


						}
						break;

					default:
						goto loop78;
					}
				}

				loop78:
					;

				} finally { DebugExitSubRule(78); }

				DebugLocation(285, 14);
				PushFollow(Follow._func_args_in_class_args1460);
				func_args124=func_args();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_func_args.Add(func_args124.Tree);
				DebugLocation(285, 24);
				// SugarCpp.g:285:24: ( WS )*
				try { DebugEnterSubRule(79);
				while (true)
				{
					int alt79=2;
					try { DebugEnterDecision(79, false);
					int LA79_0 = input.LA(1);

					if ((LA79_0==WS))
					{
						alt79 = 1;
					}


					} finally { DebugExitDecision(79); }
					switch ( alt79 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:285:24: WS
						{
						DebugLocation(285, 24);
						WS125=(IToken)Match(input,WS,Follow._WS_in_class_args1462); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS125);


						}
						break;

					default:
						goto loop79;
					}
				}

				loop79:
					;

				} finally { DebugExitSubRule(79); }

				DebugLocation(285, 28);
				char_literal126=(IToken)Match(input,94,Follow._94_in_class_args1465); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_94.Add(char_literal126);



				{
				// AST REWRITE
				// elements: func_args
				// 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();
				// 285:32: -> func_args
				{
					DebugLocation(285, 35);
					adaptor.AddChild(root_0, stream_func_args.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:286:7: ( WS )* ')'
				{
				DebugLocation(286, 7);
				// SugarCpp.g:286:7: ( WS )*
				try { DebugEnterSubRule(80);
				while (true)
				{
					int alt80=2;
					try { DebugEnterDecision(80, false);
					int LA80_0 = input.LA(1);

					if ((LA80_0==WS))
					{
						alt80 = 1;
					}


					} finally { DebugExitDecision(80); }
					switch ( alt80 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:286:7: WS
						{
						DebugLocation(286, 7);
						WS127=(IToken)Match(input,WS,Follow._WS_in_class_args1477); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS127);


						}
						break;

					default:
						goto loop80;
					}
				}

				loop80:
					;

				} finally { DebugExitSubRule(80); }

				DebugLocation(286, 11);
				char_literal128=(IToken)Match(input,94,Follow._94_in_class_args1480); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_94.Add(char_literal128);



				{
				// AST REWRITE
				// elements: 
				// 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();
				// 286:15: -> ^( Func_Args )
				{
					DebugLocation(286, 18);
					// SugarCpp.g:286:18: ^( Func_Args )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(286, 20);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Func_Args, "Func_Args"), root_1);

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(81); }


			}

			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("class_args", 14);
			LeaveRule("class_args", 14);
			LeaveRule_class_args();
		}
		DebugLocation(288, 1);
		} finally { DebugExitRule(GrammarFileName, "class_args"); }
		return retval;

	}
Пример #13
0
	private AstParserRuleReturnScope<CommonTree, IToken> namespace_def()
	{
		EnterRule_namespace_def();
		EnterRule("namespace_def", 13);
		TraceIn("namespace_def", 13);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal113 = default(IToken);
		IToken WS114 = default(IToken);
		IToken WS116 = default(IToken);
		IToken NEWLINE117 = default(IToken);
		IToken INDENT118 = default(IToken);
		IToken NEWLINE119 = default(IToken);
		IToken DEDENT121 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute112 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident115 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> global_block120 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal113_tree = default(CommonTree);
		CommonTree WS114_tree = default(CommonTree);
		CommonTree WS116_tree = default(CommonTree);
		CommonTree NEWLINE117_tree = default(CommonTree);
		CommonTree INDENT118_tree = default(CommonTree);
		CommonTree NEWLINE119_tree = default(CommonTree);
		CommonTree DEDENT121_tree = default(CommonTree);
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_DEDENT=new RewriteRuleITokenStream(adaptor,"token DEDENT");
		RewriteRuleITokenStream stream_NEWLINE=new RewriteRuleITokenStream(adaptor,"token NEWLINE");
		RewriteRuleITokenStream stream_159=new RewriteRuleITokenStream(adaptor,"token 159");
		RewriteRuleITokenStream stream_INDENT=new RewriteRuleITokenStream(adaptor,"token INDENT");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		RewriteRuleSubtreeStream stream_global_block=new RewriteRuleSubtreeStream(adaptor,"rule global_block");
		try { DebugEnterRule(GrammarFileName, "namespace_def");
		DebugLocation(280, 1);
		try
		{
			// SugarCpp.g:281:2: ( ( attribute )? 'namespace' ( WS )* ident ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )? -> ^( Namespace ( attribute )? ident ( global_block )? ) )
			DebugEnterAlt(1);
			// SugarCpp.g:281:4: ( attribute )? 'namespace' ( WS )* ident ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
			{
			DebugLocation(281, 4);
			// SugarCpp.g:281:4: ( attribute )?
			int alt72=2;
			try { DebugEnterSubRule(72);
			try { DebugEnterDecision(72, false);
			int LA72_0 = input.LA(1);

			if ((LA72_0==132))
			{
				alt72 = 1;
			}
			} finally { DebugExitDecision(72); }
			switch (alt72)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:281:4: attribute
				{
				DebugLocation(281, 4);
				PushFollow(Follow._attribute_in_namespace_def1402);
				attribute112=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute112.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(72); }

			DebugLocation(281, 15);
			string_literal113=(IToken)Match(input,159,Follow._159_in_namespace_def1405); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_159.Add(string_literal113);

			DebugLocation(281, 27);
			// SugarCpp.g:281:27: ( WS )*
			try { DebugEnterSubRule(73);
			while (true)
			{
				int alt73=2;
				try { DebugEnterDecision(73, false);
				int LA73_0 = input.LA(1);

				if ((LA73_0==WS))
				{
					alt73 = 1;
				}


				} finally { DebugExitDecision(73); }
				switch ( alt73 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:281:27: WS
					{
					DebugLocation(281, 27);
					WS114=(IToken)Match(input,WS,Follow._WS_in_namespace_def1407); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS114);


					}
					break;

				default:
					goto loop73;
				}
			}

			loop73:
				;

			} finally { DebugExitSubRule(73); }

			DebugLocation(281, 31);
			PushFollow(Follow._ident_in_namespace_def1410);
			ident115=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident115.Tree);
			DebugLocation(281, 37);
			// SugarCpp.g:281:37: ( ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT )?
			int alt77=2;
			try { DebugEnterSubRule(77);
			try { DebugEnterDecision(77, false);
			try
			{
				alt77 = dfa77.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(77); }
			switch (alt77)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:281:38: ( WS )* ( NEWLINE )+ INDENT ( NEWLINE )* global_block DEDENT
				{
				DebugLocation(281, 38);
				// SugarCpp.g:281:38: ( WS )*
				try { DebugEnterSubRule(74);
				while (true)
				{
					int alt74=2;
					try { DebugEnterDecision(74, false);
					int LA74_0 = input.LA(1);

					if ((LA74_0==WS))
					{
						alt74 = 1;
					}


					} finally { DebugExitDecision(74); }
					switch ( alt74 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:281:38: WS
						{
						DebugLocation(281, 38);
						WS116=(IToken)Match(input,WS,Follow._WS_in_namespace_def1413); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS116);


						}
						break;

					default:
						goto loop74;
					}
				}

				loop74:
					;

				} finally { DebugExitSubRule(74); }

				DebugLocation(281, 42);
				// SugarCpp.g:281:42: ( NEWLINE )+
				int cnt75=0;
				try { DebugEnterSubRule(75);
				while (true)
				{
					int alt75=2;
					try { DebugEnterDecision(75, false);
					int LA75_0 = input.LA(1);

					if ((LA75_0==NEWLINE))
					{
						alt75 = 1;
					}


					} finally { DebugExitDecision(75); }
					switch (alt75)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:281:42: NEWLINE
						{
						DebugLocation(281, 42);
						NEWLINE117=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_namespace_def1416); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE117);


						}
						break;

					default:
						if (cnt75 >= 1)
							goto loop75;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee75 = new EarlyExitException( 75, input );
						DebugRecognitionException(eee75);
						throw eee75;
					}
					cnt75++;
				}
				loop75:
					;

				} finally { DebugExitSubRule(75); }

				DebugLocation(281, 51);
				INDENT118=(IToken)Match(input,INDENT,Follow._INDENT_in_namespace_def1419); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_INDENT.Add(INDENT118);

				DebugLocation(281, 58);
				// SugarCpp.g:281:58: ( NEWLINE )*
				try { DebugEnterSubRule(76);
				while (true)
				{
					int alt76=2;
					try { DebugEnterDecision(76, false);
					int LA76_0 = input.LA(1);

					if ((LA76_0==NEWLINE))
					{
						alt76 = 1;
					}


					} finally { DebugExitDecision(76); }
					switch ( alt76 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:281:58: NEWLINE
						{
						DebugLocation(281, 58);
						NEWLINE119=(IToken)Match(input,NEWLINE,Follow._NEWLINE_in_namespace_def1421); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_NEWLINE.Add(NEWLINE119);


						}
						break;

					default:
						goto loop76;
					}
				}

				loop76:
					;

				} finally { DebugExitSubRule(76); }

				DebugLocation(281, 67);
				PushFollow(Follow._global_block_in_namespace_def1424);
				global_block120=global_block();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_global_block.Add(global_block120.Tree);
				DebugLocation(281, 80);
				DEDENT121=(IToken)Match(input,DEDENT,Follow._DEDENT_in_namespace_def1426); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_DEDENT.Add(DEDENT121);


				}
				break;

			}
			} finally { DebugExitSubRule(77); }



			{
			// AST REWRITE
			// elements: ident, attribute, global_block
			// 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();
			// 281:89: -> ^( Namespace ( attribute )? ident ( global_block )? )
			{
				DebugLocation(281, 92);
				// SugarCpp.g:281:92: ^( Namespace ( attribute )? ident ( global_block )? )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(281, 94);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Namespace, "Namespace"), root_1);

				DebugLocation(281, 104);
				// SugarCpp.g:281:104: ( attribute )?
				if (stream_attribute.HasNext)
				{
					DebugLocation(281, 104);
					adaptor.AddChild(root_1, stream_attribute.NextTree());

				}
				stream_attribute.Reset();
				DebugLocation(281, 115);
				adaptor.AddChild(root_1, stream_ident.NextTree());
				DebugLocation(281, 121);
				// SugarCpp.g:281:121: ( global_block )?
				if (stream_global_block.HasNext)
				{
					DebugLocation(281, 121);
					adaptor.AddChild(root_1, stream_global_block.NextTree());

				}
				stream_global_block.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("namespace_def", 13);
			LeaveRule("namespace_def", 13);
			LeaveRule_namespace_def();
		}
		DebugLocation(282, 1);
		} finally { DebugExitRule(GrammarFileName, "namespace_def"); }
		return retval;

	}
Пример #14
0
	private AstParserRuleReturnScope<CommonTree, IToken> enum_def()
	{
		EnterRule_enum_def();
		EnterRule("enum_def", 12);
		TraceIn("enum_def", 12);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken string_literal101 = default(IToken);
		IToken WS102 = default(IToken);
		IToken WS104 = default(IToken);
		IToken char_literal105 = default(IToken);
		IToken WS106 = default(IToken);
		IToken WS108 = default(IToken);
		IToken char_literal109 = default(IToken);
		IToken WS110 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute100 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident103 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident107 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident111 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree string_literal101_tree = default(CommonTree);
		CommonTree WS102_tree = default(CommonTree);
		CommonTree WS104_tree = default(CommonTree);
		CommonTree char_literal105_tree = default(CommonTree);
		CommonTree WS106_tree = default(CommonTree);
		CommonTree WS108_tree = default(CommonTree);
		CommonTree char_literal109_tree = default(CommonTree);
		CommonTree WS110_tree = default(CommonTree);
		RewriteRuleITokenStream stream_182=new RewriteRuleITokenStream(adaptor,"token 182");
		RewriteRuleITokenStream stream_146=new RewriteRuleITokenStream(adaptor,"token 146");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_121=new RewriteRuleITokenStream(adaptor,"token 121");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		RewriteRuleSubtreeStream stream_attribute=new RewriteRuleSubtreeStream(adaptor,"rule attribute");
		try { DebugEnterRule(GrammarFileName, "enum_def");
		DebugLocation(276, 1);
		try
		{
			// SugarCpp.g:277:2: ( ( attribute )? 'enum' ( WS )* ident ( WS )* '=' ( ( WS )* ident ( ( WS )* '|' ( WS )* ident )* )? -> ^( Enum ( attribute )? ident ^( Ident_List ( ident )* ) ) )
			DebugEnterAlt(1);
			// SugarCpp.g:277:4: ( attribute )? 'enum' ( WS )* ident ( WS )* '=' ( ( WS )* ident ( ( WS )* '|' ( WS )* ident )* )?
			{
			DebugLocation(277, 4);
			// SugarCpp.g:277:4: ( attribute )?
			int alt64=2;
			try { DebugEnterSubRule(64);
			try { DebugEnterDecision(64, false);
			int LA64_0 = input.LA(1);

			if ((LA64_0==132))
			{
				alt64 = 1;
			}
			} finally { DebugExitDecision(64); }
			switch (alt64)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:277:4: attribute
				{
				DebugLocation(277, 4);
				PushFollow(Follow._attribute_in_enum_def1339);
				attribute100=attribute();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_attribute.Add(attribute100.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(64); }

			DebugLocation(277, 15);
			string_literal101=(IToken)Match(input,146,Follow._146_in_enum_def1342); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_146.Add(string_literal101);

			DebugLocation(277, 22);
			// SugarCpp.g:277:22: ( WS )*
			try { DebugEnterSubRule(65);
			while (true)
			{
				int alt65=2;
				try { DebugEnterDecision(65, false);
				int LA65_0 = input.LA(1);

				if ((LA65_0==WS))
				{
					alt65 = 1;
				}


				} finally { DebugExitDecision(65); }
				switch ( alt65 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:277:22: WS
					{
					DebugLocation(277, 22);
					WS102=(IToken)Match(input,WS,Follow._WS_in_enum_def1344); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS102);


					}
					break;

				default:
					goto loop65;
				}
			}

			loop65:
				;

			} finally { DebugExitSubRule(65); }

			DebugLocation(277, 26);
			PushFollow(Follow._ident_in_enum_def1347);
			ident103=ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_ident.Add(ident103.Tree);
			DebugLocation(277, 32);
			// SugarCpp.g:277:32: ( WS )*
			try { DebugEnterSubRule(66);
			while (true)
			{
				int alt66=2;
				try { DebugEnterDecision(66, false);
				int LA66_0 = input.LA(1);

				if ((LA66_0==WS))
				{
					alt66 = 1;
				}


				} finally { DebugExitDecision(66); }
				switch ( alt66 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:277:32: WS
					{
					DebugLocation(277, 32);
					WS104=(IToken)Match(input,WS,Follow._WS_in_enum_def1349); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS104);


					}
					break;

				default:
					goto loop66;
				}
			}

			loop66:
				;

			} finally { DebugExitSubRule(66); }

			DebugLocation(277, 36);
			char_literal105=(IToken)Match(input,121,Follow._121_in_enum_def1352); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_121.Add(char_literal105);

			DebugLocation(277, 40);
			// SugarCpp.g:277:40: ( ( WS )* ident ( ( WS )* '|' ( WS )* ident )* )?
			int alt71=2;
			try { DebugEnterSubRule(71);
			try { DebugEnterDecision(71, false);
			try
			{
				alt71 = dfa71.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(71); }
			switch (alt71)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:277:41: ( WS )* ident ( ( WS )* '|' ( WS )* ident )*
				{
				DebugLocation(277, 41);
				// SugarCpp.g:277:41: ( WS )*
				try { DebugEnterSubRule(67);
				while (true)
				{
					int alt67=2;
					try { DebugEnterDecision(67, false);
					int LA67_0 = input.LA(1);

					if ((LA67_0==WS))
					{
						alt67 = 1;
					}


					} finally { DebugExitDecision(67); }
					switch ( alt67 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:277:41: WS
						{
						DebugLocation(277, 41);
						WS106=(IToken)Match(input,WS,Follow._WS_in_enum_def1355); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS106);


						}
						break;

					default:
						goto loop67;
					}
				}

				loop67:
					;

				} finally { DebugExitSubRule(67); }

				DebugLocation(277, 45);
				PushFollow(Follow._ident_in_enum_def1358);
				ident107=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident107.Tree);
				DebugLocation(277, 51);
				// SugarCpp.g:277:51: ( ( WS )* '|' ( WS )* ident )*
				try { DebugEnterSubRule(70);
				while (true)
				{
					int alt70=2;
					try { DebugEnterDecision(70, false);
					try
					{
						alt70 = dfa70.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(70); }
					switch ( alt70 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:277:52: ( WS )* '|' ( WS )* ident
						{
						DebugLocation(277, 52);
						// SugarCpp.g:277:52: ( WS )*
						try { DebugEnterSubRule(68);
						while (true)
						{
							int alt68=2;
							try { DebugEnterDecision(68, false);
							int LA68_0 = input.LA(1);

							if ((LA68_0==WS))
							{
								alt68 = 1;
							}


							} finally { DebugExitDecision(68); }
							switch ( alt68 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:277:52: WS
								{
								DebugLocation(277, 52);
								WS108=(IToken)Match(input,WS,Follow._WS_in_enum_def1361); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS108);


								}
								break;

							default:
								goto loop68;
							}
						}

						loop68:
							;

						} finally { DebugExitSubRule(68); }

						DebugLocation(277, 56);
						char_literal109=(IToken)Match(input,182,Follow._182_in_enum_def1364); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_182.Add(char_literal109);

						DebugLocation(277, 60);
						// SugarCpp.g:277:60: ( WS )*
						try { DebugEnterSubRule(69);
						while (true)
						{
							int alt69=2;
							try { DebugEnterDecision(69, false);
							int LA69_0 = input.LA(1);

							if ((LA69_0==WS))
							{
								alt69 = 1;
							}


							} finally { DebugExitDecision(69); }
							switch ( alt69 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:277:60: WS
								{
								DebugLocation(277, 60);
								WS110=(IToken)Match(input,WS,Follow._WS_in_enum_def1366); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS110);


								}
								break;

							default:
								goto loop69;
							}
						}

						loop69:
							;

						} finally { DebugExitSubRule(69); }

						DebugLocation(277, 64);
						PushFollow(Follow._ident_in_enum_def1369);
						ident111=ident();
						PopFollow();
						if (state.failed) return retval;
						if (state.backtracking == 0) stream_ident.Add(ident111.Tree);

						}
						break;

					default:
						goto loop70;
					}
				}

				loop70:
					;

				} finally { DebugExitSubRule(70); }


				}
				break;

			}
			} finally { DebugExitSubRule(71); }



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

			root_0 = (CommonTree)adaptor.Nil();
			// 277:74: -> ^( Enum ( attribute )? ident ^( Ident_List ( ident )* ) )
			{
				DebugLocation(277, 77);
				// SugarCpp.g:277:77: ^( Enum ( attribute )? ident ^( Ident_List ( ident )* ) )
				{
				CommonTree root_1 = (CommonTree)adaptor.Nil();
				DebugLocation(277, 79);
				root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Enum, "Enum"), root_1);

				DebugLocation(277, 84);
				// SugarCpp.g:277:84: ( attribute )?
				if (stream_attribute.HasNext)
				{
					DebugLocation(277, 84);
					adaptor.AddChild(root_1, stream_attribute.NextTree());

				}
				stream_attribute.Reset();
				DebugLocation(277, 95);
				adaptor.AddChild(root_1, stream_ident.NextTree());
				DebugLocation(277, 101);
				// SugarCpp.g:277:101: ^( Ident_List ( ident )* )
				{
				CommonTree root_2 = (CommonTree)adaptor.Nil();
				DebugLocation(277, 103);
				root_2 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Ident_List, "Ident_List"), root_2);

				DebugLocation(277, 114);
				// SugarCpp.g:277:114: ( ident )*
				while ( stream_ident.HasNext )
				{
					DebugLocation(277, 114);
					adaptor.AddChild(root_2, stream_ident.NextTree());

				}
				stream_ident.Reset();

				adaptor.AddChild(root_1, root_2);
				}

				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("enum_def", 12);
			LeaveRule("enum_def", 12);
			LeaveRule_enum_def();
		}
		DebugLocation(278, 1);
		} finally { DebugExitRule(GrammarFileName, "enum_def"); }
		return retval;

	}
Пример #15
0
	private AstParserRuleReturnScope<object, IToken> orderby_expr()
	{
		EnterRule_orderby_expr();
		EnterRule("orderby_expr", 20);
		TraceIn("orderby_expr", 20);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		AstParserRuleReturnScope<object, IToken> exp84 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> sortorder_operator85 = default(AstParserRuleReturnScope<object, IToken>);

		RewriteRuleSubtreeStream stream_exp=new RewriteRuleSubtreeStream(adaptor,"rule exp");
		RewriteRuleSubtreeStream stream_sortorder_operator=new RewriteRuleSubtreeStream(adaptor,"rule sortorder_operator");
		try { DebugEnterRule(GrammarFileName, "orderby_expr");
		DebugLocation(184, 1);
		try
		{
			// Queries\\PomonaQuery.g:185:2: ( exp ( sortorder_operator )? -> ^( ORDERBY_ASC exp ( sortorder_operator )? ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:185:4: exp ( sortorder_operator )?
			{
			DebugLocation(185, 4);
			PushFollow(Follow._exp_in_orderby_expr1167);
			exp84=exp();
			PopFollow();

			stream_exp.Add(exp84.Tree);
			DebugLocation(185, 8);
			// Queries\\PomonaQuery.g:185:8: ( sortorder_operator )?
			int alt27=2;
			try { DebugEnterSubRule(27);
			try { DebugEnterDecision(27, false);
			int LA27_1 = input.LA(1);

			if (((LA27_1>=62 && LA27_1<=63)))
			{
				alt27 = 1;
			}
			} finally { DebugExitDecision(27); }
			switch (alt27)
			{
			case 1:
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:185:9: sortorder_operator
				{
				DebugLocation(185, 9);
				PushFollow(Follow._sortorder_operator_in_orderby_expr1170);
				sortorder_operator85=sortorder_operator();
				PopFollow();

				stream_sortorder_operator.Add(sortorder_operator85.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(27); }



			{
			// AST REWRITE
			// elements: exp, sortorder_operator
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 185:30: -> ^( ORDERBY_ASC exp ( sortorder_operator )? )
			{
				DebugLocation(185, 33);
				// Queries\\PomonaQuery.g:185:33: ^( ORDERBY_ASC exp ( sortorder_operator )? )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(185, 35);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(ORDERBY_ASC, "ORDERBY_ASC"), root_1);

				DebugLocation(185, 47);
				adaptor.AddChild(root_1, stream_exp.NextTree());
				DebugLocation(185, 51);
				// Queries\\PomonaQuery.g:185:51: ( sortorder_operator )?
				if (stream_sortorder_operator.HasNext)
				{
					DebugLocation(185, 51);
					adaptor.AddChild(root_1, stream_sortorder_operator.NextTree());

				}
				stream_sortorder_operator.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("orderby_expr", 20);
			LeaveRule("orderby_expr", 20);
			LeaveRule_orderby_expr();
		}
		DebugLocation(186, 1);
		} finally { DebugExitRule(GrammarFileName, "orderby_expr"); }
		return retval;

	}
Пример #16
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_no_array()
	{
		EnterRule_type_no_array();
		EnterRule("type_no_array", 19);
		TraceIn("type_no_array", 19);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS215 = default(IToken);
		IToken char_literal216 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_star214 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS215_tree = default(CommonTree);
		CommonTree char_literal216_tree = default(CommonTree);
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_91=new RewriteRuleITokenStream(adaptor,"token 91");
		RewriteRuleSubtreeStream stream_type_star=new RewriteRuleSubtreeStream(adaptor,"rule type_star");
		try { DebugEnterRule(GrammarFileName, "type_no_array");
		DebugLocation(316, 1);
		try
		{
			// SugarCpp.g:317:2: ( type_star ( ( WS )* '&' -> ^( Type_Ref type_star ) | -> type_star ) )
			DebugEnterAlt(1);
			// SugarCpp.g:317:4: type_star ( ( WS )* '&' -> ^( Type_Ref type_star ) | -> type_star )
			{
			DebugLocation(317, 4);
			PushFollow(Follow._type_star_in_type_no_array2039);
			type_star214=type_star();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_star.Add(type_star214.Tree);
			DebugLocation(317, 14);
			// SugarCpp.g:317:14: ( ( WS )* '&' -> ^( Type_Ref type_star ) | -> type_star )
			int alt142=2;
			try { DebugEnterSubRule(142);
			try { DebugEnterDecision(142, false);
			try
			{
				alt142 = dfa142.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(142); }
			switch (alt142)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:317:16: ( WS )* '&'
				{
				DebugLocation(317, 16);
				// SugarCpp.g:317:16: ( WS )*
				try { DebugEnterSubRule(141);
				while (true)
				{
					int alt141=2;
					try { DebugEnterDecision(141, false);
					int LA141_0 = input.LA(1);

					if ((LA141_0==WS))
					{
						alt141 = 1;
					}


					} finally { DebugExitDecision(141); }
					switch ( alt141 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:317:16: WS
						{
						DebugLocation(317, 16);
						WS215=(IToken)Match(input,WS,Follow._WS_in_type_no_array2043); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS215);


						}
						break;

					default:
						goto loop141;
					}
				}

				loop141:
					;

				} finally { DebugExitSubRule(141); }

				DebugLocation(317, 20);
				char_literal216=(IToken)Match(input,91,Follow._91_in_type_no_array2046); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_91.Add(char_literal216);



				{
				// AST REWRITE
				// elements: type_star
				// 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();
				// 317:24: -> ^( Type_Ref type_star )
				{
					DebugLocation(317, 27);
					// SugarCpp.g:317:27: ^( Type_Ref type_star )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(317, 29);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Ref, "Type_Ref"), root_1);

					DebugLocation(317, 38);
					adaptor.AddChild(root_1, stream_type_star.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:318:7: 
				{

				{
				// AST REWRITE
				// elements: type_star
				// 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();
				// 318:7: -> type_star
				{
					DebugLocation(318, 10);
					adaptor.AddChild(root_0, stream_type_star.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(142); }


			}

			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("type_no_array", 19);
			LeaveRule("type_no_array", 19);
			LeaveRule_type_no_array();
		}
		DebugLocation(320, 1);
		} finally { DebugExitRule(GrammarFileName, "type_no_array"); }
		return retval;

	}
Пример #17
0
	private AstParserRuleReturnScope<object, IToken> lambda_expression()
	{
		EnterRule_lambda_expression();
		EnterRule("lambda_expression", 4);
		TraceIn("lambda_expression", 4);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken char_literal8 = default(IToken);
		AstParserRuleReturnScope<object, IToken> or_expression7 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> or_expression9 = default(AstParserRuleReturnScope<object, IToken>);

		object char_literal8_tree = default(object);
		RewriteRuleITokenStream stream_51=new RewriteRuleITokenStream(adaptor,"token 51");
		RewriteRuleSubtreeStream stream_or_expression=new RewriteRuleSubtreeStream(adaptor,"rule or_expression");
		try { DebugEnterRule(GrammarFileName, "lambda_expression");
		DebugLocation(89, 1);
		try
		{
			// Queries\\PomonaQuery.g:90:2: ( or_expression ( ':' or_expression )? -> ^( LAMBDA_OP ( or_expression )+ ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:90:4: or_expression ( ':' or_expression )?
			{
			DebugLocation(90, 4);
			PushFollow(Follow._or_expression_in_lambda_expression559);
			or_expression7=or_expression();
			PopFollow();

			stream_or_expression.Add(or_expression7.Tree);
			DebugLocation(90, 18);
			// Queries\\PomonaQuery.g:90:18: ( ':' or_expression )?
			int alt2=2;
			try { DebugEnterSubRule(2);
			try { DebugEnterDecision(2, false);
			int LA2_1 = input.LA(1);

			if ((LA2_1==51))
			{
				alt2 = 1;
			}
			} finally { DebugExitDecision(2); }
			switch (alt2)
			{
			case 1:
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:90:20: ':' or_expression
				{
				DebugLocation(90, 20);
				char_literal8=(IToken)Match(input,51,Follow._51_in_lambda_expression563);  
				stream_51.Add(char_literal8);

				DebugLocation(90, 24);
				PushFollow(Follow._or_expression_in_lambda_expression565);
				or_expression9=or_expression();
				PopFollow();

				stream_or_expression.Add(or_expression9.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(2); }



			{
			// AST REWRITE
			// elements: or_expression
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 90:41: -> ^( LAMBDA_OP ( or_expression )+ )
			{
				DebugLocation(90, 44);
				// Queries\\PomonaQuery.g:90:44: ^( LAMBDA_OP ( or_expression )+ )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(90, 46);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(LAMBDA_OP, "LAMBDA_OP"), root_1);

				DebugLocation(90, 56);
				if (!(stream_or_expression.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_or_expression.HasNext )
				{
					DebugLocation(90, 56);
					adaptor.AddChild(root_1, stream_or_expression.NextTree());

				}
				stream_or_expression.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("lambda_expression", 4);
			LeaveRule("lambda_expression", 4);
			LeaveRule_lambda_expression();
		}
		DebugLocation(91, 1);
		} finally { DebugExitRule(GrammarFileName, "lambda_expression"); }
		return retval;

	}
Пример #18
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_star()
	{
		EnterRule_type_star();
		EnterRule("type_star", 20);
		TraceIn("type_star", 20);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken WS218 = default(IToken);
		IToken char_literal219 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_template_type217 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree WS218_tree = default(CommonTree);
		CommonTree char_literal219_tree = default(CommonTree);
		RewriteRuleITokenStream stream_95=new RewriteRuleITokenStream(adaptor,"token 95");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleSubtreeStream stream_type_template_type=new RewriteRuleSubtreeStream(adaptor,"rule type_template_type");
		try { DebugEnterRule(GrammarFileName, "type_star");
		DebugLocation(322, 1);
		try
		{
			// SugarCpp.g:323:2: ( type_template_type ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type ) )
			DebugEnterAlt(1);
			// SugarCpp.g:323:4: type_template_type ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type )
			{
			DebugLocation(323, 4);
			PushFollow(Follow._type_template_type_in_type_star2081);
			type_template_type217=type_template_type();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_template_type.Add(type_template_type217.Tree);
			DebugLocation(323, 23);
			// SugarCpp.g:323:23: ( ( ( WS )* '*' )+ -> ^( Type_Star type_template_type ( '*' )+ ) | -> type_template_type )
			int alt145=2;
			try { DebugEnterSubRule(145);
			try { DebugEnterDecision(145, false);
			try
			{
				alt145 = dfa145.Predict(input);
			}
			catch (NoViableAltException nvae)
			{
				DebugRecognitionException(nvae);
				throw;
			}
			} finally { DebugExitDecision(145); }
			switch (alt145)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:323:25: ( ( WS )* '*' )+
				{
				DebugLocation(323, 25);
				// SugarCpp.g:323:25: ( ( WS )* '*' )+
				int cnt144=0;
				try { DebugEnterSubRule(144);
				while (true)
				{
					int alt144=2;
					try { DebugEnterDecision(144, false);
					try
					{
						alt144 = dfa144.Predict(input);
					}
					catch (NoViableAltException nvae)
					{
						DebugRecognitionException(nvae);
						throw;
					}
					} finally { DebugExitDecision(144); }
					switch (alt144)
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:323:26: ( WS )* '*'
						{
						DebugLocation(323, 26);
						// SugarCpp.g:323:26: ( WS )*
						try { DebugEnterSubRule(143);
						while (true)
						{
							int alt143=2;
							try { DebugEnterDecision(143, false);
							int LA143_0 = input.LA(1);

							if ((LA143_0==WS))
							{
								alt143 = 1;
							}


							} finally { DebugExitDecision(143); }
							switch ( alt143 )
							{
							case 1:
								DebugEnterAlt(1);
								// SugarCpp.g:323:26: WS
								{
								DebugLocation(323, 26);
								WS218=(IToken)Match(input,WS,Follow._WS_in_type_star2086); if (state.failed) return retval; 
								if (state.backtracking == 0) stream_WS.Add(WS218);


								}
								break;

							default:
								goto loop143;
							}
						}

						loop143:
							;

						} finally { DebugExitSubRule(143); }

						DebugLocation(323, 30);
						char_literal219=(IToken)Match(input,95,Follow._95_in_type_star2089); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_95.Add(char_literal219);


						}
						break;

					default:
						if (cnt144 >= 1)
							goto loop144;

						if (state.backtracking>0) {state.failed=true; return retval;}
						EarlyExitException eee144 = new EarlyExitException( 144, input );
						DebugRecognitionException(eee144);
						throw eee144;
					}
					cnt144++;
				}
				loop144:
					;

				} finally { DebugExitSubRule(144); }



				{
				// AST REWRITE
				// elements: type_template_type, 95
				// 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();
				// 323:36: -> ^( Type_Star type_template_type ( '*' )+ )
				{
					DebugLocation(323, 39);
					// SugarCpp.g:323:39: ^( Type_Star type_template_type ( '*' )+ )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(323, 41);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Star, "Type_Star"), root_1);

					DebugLocation(323, 51);
					adaptor.AddChild(root_1, stream_type_template_type.NextTree());
					DebugLocation(323, 70);
					if (!(stream_95.HasNext))
					{
						throw new RewriteEarlyExitException();
					}
					while ( stream_95.HasNext )
					{
						DebugLocation(323, 70);
						adaptor.AddChild(root_1, stream_95.NextNode());

					}
					stream_95.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:324:10: 
				{

				{
				// AST REWRITE
				// elements: type_template_type
				// 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();
				// 324:10: -> type_template_type
				{
					DebugLocation(324, 13);
					adaptor.AddChild(root_0, stream_type_template_type.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(145); }


			}

			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("type_star", 20);
			LeaveRule("type_star", 20);
			LeaveRule_type_star();
		}
		DebugLocation(326, 1);
		} finally { DebugExitRule(GrammarFileName, "type_star"); }
		return retval;

	}
Пример #19
0
	private AstParserRuleReturnScope<object, IToken> and_expression()
	{
		EnterRule_and_expression();
		EnterRule("and_expression", 7);
		TraceIn("and_expression", 7);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		AstParserRuleReturnScope<object, IToken> relational_expr15 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> and_operator16 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> relational_expr17 = default(AstParserRuleReturnScope<object, IToken>);

		RewriteRuleSubtreeStream stream_relational_expr=new RewriteRuleSubtreeStream(adaptor,"rule relational_expr");
		RewriteRuleSubtreeStream stream_and_operator=new RewriteRuleSubtreeStream(adaptor,"rule and_operator");
		try { DebugEnterRule(GrammarFileName, "and_expression");
		DebugLocation(101, 1);
		try
		{
			// Queries\\PomonaQuery.g:102:2: ( relational_expr ( and_operator relational_expr )* -> ^( AND_OP ( relational_expr )+ ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:102:4: relational_expr ( and_operator relational_expr )*
			{
			DebugLocation(102, 4);
			PushFollow(Follow._relational_expr_in_and_expression637);
			relational_expr15=relational_expr();
			PopFollow();

			stream_relational_expr.Add(relational_expr15.Tree);
			DebugLocation(102, 20);
			// Queries\\PomonaQuery.g:102:20: ( and_operator relational_expr )*
			try { DebugEnterSubRule(5);
			while (true)
			{
				int alt5=2;
				try { DebugEnterDecision(5, false);
				int LA5_1 = input.LA(1);

				if ((LA5_1==42||LA5_1==60))
				{
					alt5 = 1;
				}


				} finally { DebugExitDecision(5); }
				switch ( alt5 )
				{
				case 1:
					DebugEnterAlt(1);
					// Queries\\PomonaQuery.g:102:22: and_operator relational_expr
					{
					DebugLocation(102, 22);
					PushFollow(Follow._and_operator_in_and_expression641);
					and_operator16=and_operator();
					PopFollow();

					stream_and_operator.Add(and_operator16.Tree);
					DebugLocation(102, 35);
					PushFollow(Follow._relational_expr_in_and_expression643);
					relational_expr17=relational_expr();
					PopFollow();

					stream_relational_expr.Add(relational_expr17.Tree);

					}
					break;

				default:
					goto loop5;
				}
			}

			loop5:
				;

			} finally { DebugExitSubRule(5); }



			{
			// AST REWRITE
			// elements: relational_expr
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 102:54: -> ^( AND_OP ( relational_expr )+ )
			{
				DebugLocation(102, 57);
				// Queries\\PomonaQuery.g:102:57: ^( AND_OP ( relational_expr )+ )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(102, 59);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(AND_OP, "AND_OP"), root_1);

				DebugLocation(102, 66);
				if (!(stream_relational_expr.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_relational_expr.HasNext )
				{
					DebugLocation(102, 66);
					adaptor.AddChild(root_1, stream_relational_expr.NextTree());

				}
				stream_relational_expr.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("and_expression", 7);
			LeaveRule("and_expression", 7);
			LeaveRule_and_expression();
		}
		DebugLocation(103, 1);
		} finally { DebugExitRule(GrammarFileName, "and_expression"); }
		return retval;

	}
Пример #20
0
	private AstParserRuleReturnScope<CommonTree, IToken> type_template_type()
	{
		EnterRule_type_template_type();
		EnterRule("type_template_type", 21);
		TraceIn("type_template_type", 21);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken char_literal221 = default(IToken);
		IToken WS222 = default(IToken);
		IToken WS224 = default(IToken);
		IToken char_literal225 = default(IToken);
		IToken WS226 = default(IToken);
		IToken WS228 = default(IToken);
		IToken char_literal229 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> type_ident220 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name223 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> type_name227 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal221_tree = default(CommonTree);
		CommonTree WS222_tree = default(CommonTree);
		CommonTree WS224_tree = default(CommonTree);
		CommonTree char_literal225_tree = default(CommonTree);
		CommonTree WS226_tree = default(CommonTree);
		CommonTree WS228_tree = default(CommonTree);
		CommonTree char_literal229_tree = default(CommonTree);
		RewriteRuleITokenStream stream_125=new RewriteRuleITokenStream(adaptor,"token 125");
		RewriteRuleITokenStream stream_115=new RewriteRuleITokenStream(adaptor,"token 115");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_type_name=new RewriteRuleSubtreeStream(adaptor,"rule type_name");
		RewriteRuleSubtreeStream stream_type_ident=new RewriteRuleSubtreeStream(adaptor,"rule type_ident");
		try { DebugEnterRule(GrammarFileName, "type_template_type");
		DebugLocation(328, 1);
		try
		{
			// SugarCpp.g:329:2: ( type_ident ( '<' ( ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )* )? ( WS )* '>' -> ^( Type_Template type_ident ( type_name )* ) | -> type_ident ) )
			DebugEnterAlt(1);
			// SugarCpp.g:329:4: type_ident ( '<' ( ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )* )? ( WS )* '>' -> ^( Type_Template type_ident ( type_name )* ) | -> type_ident )
			{
			DebugLocation(329, 4);
			PushFollow(Follow._type_ident_in_type_template_type2135);
			type_ident220=type_ident();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_type_ident.Add(type_ident220.Tree);
			DebugLocation(329, 15);
			// SugarCpp.g:329:15: ( '<' ( ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )* )? ( WS )* '>' -> ^( Type_Template type_ident ( type_name )* ) | -> type_ident )
			int alt152=2;
			try { DebugEnterSubRule(152);
			try { DebugEnterDecision(152, false);
			int LA152_0 = input.LA(1);

			if ((LA152_0==115))
			{
				alt152 = 1;
			}
			else if ((LA152_0==DEDENT||(LA152_0>=IDENT && LA152_0<=INDENT)||LA152_0==NEWLINE||LA152_0==WS||LA152_0==91||(LA152_0>=93 && LA152_0<=95)||LA152_0==100||LA152_0==105||(LA152_0>=113 && LA152_0<=114)||LA152_0==121||(LA152_0>=124 && LA152_0<=125)||(LA152_0>=132 && LA152_0<=133)||LA152_0==138||LA152_0==144||(LA152_0>=149 && LA152_0<=150)||LA152_0==152||LA152_0==165||LA152_0==169||(LA152_0>=171 && LA152_0<=172)||(LA152_0>=175 && LA152_0<=176)||(LA152_0>=180 && LA152_0<=181)||LA152_0==186))
			{
				alt152 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 152, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(152); }
			switch (alt152)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:329:17: '<' ( ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )* )? ( WS )* '>'
				{
				DebugLocation(329, 17);
				char_literal221=(IToken)Match(input,115,Follow._115_in_type_template_type2139); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_115.Add(char_literal221);

				DebugLocation(329, 21);
				// SugarCpp.g:329:21: ( ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )* )?
				int alt150=2;
				try { DebugEnterSubRule(150);
				try { DebugEnterDecision(150, false);
				try
				{
					alt150 = dfa150.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(150); }
				switch (alt150)
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:329:22: ( WS )* type_name ( ( WS )* ',' ( WS )* type_name )*
					{
					DebugLocation(329, 22);
					// SugarCpp.g:329:22: ( WS )*
					try { DebugEnterSubRule(146);
					while (true)
					{
						int alt146=2;
						try { DebugEnterDecision(146, false);
						int LA146_0 = input.LA(1);

						if ((LA146_0==WS))
						{
							alt146 = 1;
						}


						} finally { DebugExitDecision(146); }
						switch ( alt146 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:329:22: WS
							{
							DebugLocation(329, 22);
							WS222=(IToken)Match(input,WS,Follow._WS_in_type_template_type2142); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS222);


							}
							break;

						default:
							goto loop146;
						}
					}

					loop146:
						;

					} finally { DebugExitSubRule(146); }

					DebugLocation(329, 26);
					PushFollow(Follow._type_name_in_type_template_type2145);
					type_name223=type_name();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_type_name.Add(type_name223.Tree);
					DebugLocation(329, 36);
					// SugarCpp.g:329:36: ( ( WS )* ',' ( WS )* type_name )*
					try { DebugEnterSubRule(149);
					while (true)
					{
						int alt149=2;
						try { DebugEnterDecision(149, false);
						try
						{
							alt149 = dfa149.Predict(input);
						}
						catch (NoViableAltException nvae)
						{
							DebugRecognitionException(nvae);
							throw;
						}
						} finally { DebugExitDecision(149); }
						switch ( alt149 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:329:37: ( WS )* ',' ( WS )* type_name
							{
							DebugLocation(329, 37);
							// SugarCpp.g:329:37: ( WS )*
							try { DebugEnterSubRule(147);
							while (true)
							{
								int alt147=2;
								try { DebugEnterDecision(147, false);
								int LA147_0 = input.LA(1);

								if ((LA147_0==WS))
								{
									alt147 = 1;
								}


								} finally { DebugExitDecision(147); }
								switch ( alt147 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:329:37: WS
									{
									DebugLocation(329, 37);
									WS224=(IToken)Match(input,WS,Follow._WS_in_type_template_type2148); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS224);


									}
									break;

								default:
									goto loop147;
								}
							}

							loop147:
								;

							} finally { DebugExitSubRule(147); }

							DebugLocation(329, 41);
							char_literal225=(IToken)Match(input,100,Follow._100_in_type_template_type2151); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_100.Add(char_literal225);

							DebugLocation(329, 45);
							// SugarCpp.g:329:45: ( WS )*
							try { DebugEnterSubRule(148);
							while (true)
							{
								int alt148=2;
								try { DebugEnterDecision(148, false);
								int LA148_0 = input.LA(1);

								if ((LA148_0==WS))
								{
									alt148 = 1;
								}


								} finally { DebugExitDecision(148); }
								switch ( alt148 )
								{
								case 1:
									DebugEnterAlt(1);
									// SugarCpp.g:329:45: WS
									{
									DebugLocation(329, 45);
									WS226=(IToken)Match(input,WS,Follow._WS_in_type_template_type2153); if (state.failed) return retval; 
									if (state.backtracking == 0) stream_WS.Add(WS226);


									}
									break;

								default:
									goto loop148;
								}
							}

							loop148:
								;

							} finally { DebugExitSubRule(148); }

							DebugLocation(329, 49);
							PushFollow(Follow._type_name_in_type_template_type2156);
							type_name227=type_name();
							PopFollow();
							if (state.failed) return retval;
							if (state.backtracking == 0) stream_type_name.Add(type_name227.Tree);

							}
							break;

						default:
							goto loop149;
						}
					}

					loop149:
						;

					} finally { DebugExitSubRule(149); }


					}
					break;

				}
				} finally { DebugExitSubRule(150); }

				DebugLocation(329, 63);
				// SugarCpp.g:329:63: ( WS )*
				try { DebugEnterSubRule(151);
				while (true)
				{
					int alt151=2;
					try { DebugEnterDecision(151, false);
					int LA151_0 = input.LA(1);

					if ((LA151_0==WS))
					{
						alt151 = 1;
					}


					} finally { DebugExitDecision(151); }
					switch ( alt151 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:329:63: WS
						{
						DebugLocation(329, 63);
						WS228=(IToken)Match(input,WS,Follow._WS_in_type_template_type2162); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS228);


						}
						break;

					default:
						goto loop151;
					}
				}

				loop151:
					;

				} finally { DebugExitSubRule(151); }

				DebugLocation(329, 67);
				char_literal229=(IToken)Match(input,125,Follow._125_in_type_template_type2165); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_125.Add(char_literal229);



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

				root_0 = (CommonTree)adaptor.Nil();
				// 329:71: -> ^( Type_Template type_ident ( type_name )* )
				{
					DebugLocation(329, 74);
					// SugarCpp.g:329:74: ^( Type_Template type_ident ( type_name )* )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(329, 76);
					root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(Type_Template, "Type_Template"), root_1);

					DebugLocation(329, 90);
					adaptor.AddChild(root_1, stream_type_ident.NextTree());
					DebugLocation(329, 101);
					// SugarCpp.g:329:101: ( type_name )*
					while ( stream_type_name.HasNext )
					{
						DebugLocation(329, 101);
						adaptor.AddChild(root_1, stream_type_name.NextTree());

					}
					stream_type_name.Reset();

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:330:8: 
				{

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

				root_0 = (CommonTree)adaptor.Nil();
				// 330:8: -> type_ident
				{
					DebugLocation(330, 11);
					adaptor.AddChild(root_0, stream_type_ident.NextTree());

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			} finally { DebugExitSubRule(152); }


			}

			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("type_template_type", 21);
			LeaveRule("type_template_type", 21);
			LeaveRule_type_template_type();
		}
		DebugLocation(332, 1);
		} finally { DebugExitRule(GrammarFileName, "type_template_type"); }
		return retval;

	}
		// $ANTLR start "relationshipDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:113:1: relationshipDeclaration : 'relationship' name '=' relationshipJoinDeclaration ';' -> ^( RELATIONSHIP name relationshipJoinDeclaration ) ;
		public relationshipDeclaration_return relationshipDeclaration() // throws RecognitionException [1]
		{
			var retval = new relationshipDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken string_literal25 = null;
			IToken char_literal27 = null;
			IToken char_literal29 = null;
			name_return name26 = default( name_return );

			relationshipJoinDeclaration_return relationshipJoinDeclaration28 = default( relationshipJoinDeclaration_return );


			CommonTree string_literal25_tree = null;
			CommonTree char_literal27_tree = null;
			CommonTree char_literal29_tree = null;
			var stream_67 = new RewriteRuleTokenStream( adaptor, "token 67" );
			var stream_68 = new RewriteRuleTokenStream( adaptor, "token 68" );
			var stream_63 = new RewriteRuleTokenStream( adaptor, "token 63" );
			var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
			var stream_relationshipJoinDeclaration = new RewriteRuleSubtreeStream( adaptor, "rule relationshipJoinDeclaration" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:2: ( 'relationship' name '=' relationshipJoinDeclaration ';' -> ^( RELATIONSHIP name relationshipJoinDeclaration ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:4: 'relationship' name '=' relationshipJoinDeclaration ';'
				{
					string_literal25 = (IToken)Match( input, 67, FOLLOW_67_in_relationshipDeclaration484 );
					stream_67.Add( string_literal25 );

					PushFollow( FOLLOW_name_in_relationshipDeclaration486 );
					name26 = name();
					state.followingStackPointer--;

					stream_name.Add( name26.Tree );
					char_literal27 = (IToken)Match( input, 68, FOLLOW_68_in_relationshipDeclaration488 );
					stream_68.Add( char_literal27 );

					PushFollow( FOLLOW_relationshipJoinDeclaration_in_relationshipDeclaration490 );
					relationshipJoinDeclaration28 = relationshipJoinDeclaration();
					state.followingStackPointer--;

					stream_relationshipJoinDeclaration.Add( relationshipJoinDeclaration28.Tree );
					char_literal29 = (IToken)Match( input, 63, FOLLOW_63_in_relationshipDeclaration492 );
					stream_63.Add( char_literal29 );


					// AST REWRITE
					// elements:          name, relationshipJoinDeclaration
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 114:60: -> ^( RELATIONSHIP name relationshipJoinDeclaration )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:63: ^( RELATIONSHIP name relationshipJoinDeclaration )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( RELATIONSHIP, "RELATIONSHIP" ), root_1 );

							adaptor.AddChild( root_1, stream_name.NextTree() );
							adaptor.AddChild( root_1, stream_relationshipJoinDeclaration.NextTree() );

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #22
0
	private AstParserRuleReturnScope<CommonTree, IToken> attribute_args_list()
	{
		EnterRule_attribute_args_list();
		EnterRule("attribute_args_list", 5);
		TraceIn("attribute_args_list", 5);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken char_literal18 = default(IToken);
		IToken WS19 = default(IToken);
		IToken WS21 = default(IToken);
		IToken char_literal22 = default(IToken);
		IToken WS23 = default(IToken);
		IToken WS25 = default(IToken);
		IToken char_literal26 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> attribute_args20 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> attribute_args24 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal18_tree = default(CommonTree);
		CommonTree WS19_tree = default(CommonTree);
		CommonTree WS21_tree = default(CommonTree);
		CommonTree char_literal22_tree = default(CommonTree);
		CommonTree WS23_tree = default(CommonTree);
		CommonTree WS25_tree = default(CommonTree);
		CommonTree char_literal26_tree = default(CommonTree);
		RewriteRuleITokenStream stream_94=new RewriteRuleITokenStream(adaptor,"token 94");
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_93=new RewriteRuleITokenStream(adaptor,"token 93");
		RewriteRuleITokenStream stream_100=new RewriteRuleITokenStream(adaptor,"token 100");
		RewriteRuleSubtreeStream stream_attribute_args=new RewriteRuleSubtreeStream(adaptor,"rule attribute_args");
		try { DebugEnterRule(GrammarFileName, "attribute_args_list");
		DebugLocation(239, 1);
		try
		{
			// SugarCpp.g:240:2: ( '(' ( WS )* attribute_args ( ( WS )* ',' ( WS )* attribute_args )* ( WS )* ')' -> ( attribute_args )+ )
			DebugEnterAlt(1);
			// SugarCpp.g:240:4: '(' ( WS )* attribute_args ( ( WS )* ',' ( WS )* attribute_args )* ( WS )* ')'
			{
			DebugLocation(240, 4);
			char_literal18=(IToken)Match(input,93,Follow._93_in_attribute_args_list692); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_93.Add(char_literal18);

			DebugLocation(240, 8);
			// SugarCpp.g:240:8: ( WS )*
			try { DebugEnterSubRule(7);
			while (true)
			{
				int alt7=2;
				try { DebugEnterDecision(7, false);
				int LA7_0 = input.LA(1);

				if ((LA7_0==WS))
				{
					alt7 = 1;
				}


				} finally { DebugExitDecision(7); }
				switch ( alt7 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:240:8: WS
					{
					DebugLocation(240, 8);
					WS19=(IToken)Match(input,WS,Follow._WS_in_attribute_args_list694); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS19);


					}
					break;

				default:
					goto loop7;
				}
			}

			loop7:
				;

			} finally { DebugExitSubRule(7); }

			DebugLocation(240, 12);
			PushFollow(Follow._attribute_args_in_attribute_args_list697);
			attribute_args20=attribute_args();
			PopFollow();
			if (state.failed) return retval;
			if (state.backtracking == 0) stream_attribute_args.Add(attribute_args20.Tree);
			DebugLocation(240, 27);
			// SugarCpp.g:240:27: ( ( WS )* ',' ( WS )* attribute_args )*
			try { DebugEnterSubRule(10);
			while (true)
			{
				int alt10=2;
				try { DebugEnterDecision(10, false);
				try
				{
					alt10 = dfa10.Predict(input);
				}
				catch (NoViableAltException nvae)
				{
					DebugRecognitionException(nvae);
					throw;
				}
				} finally { DebugExitDecision(10); }
				switch ( alt10 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:240:28: ( WS )* ',' ( WS )* attribute_args
					{
					DebugLocation(240, 28);
					// SugarCpp.g:240:28: ( WS )*
					try { DebugEnterSubRule(8);
					while (true)
					{
						int alt8=2;
						try { DebugEnterDecision(8, false);
						int LA8_0 = input.LA(1);

						if ((LA8_0==WS))
						{
							alt8 = 1;
						}


						} finally { DebugExitDecision(8); }
						switch ( alt8 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:240:28: WS
							{
							DebugLocation(240, 28);
							WS21=(IToken)Match(input,WS,Follow._WS_in_attribute_args_list700); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS21);


							}
							break;

						default:
							goto loop8;
						}
					}

					loop8:
						;

					} finally { DebugExitSubRule(8); }

					DebugLocation(240, 32);
					char_literal22=(IToken)Match(input,100,Follow._100_in_attribute_args_list703); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_100.Add(char_literal22);

					DebugLocation(240, 36);
					// SugarCpp.g:240:36: ( WS )*
					try { DebugEnterSubRule(9);
					while (true)
					{
						int alt9=2;
						try { DebugEnterDecision(9, false);
						int LA9_0 = input.LA(1);

						if ((LA9_0==WS))
						{
							alt9 = 1;
						}


						} finally { DebugExitDecision(9); }
						switch ( alt9 )
						{
						case 1:
							DebugEnterAlt(1);
							// SugarCpp.g:240:36: WS
							{
							DebugLocation(240, 36);
							WS23=(IToken)Match(input,WS,Follow._WS_in_attribute_args_list705); if (state.failed) return retval; 
							if (state.backtracking == 0) stream_WS.Add(WS23);


							}
							break;

						default:
							goto loop9;
						}
					}

					loop9:
						;

					} finally { DebugExitSubRule(9); }

					DebugLocation(240, 40);
					PushFollow(Follow._attribute_args_in_attribute_args_list708);
					attribute_args24=attribute_args();
					PopFollow();
					if (state.failed) return retval;
					if (state.backtracking == 0) stream_attribute_args.Add(attribute_args24.Tree);

					}
					break;

				default:
					goto loop10;
				}
			}

			loop10:
				;

			} finally { DebugExitSubRule(10); }

			DebugLocation(240, 57);
			// SugarCpp.g:240:57: ( WS )*
			try { DebugEnterSubRule(11);
			while (true)
			{
				int alt11=2;
				try { DebugEnterDecision(11, false);
				int LA11_0 = input.LA(1);

				if ((LA11_0==WS))
				{
					alt11 = 1;
				}


				} finally { DebugExitDecision(11); }
				switch ( alt11 )
				{
				case 1:
					DebugEnterAlt(1);
					// SugarCpp.g:240:57: WS
					{
					DebugLocation(240, 57);
					WS25=(IToken)Match(input,WS,Follow._WS_in_attribute_args_list712); if (state.failed) return retval; 
					if (state.backtracking == 0) stream_WS.Add(WS25);


					}
					break;

				default:
					goto loop11;
				}
			}

			loop11:
				;

			} finally { DebugExitSubRule(11); }

			DebugLocation(240, 61);
			char_literal26=(IToken)Match(input,94,Follow._94_in_attribute_args_list715); if (state.failed) return retval; 
			if (state.backtracking == 0) stream_94.Add(char_literal26);



			{
			// AST REWRITE
			// elements: attribute_args
			// 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();
			// 240:65: -> ( attribute_args )+
			{
				DebugLocation(240, 68);
				if (!(stream_attribute_args.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_attribute_args.HasNext )
				{
					DebugLocation(240, 68);
					adaptor.AddChild(root_0, stream_attribute_args.NextTree());

				}
				stream_attribute_args.Reset();

			}

			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("attribute_args_list", 5);
			LeaveRule("attribute_args_list", 5);
			LeaveRule_attribute_args_list();
		}
		DebugLocation(241, 1);
		} finally { DebugExitRule(GrammarFileName, "attribute_args_list"); }
		return retval;

	}
		// $ANTLR start "formulaDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:125:1: formulaDeclaration : entityChainNoFilter assignmentOp expression ';' -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) ) ;
		public formulaDeclaration_return formulaDeclaration() // throws RecognitionException [1]
		{
			var retval = new formulaDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken char_literal36 = null;
			entityChainNoFilter_return entityChainNoFilter33 = default( entityChainNoFilter_return );

			assignmentOp_return assignmentOp34 = default( assignmentOp_return );

			expression_return expression35 = default( expression_return );


			CommonTree char_literal36_tree = null;
			var stream_63 = new RewriteRuleTokenStream( adaptor, "token 63" );
			var stream_entityChainNoFilter = new RewriteRuleSubtreeStream( adaptor, "rule entityChainNoFilter" );
			var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
			var stream_assignmentOp = new RewriteRuleSubtreeStream( adaptor, "rule assignmentOp" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:2: ( entityChainNoFilter assignmentOp expression ';' -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:4: entityChainNoFilter assignmentOp expression ';'
				{
					PushFollow( FOLLOW_entityChainNoFilter_in_formulaDeclaration558 );
					entityChainNoFilter33 = entityChainNoFilter();
					state.followingStackPointer--;

					stream_entityChainNoFilter.Add( entityChainNoFilter33.Tree );
					PushFollow( FOLLOW_assignmentOp_in_formulaDeclaration560 );
					assignmentOp34 = assignmentOp();
					state.followingStackPointer--;

					stream_assignmentOp.Add( assignmentOp34.Tree );
					PushFollow( FOLLOW_expression_in_formulaDeclaration562 );
					expression35 = expression();
					state.followingStackPointer--;

					stream_expression.Add( expression35.Tree );
					char_literal36 = (IToken)Match( input, 63, FOLLOW_63_in_formulaDeclaration564 );
					stream_63.Add( char_literal36 );


					// AST REWRITE
					// elements:          assignmentOp, entityChainNoFilter, expression
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 126:52: -> ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:55: ^( FORMULA ^( assignmentOp entityChainNoFilter expression ) )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( FORMULA, "FORMULA" ), root_1 );

							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:126:66: ^( assignmentOp entityChainNoFilter expression )
							{
								var root_2 = (CommonTree)adaptor.GetNilNode();
								root_2 = (CommonTree)adaptor.BecomeRoot( stream_assignmentOp.NextNode(), root_2 );

								adaptor.AddChild( root_2, stream_entityChainNoFilter.NextTree() );
								adaptor.AddChild( root_2, stream_expression.NextTree() );

								adaptor.AddChild( root_1, root_2 );
							}

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #24
0
	public AstParserRuleReturnScope<object, IToken> parse()
	{
		EnterRule_parse();
		EnterRule("parse", 1);
		TraceIn("parse", 1);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken EOF2 = default(IToken);
		AstParserRuleReturnScope<object, IToken> arglist_expr1 = default(AstParserRuleReturnScope<object, IToken>);

		object EOF2_tree = default(object);
		RewriteRuleITokenStream stream_EOF=new RewriteRuleITokenStream(adaptor,"token EOF");
		RewriteRuleSubtreeStream stream_arglist_expr=new RewriteRuleSubtreeStream(adaptor,"rule arglist_expr");
		try { DebugEnterRule(GrammarFileName, "parse");
		DebugLocation(77, 1);
		try
		{
			// Queries\\PomonaQuery.g:78:2: ( arglist_expr EOF -> ^( ROOT arglist_expr ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:78:4: arglist_expr EOF
			{
			DebugLocation(78, 4);
			PushFollow(Follow._arglist_expr_in_parse498);
			arglist_expr1=arglist_expr();
			PopFollow();

			stream_arglist_expr.Add(arglist_expr1.Tree);
			DebugLocation(78, 17);
			EOF2=(IToken)Match(input,EOF,Follow._EOF_in_parse500);  
			stream_EOF.Add(EOF2);



			{
			// AST REWRITE
			// elements: arglist_expr
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 78:21: -> ^( ROOT arglist_expr )
			{
				DebugLocation(78, 24);
				// Queries\\PomonaQuery.g:78:24: ^( ROOT arglist_expr )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(78, 26);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(ROOT, "ROOT"), root_1);

				DebugLocation(78, 31);
				adaptor.AddChild(root_1, stream_arglist_expr.NextTree());

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("parse", 1);
			LeaveRule("parse", 1);
			LeaveRule_parse();
		}
		DebugLocation(79, 1);
		} finally { DebugExitRule(GrammarFileName, "parse"); }
		return retval;

	}
		// $ANTLR start "criteria"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:248:1: criteria : '[' expression ']' -> ^( CRITERIA expression ) ;
		public criteria_return criteria() // throws RecognitionException [1]
		{
			var retval = new criteria_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken char_literal84 = null;
			IToken char_literal86 = null;
			expression_return expression85 = default( expression_return );


			CommonTree char_literal84_tree = null;
			CommonTree char_literal86_tree = null;
			var stream_93 = new RewriteRuleTokenStream( adaptor, "token 93" );
			var stream_92 = new RewriteRuleTokenStream( adaptor, "token 92" );
			var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:2: ( '[' expression ']' -> ^( CRITERIA expression ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:4: '[' expression ']'
				{
					char_literal84 = (IToken)Match( input, 92, FOLLOW_92_in_criteria1320 );
					stream_92.Add( char_literal84 );

					PushFollow( FOLLOW_expression_in_criteria1322 );
					expression85 = expression();
					state.followingStackPointer--;

					stream_expression.Add( expression85.Tree );
					char_literal86 = (IToken)Match( input, 93, FOLLOW_93_in_criteria1324 );
					stream_93.Add( char_literal86 );


					// AST REWRITE
					// elements:          expression
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 249:23: -> ^( CRITERIA expression )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:26: ^( CRITERIA expression )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CRITERIA, "CRITERIA" ), root_1 );

							adaptor.AddChild( root_1, stream_expression.NextTree() );

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #26
0
	private AstParserRuleReturnScope<object, IToken> postfix_expr()
	{
		EnterRule_postfix_expr();
		EnterRule("postfix_expr", 18);
		TraceIn("postfix_expr", 18);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken ID59 = default(IToken);
		IToken char_literal60 = default(IToken);
		IToken char_literal62 = default(IToken);
		IToken ID63 = default(IToken);
		IToken char_literal64 = default(IToken);
		IToken char_literal65 = default(IToken);
		IToken ID66 = default(IToken);
		IToken char_literal67 = default(IToken);
		IToken char_literal69 = default(IToken);
		IToken ID70 = default(IToken);
		IToken char_literal71 = default(IToken);
		IToken char_literal72 = default(IToken);
		IToken ID73 = default(IToken);
		IToken STRING74 = default(IToken);
		IToken INT75 = default(IToken);
		IToken char_literal76 = default(IToken);
		IToken char_literal78 = default(IToken);
		IToken char_literal79 = default(IToken);
		IToken char_literal81 = default(IToken);
		IToken PREFIXED_STRING82 = default(IToken);
		AstParserRuleReturnScope<object, IToken> arglist_expr61 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> arglist_expr68 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> orderby_expr77 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> arglist_expr80 = default(AstParserRuleReturnScope<object, IToken>);

		object ID59_tree = default(object);
		object char_literal60_tree = default(object);
		object char_literal62_tree = default(object);
		object ID63_tree = default(object);
		object char_literal64_tree = default(object);
		object char_literal65_tree = default(object);
		object ID66_tree = default(object);
		object char_literal67_tree = default(object);
		object char_literal69_tree = default(object);
		object ID70_tree = default(object);
		object char_literal71_tree = default(object);
		object char_literal72_tree = default(object);
		object ID73_tree = default(object);
		object STRING74_tree = default(object);
		object INT75_tree = default(object);
		object char_literal76_tree = default(object);
		object char_literal78_tree = default(object);
		object char_literal79_tree = default(object);
		object char_literal81_tree = default(object);
		object PREFIXED_STRING82_tree = default(object);
		RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
		RewriteRuleITokenStream stream_43=new RewriteRuleITokenStream(adaptor,"token 43");
		RewriteRuleITokenStream stream_44=new RewriteRuleITokenStream(adaptor,"token 44");
		RewriteRuleITokenStream stream_57=new RewriteRuleITokenStream(adaptor,"token 57");
		RewriteRuleITokenStream stream_58=new RewriteRuleITokenStream(adaptor,"token 58");
		RewriteRuleSubtreeStream stream_arglist_expr=new RewriteRuleSubtreeStream(adaptor,"rule arglist_expr");
		try { DebugEnterRule(GrammarFileName, "postfix_expr");
		DebugLocation(166, 1);
		try
		{
			// Queries\\PomonaQuery.g:167:2: ( ID ( '(' arglist_expr ')' ) -> ^( METHOD_CALL ID arglist_expr ) | ID ( '(' ')' ) -> ^( METHOD_CALL ID ) | ID ( '[' arglist_expr ']' ) -> ^( INDEXER_ACCESS ID arglist_expr ) | ID ( '[' ']' ) -> ^( INDEXER_ACCESS ID ) | ID | STRING | INT | '(' ! orderby_expr ')' !| '[' arglist_expr ']' -> ^( ARRAY_LITERAL arglist_expr ) | PREFIXED_STRING )
			int alt26=10;
			try { DebugEnterDecision(26, false);
			switch (input.LA(1))
			{
			case ID:
				{
				switch (input.LA(2))
				{
				case 43:
					{
					int LA26_3 = input.LA(3);

					if ((LA26_3==44))
					{
						alt26 = 2;
					}
					else if ((LA26_3==ID||LA26_3==INT||LA26_3==PREFIXED_STRING||LA26_3==STRING||LA26_3==39||LA26_3==43||LA26_3==57||LA26_3==74))
					{
						alt26 = 1;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 26, 7, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					}
					break;
				case 57:
					{
					int LA26_3 = input.LA(3);

					if ((LA26_3==58))
					{
						alt26 = 4;
					}
					else if ((LA26_3==ID||LA26_3==INT||LA26_3==PREFIXED_STRING||LA26_3==STRING||LA26_3==39||LA26_3==43||LA26_3==57||LA26_3==74))
					{
						alt26 = 3;
					}
					else
					{
						NoViableAltException nvae = new NoViableAltException("", 26, 8, input, 3);
						DebugRecognitionException(nvae);
						throw nvae;
					}
					}
					break;
				case EOF:
				case 40:
				case 41:
				case 42:
				case 44:
				case 45:
				case 46:
				case 47:
				case 48:
				case 49:
				case 50:
				case 51:
				case 52:
				case 53:
				case 54:
				case 55:
				case 56:
				case 58:
				case 59:
				case 60:
				case 61:
				case 62:
				case 63:
				case 64:
				case 65:
				case 66:
				case 67:
				case 68:
				case 69:
				case 70:
				case 71:
				case 72:
				case 73:
				case 75:
				case 76:
				case 77:
					{
					alt26 = 5;
					}
					break;
				default:
					{
						NoViableAltException nvae = new NoViableAltException("", 26, 1, input, 2);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}

				}
				break;
			case STRING:
				{
				alt26 = 6;
				}
				break;
			case INT:
				{
				alt26 = 7;
				}
				break;
			case 43:
				{
				alt26 = 8;
				}
				break;
			case 57:
				{
				alt26 = 9;
				}
				break;
			case PREFIXED_STRING:
				{
				alt26 = 10;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 26, 0, input, 1);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(26); }
			switch (alt26)
			{
			case 1:
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:167:4: ID ( '(' arglist_expr ')' )
				{
				DebugLocation(167, 4);
				ID59=(IToken)Match(input,ID,Follow._ID_in_postfix_expr1005);  
				stream_ID.Add(ID59);

				DebugLocation(167, 7);
				// Queries\\PomonaQuery.g:167:7: ( '(' arglist_expr ')' )
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:167:9: '(' arglist_expr ')'
				{
				DebugLocation(167, 9);
				char_literal60=(IToken)Match(input,43,Follow._43_in_postfix_expr1009);  
				stream_43.Add(char_literal60);

				DebugLocation(167, 13);
				PushFollow(Follow._arglist_expr_in_postfix_expr1011);
				arglist_expr61=arglist_expr();
				PopFollow();

				stream_arglist_expr.Add(arglist_expr61.Tree);
				DebugLocation(167, 26);
				char_literal62=(IToken)Match(input,44,Follow._44_in_postfix_expr1013);  
				stream_44.Add(char_literal62);


				}



				{
				// AST REWRITE
				// elements: ID, arglist_expr
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 167:32: -> ^( METHOD_CALL ID arglist_expr )
				{
					DebugLocation(167, 35);
					// Queries\\PomonaQuery.g:167:35: ^( METHOD_CALL ID arglist_expr )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(167, 37);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(METHOD_CALL, "METHOD_CALL"), root_1);

					DebugLocation(167, 49);
					adaptor.AddChild(root_1, stream_ID.NextNode());
					DebugLocation(167, 52);
					adaptor.AddChild(root_1, stream_arglist_expr.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// Queries\\PomonaQuery.g:168:4: ID ( '(' ')' )
				{
				DebugLocation(168, 4);
				ID63=(IToken)Match(input,ID,Follow._ID_in_postfix_expr1030);  
				stream_ID.Add(ID63);

				DebugLocation(168, 7);
				// Queries\\PomonaQuery.g:168:7: ( '(' ')' )
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:168:9: '(' ')'
				{
				DebugLocation(168, 9);
				char_literal64=(IToken)Match(input,43,Follow._43_in_postfix_expr1034);  
				stream_43.Add(char_literal64);

				DebugLocation(168, 13);
				char_literal65=(IToken)Match(input,44,Follow._44_in_postfix_expr1036);  
				stream_44.Add(char_literal65);


				}



				{
				// AST REWRITE
				// elements: ID
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 168:19: -> ^( METHOD_CALL ID )
				{
					DebugLocation(168, 22);
					// Queries\\PomonaQuery.g:168:22: ^( METHOD_CALL ID )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(168, 24);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(METHOD_CALL, "METHOD_CALL"), root_1);

					DebugLocation(168, 36);
					adaptor.AddChild(root_1, stream_ID.NextNode());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// Queries\\PomonaQuery.g:169:4: ID ( '[' arglist_expr ']' )
				{
				DebugLocation(169, 4);
				ID66=(IToken)Match(input,ID,Follow._ID_in_postfix_expr1051);  
				stream_ID.Add(ID66);

				DebugLocation(169, 7);
				// Queries\\PomonaQuery.g:169:7: ( '[' arglist_expr ']' )
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:169:9: '[' arglist_expr ']'
				{
				DebugLocation(169, 9);
				char_literal67=(IToken)Match(input,57,Follow._57_in_postfix_expr1055);  
				stream_57.Add(char_literal67);

				DebugLocation(169, 13);
				PushFollow(Follow._arglist_expr_in_postfix_expr1057);
				arglist_expr68=arglist_expr();
				PopFollow();

				stream_arglist_expr.Add(arglist_expr68.Tree);
				DebugLocation(169, 26);
				char_literal69=(IToken)Match(input,58,Follow._58_in_postfix_expr1059);  
				stream_58.Add(char_literal69);


				}



				{
				// AST REWRITE
				// elements: ID, arglist_expr
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 169:32: -> ^( INDEXER_ACCESS ID arglist_expr )
				{
					DebugLocation(169, 35);
					// Queries\\PomonaQuery.g:169:35: ^( INDEXER_ACCESS ID arglist_expr )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(169, 37);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(INDEXER_ACCESS, "INDEXER_ACCESS"), root_1);

					DebugLocation(169, 52);
					adaptor.AddChild(root_1, stream_ID.NextNode());
					DebugLocation(169, 55);
					adaptor.AddChild(root_1, stream_arglist_expr.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// Queries\\PomonaQuery.g:170:4: ID ( '[' ']' )
				{
				DebugLocation(170, 4);
				ID70=(IToken)Match(input,ID,Follow._ID_in_postfix_expr1076);  
				stream_ID.Add(ID70);

				DebugLocation(170, 7);
				// Queries\\PomonaQuery.g:170:7: ( '[' ']' )
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:170:9: '[' ']'
				{
				DebugLocation(170, 9);
				char_literal71=(IToken)Match(input,57,Follow._57_in_postfix_expr1080);  
				stream_57.Add(char_literal71);

				DebugLocation(170, 13);
				char_literal72=(IToken)Match(input,58,Follow._58_in_postfix_expr1082);  
				stream_58.Add(char_literal72);


				}



				{
				// AST REWRITE
				// elements: ID
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 170:19: -> ^( INDEXER_ACCESS ID )
				{
					DebugLocation(170, 22);
					// Queries\\PomonaQuery.g:170:22: ^( INDEXER_ACCESS ID )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(170, 24);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(INDEXER_ACCESS, "INDEXER_ACCESS"), root_1);

					DebugLocation(170, 39);
					adaptor.AddChild(root_1, stream_ID.NextNode());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 5:
				DebugEnterAlt(5);
				// Queries\\PomonaQuery.g:171:4: ID
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(171, 4);
				ID73=(IToken)Match(input,ID,Follow._ID_in_postfix_expr1097); 
				ID73_tree = (object)adaptor.Create(ID73);
				adaptor.AddChild(root_0, ID73_tree);

				}
				break;
			case 6:
				DebugEnterAlt(6);
				// Queries\\PomonaQuery.g:172:4: STRING
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(172, 4);
				STRING74=(IToken)Match(input,STRING,Follow._STRING_in_postfix_expr1102); 
				STRING74_tree = (object)adaptor.Create(STRING74);
				adaptor.AddChild(root_0, STRING74_tree);

				}
				break;
			case 7:
				DebugEnterAlt(7);
				// Queries\\PomonaQuery.g:173:4: INT
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(173, 4);
				INT75=(IToken)Match(input,INT,Follow._INT_in_postfix_expr1107); 
				INT75_tree = (object)adaptor.Create(INT75);
				adaptor.AddChild(root_0, INT75_tree);

				}
				break;
			case 8:
				DebugEnterAlt(8);
				// Queries\\PomonaQuery.g:174:4: '(' ! orderby_expr ')' !
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(174, 7);
				char_literal76=(IToken)Match(input,43,Follow._43_in_postfix_expr1112); 
				DebugLocation(174, 9);
				PushFollow(Follow._orderby_expr_in_postfix_expr1115);
				orderby_expr77=orderby_expr();
				PopFollow();

				adaptor.AddChild(root_0, orderby_expr77.Tree);
				DebugLocation(174, 25);
				char_literal78=(IToken)Match(input,44,Follow._44_in_postfix_expr1117); 

				}
				break;
			case 9:
				DebugEnterAlt(9);
				// Queries\\PomonaQuery.g:175:4: '[' arglist_expr ']'
				{
				DebugLocation(175, 4);
				char_literal79=(IToken)Match(input,57,Follow._57_in_postfix_expr1123);  
				stream_57.Add(char_literal79);

				DebugLocation(175, 8);
				PushFollow(Follow._arglist_expr_in_postfix_expr1125);
				arglist_expr80=arglist_expr();
				PopFollow();

				stream_arglist_expr.Add(arglist_expr80.Tree);
				DebugLocation(175, 21);
				char_literal81=(IToken)Match(input,58,Follow._58_in_postfix_expr1127);  
				stream_58.Add(char_literal81);



				{
				// AST REWRITE
				// elements: arglist_expr
				// token labels: 
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				retval.Tree = root_0;
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 175:25: -> ^( ARRAY_LITERAL arglist_expr )
				{
					DebugLocation(175, 28);
					// Queries\\PomonaQuery.g:175:28: ^( ARRAY_LITERAL arglist_expr )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(175, 30);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(ARRAY_LITERAL, "ARRAY_LITERAL"), root_1);

					DebugLocation(175, 44);
					adaptor.AddChild(root_1, stream_arglist_expr.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}

				}
				break;
			case 10:
				DebugEnterAlt(10);
				// Queries\\PomonaQuery.g:176:4: PREFIXED_STRING
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(176, 4);
				PREFIXED_STRING82=(IToken)Match(input,PREFIXED_STRING,Follow._PREFIXED_STRING_in_postfix_expr1140); 
				PREFIXED_STRING82_tree = (object)adaptor.Create(PREFIXED_STRING82);
				adaptor.AddChild(root_0, PREFIXED_STRING82_tree);

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("postfix_expr", 18);
			LeaveRule("postfix_expr", 18);
			LeaveRule_postfix_expr();
		}
		DebugLocation(177, 1);
		} finally { DebugExitRule(GrammarFileName, "postfix_expr"); }
		return retval;

	}
		// $ANTLR start "baseClassDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:82:1: baseClassDeclaration : ':' name 'where' expression -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) ) ;
		public baseClassDeclaration_return baseClassDeclaration() // throws RecognitionException [1]
		{
			var retval = new baseClassDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken char_literal8 = null;
			IToken string_literal10 = null;
			name_return name9 = default( name_return );

			expression_return expression11 = default( expression_return );


			CommonTree char_literal8_tree = null;
			CommonTree string_literal10_tree = null;
			var stream_59 = new RewriteRuleTokenStream( adaptor, "token 59" );
			var stream_58 = new RewriteRuleTokenStream( adaptor, "token 58" );
			var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
			var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:2: ( ':' name 'where' expression -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:4: ':' name 'where' expression
				{
					char_literal8 = (IToken)Match( input, 58, FOLLOW_58_in_baseClassDeclaration294 );
					stream_58.Add( char_literal8 );

					PushFollow( FOLLOW_name_in_baseClassDeclaration296 );
					name9 = name();
					state.followingStackPointer--;

					stream_name.Add( name9.Tree );
					string_literal10 = (IToken)Match( input, 59, FOLLOW_59_in_baseClassDeclaration298 );
					stream_59.Add( string_literal10 );

					PushFollow( FOLLOW_expression_in_baseClassDeclaration300 );
					expression11 = expression();
					state.followingStackPointer--;

					stream_expression.Add( expression11.Tree );


					// AST REWRITE
					// elements:          name, expression
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 83:32: -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:35: ^( BASE_CLASS name ^( DISCRIMINATOR expression ) )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( BASE_CLASS, "BASE_CLASS" ), root_1 );

							adaptor.AddChild( root_1, stream_name.NextTree() );
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:54: ^( DISCRIMINATOR expression )
							{
								var root_2 = (CommonTree)adaptor.GetNilNode();
								root_2 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( DISCRIMINATOR, "DISCRIMINATOR" ), root_2 );

								adaptor.AddChild( root_2, stream_expression.NextTree() );

								adaptor.AddChild( root_1, root_2 );
							}

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #28
0
	private AstParserRuleReturnScope<object, IToken> as_expression()
	{
		EnterRule_as_expression();
		EnterRule("as_expression", 3);
		TraceIn("as_expression", 3);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken string_literal5 = default(IToken);
		AstParserRuleReturnScope<object, IToken> lambda_expression4 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> lambda_expression6 = default(AstParserRuleReturnScope<object, IToken>);

		object string_literal5_tree = default(object);
		RewriteRuleITokenStream stream_61=new RewriteRuleITokenStream(adaptor,"token 61");
		RewriteRuleSubtreeStream stream_lambda_expression=new RewriteRuleSubtreeStream(adaptor,"rule lambda_expression");
		try { DebugEnterRule(GrammarFileName, "as_expression");
		DebugLocation(85, 1);
		try
		{
			// Queries\\PomonaQuery.g:86:2: ( lambda_expression ( 'as' lambda_expression )? -> ^( AS_OP ( lambda_expression )+ ) )
			DebugEnterAlt(1);
			// Queries\\PomonaQuery.g:86:4: lambda_expression ( 'as' lambda_expression )?
			{
			DebugLocation(86, 4);
			PushFollow(Follow._lambda_expression_in_as_expression530);
			lambda_expression4=lambda_expression();
			PopFollow();

			stream_lambda_expression.Add(lambda_expression4.Tree);
			DebugLocation(86, 22);
			// Queries\\PomonaQuery.g:86:22: ( 'as' lambda_expression )?
			int alt1=2;
			try { DebugEnterSubRule(1);
			try { DebugEnterDecision(1, false);
			int LA1_1 = input.LA(1);

			if ((LA1_1==61))
			{
				alt1 = 1;
			}
			} finally { DebugExitDecision(1); }
			switch (alt1)
			{
			case 1:
				DebugEnterAlt(1);
				// Queries\\PomonaQuery.g:86:24: 'as' lambda_expression
				{
				DebugLocation(86, 24);
				string_literal5=(IToken)Match(input,61,Follow._61_in_as_expression534);  
				stream_61.Add(string_literal5);

				DebugLocation(86, 29);
				PushFollow(Follow._lambda_expression_in_as_expression536);
				lambda_expression6=lambda_expression();
				PopFollow();

				stream_lambda_expression.Add(lambda_expression6.Tree);

				}
				break;

			}
			} finally { DebugExitSubRule(1); }



			{
			// AST REWRITE
			// elements: lambda_expression
			// token labels: 
			// rule labels: retval
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.Tree = root_0;
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

			root_0 = (object)adaptor.Nil();
			// 86:50: -> ^( AS_OP ( lambda_expression )+ )
			{
				DebugLocation(86, 53);
				// Queries\\PomonaQuery.g:86:53: ^( AS_OP ( lambda_expression )+ )
				{
				object root_1 = (object)adaptor.Nil();
				DebugLocation(86, 55);
				root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(AS_OP, "AS_OP"), root_1);

				DebugLocation(86, 61);
				if (!(stream_lambda_expression.HasNext))
				{
					throw new RewriteEarlyExitException();
				}
				while ( stream_lambda_expression.HasNext )
				{
					DebugLocation(86, 61);
					adaptor.AddChild(root_1, stream_lambda_expression.NextTree());

				}
				stream_lambda_expression.Reset();

				adaptor.AddChild(root_0, root_1);
				}

			}

			retval.Tree = root_0;
			}

			}

			retval.Stop = (IToken)input.LT(-1);

			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
			retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("as_expression", 3);
			LeaveRule("as_expression", 3);
			LeaveRule_as_expression();
		}
		DebugLocation(87, 1);
		} finally { DebugExitRule(GrammarFileName, "as_expression"); }
		return retval;

	}
		// $ANTLR start "propertyDeclaration"
		// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:97:1: propertyDeclaration : 'property' name ( propertyModifiers )? ';' -> ^( PROPERTY name ( propertyModifiers )? ) ;
		public propertyDeclaration_return propertyDeclaration() // throws RecognitionException [1]
		{
			var retval = new propertyDeclaration_return();
			retval.Start = input.LT( 1 );

			CommonTree root_0 = null;

			IToken string_literal17 = null;
			IToken char_literal20 = null;
			name_return name18 = default( name_return );

			propertyModifiers_return propertyModifiers19 = default( propertyModifiers_return );


			CommonTree string_literal17_tree = null;
			CommonTree char_literal20_tree = null;
			var stream_62 = new RewriteRuleTokenStream( adaptor, "token 62" );
			var stream_63 = new RewriteRuleTokenStream( adaptor, "token 63" );
			var stream_propertyModifiers = new RewriteRuleSubtreeStream( adaptor, "rule propertyModifiers" );
			var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
			try
			{
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:2: ( 'property' name ( propertyModifiers )? ';' -> ^( PROPERTY name ( propertyModifiers )? ) )
				// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:4: 'property' name ( propertyModifiers )? ';'
				{
					string_literal17 = (IToken)Match( input, 62, FOLLOW_62_in_propertyDeclaration389 );
					stream_62.Add( string_literal17 );

					PushFollow( FOLLOW_name_in_propertyDeclaration391 );
					name18 = name();
					state.followingStackPointer--;

					stream_name.Add( name18.Tree );
					// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:20: ( propertyModifiers )?
					int alt6 = 2;
					int LA6_0 = input.LA( 1 );

					if ( ( ( LA6_0 >= 64 && LA6_0 <= 66 ) ) )
						alt6 = 1;
					switch ( alt6 )
					{
						case 1:
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:20: propertyModifiers
							{
								PushFollow( FOLLOW_propertyModifiers_in_propertyDeclaration393 );
								propertyModifiers19 = propertyModifiers();
								state.followingStackPointer--;

								stream_propertyModifiers.Add( propertyModifiers19.Tree );
							}
							break;
					}

					char_literal20 = (IToken)Match( input, 63, FOLLOW_63_in_propertyDeclaration396 );
					stream_63.Add( char_literal20 );


					// AST REWRITE
					// elements:          name, propertyModifiers
					// token labels:      
					// rule labels:       retval
					// token list labels: 
					// rule list labels:  
					// wildcard labels: 
					retval.Tree = root_0;
					var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );

					root_0 = (CommonTree)adaptor.GetNilNode();
					// 98:43: -> ^( PROPERTY name ( propertyModifiers )? )
					{
						// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:46: ^( PROPERTY name ( propertyModifiers )? )
						{
							var root_1 = (CommonTree)adaptor.GetNilNode();
							root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( PROPERTY, "PROPERTY" ), root_1 );

							adaptor.AddChild( root_1, stream_name.NextTree() );
							// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:98:63: ( propertyModifiers )?
							if ( stream_propertyModifiers.HasNext() )
								adaptor.AddChild( root_1, stream_propertyModifiers.NextTree() );
							stream_propertyModifiers.Reset();

							adaptor.AddChild( root_0, root_1 );
						}
					}

					retval.Tree = root_0;
					retval.Tree = root_0;
				}

				retval.Stop = input.LT( -1 );

				retval.Tree = adaptor.RulePostProcessing( root_0 );
				adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
			}
			catch ( RecognitionException re )
			{
				ReportError( re );
				Recover( input, re );
				// Conversion of the second argument necessary, but harmless
				retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
			}
			finally {}
			return retval;
		}
Пример #30
0
	private AstParserRuleReturnScope<CommonTree, IToken> lvalue_atom()
	{
		EnterRule_lvalue_atom();
		EnterRule("lvalue_atom", 100);
		TraceIn("lvalue_atom", 100);
		AstParserRuleReturnScope<CommonTree, IToken> retval = new AstParserRuleReturnScope<CommonTree, IToken>();
		retval.Start = (IToken)input.LT(1);

		CommonTree root_0 = default(CommonTree);

		IToken char_literal955 = default(IToken);
		IToken WS956 = default(IToken);
		AstParserRuleReturnScope<CommonTree, IToken> ident954 = default(AstParserRuleReturnScope<CommonTree, IToken>);
		AstParserRuleReturnScope<CommonTree, IToken> ident957 = default(AstParserRuleReturnScope<CommonTree, IToken>);

		CommonTree char_literal955_tree = default(CommonTree);
		CommonTree WS956_tree = default(CommonTree);
		RewriteRuleITokenStream stream_WS=new RewriteRuleITokenStream(adaptor,"token WS");
		RewriteRuleITokenStream stream_131=new RewriteRuleITokenStream(adaptor,"token 131");
		RewriteRuleSubtreeStream stream_ident=new RewriteRuleSubtreeStream(adaptor,"rule ident");
		try { DebugEnterRule(GrammarFileName, "lvalue_atom");
		DebugLocation(754, 1);
		try
		{
			// SugarCpp.g:755:2: ( ident | '@' ( WS )* ident -> ^( '@' ident ) )
			int alt618=2;
			try { DebugEnterDecision(618, false);
			int LA618_0 = input.LA(1);

			if ((LA618_0==IDENT))
			{
				alt618 = 1;
			}
			else if ((LA618_0==131))
			{
				alt618 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 618, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(618); }
			switch (alt618)
			{
			case 1:
				DebugEnterAlt(1);
				// SugarCpp.g:755:4: ident
				{
				root_0 = (CommonTree)adaptor.Nil();

				DebugLocation(755, 4);
				PushFollow(Follow._ident_in_lvalue_atom9152);
				ident954=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) adaptor.AddChild(root_0, ident954.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// SugarCpp.g:756:4: '@' ( WS )* ident
				{
				DebugLocation(756, 4);
				char_literal955=(IToken)Match(input,131,Follow._131_in_lvalue_atom9157); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_131.Add(char_literal955);

				DebugLocation(756, 8);
				// SugarCpp.g:756:8: ( WS )*
				try { DebugEnterSubRule(617);
				while (true)
				{
					int alt617=2;
					try { DebugEnterDecision(617, false);
					int LA617_0 = input.LA(1);

					if ((LA617_0==WS))
					{
						alt617 = 1;
					}


					} finally { DebugExitDecision(617); }
					switch ( alt617 )
					{
					case 1:
						DebugEnterAlt(1);
						// SugarCpp.g:756:8: WS
						{
						DebugLocation(756, 8);
						WS956=(IToken)Match(input,WS,Follow._WS_in_lvalue_atom9159); if (state.failed) return retval; 
						if (state.backtracking == 0) stream_WS.Add(WS956);


						}
						break;

					default:
						goto loop617;
					}
				}

				loop617:
					;

				} finally { DebugExitSubRule(617); }

				DebugLocation(756, 12);
				PushFollow(Follow._ident_in_lvalue_atom9162);
				ident957=ident();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_ident.Add(ident957.Tree);


				{
				// AST REWRITE
				// elements: ident, 131
				// 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();
				// 756:18: -> ^( '@' ident )
				{
					DebugLocation(756, 21);
					// SugarCpp.g:756:21: ^( '@' ident )
					{
					CommonTree root_1 = (CommonTree)adaptor.Nil();
					DebugLocation(756, 23);
					root_1 = (CommonTree)adaptor.BecomeRoot(stream_131.NextNode(), root_1);

					DebugLocation(756, 27);
					adaptor.AddChild(root_1, stream_ident.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("lvalue_atom", 100);
			LeaveRule("lvalue_atom", 100);
			LeaveRule_lvalue_atom();
		}
		DebugLocation(757, 1);
		} finally { DebugExitRule(GrammarFileName, "lvalue_atom"); }
		return retval;

	}