Пример #1
0
        // throws RecognitionException [1]
        // $ANTLR start identifier
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1026:1: identifier : qualifiedIdent ( options {greedy=true; } : DOT qualifiedIdent )* -> ^( IDENTIFIER ( qualifiedIdent )+ ) ;
        public identifier_return identifier()
        {
            identifier_return retval = new identifier_return();
            retval.start = input.LT(1);
            int identifier_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken DOT173 = null;
            qualifiedIdent_return qualifiedIdent172 = null;

            qualifiedIdent_return qualifiedIdent174 = null;

            CommonTree DOT173_tree=null;
            RewriteRuleTokenStream stream_DOT = new RewriteRuleTokenStream(adaptor,"token DOT");
            RewriteRuleSubtreeStream stream_qualifiedIdent = new RewriteRuleSubtreeStream(adaptor,"rule qualifiedIdent");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 65) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1027:4: ( qualifiedIdent ( options {greedy=true; } : DOT qualifiedIdent )* -> ^( IDENTIFIER ( qualifiedIdent )+ ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1027:4: qualifiedIdent ( options {greedy=true; } : DOT qualifiedIdent )*
            {
                PushFollow(FOLLOW_qualifiedIdent_in_identifier3221);
                qualifiedIdent172 = qualifiedIdent();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_qualifiedIdent.Add(qualifiedIdent172.Tree);
                if ( backtracking == 0 )
                {

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1028:3: ( options {greedy=true; } : DOT qualifiedIdent )*
                do
                {
                    int alt46 = 2;
                    int LA46_0 = input.LA(1);

                    if ( (LA46_0 == DOT) )
                    {
                        alt46 = 1;
                    }

                    switch (alt46)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1029:6: DOT qualifiedIdent
                            {
                                DOT173 = (CommonToken)input.LT(1);
                                Match(input,DOT,FOLLOW_DOT_in_identifier3245); if (failed) return retval;
                                if ( backtracking==0 ) stream_DOT.Add(DOT173);

                                if ( backtracking == 0 )
                                {
                                   buffer.Append(".");
                                }
                                PushFollow(FOLLOW_qualifiedIdent_in_identifier3249);
                                qualifiedIdent174 = qualifiedIdent();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_qualifiedIdent.Add(qualifiedIdent174.Tree);

                            }
                            break;

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

                loop46:
                    ;	// Stops C# compiler whinging that label 'loop46' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1031:3: -> ^( IDENTIFIER ( qualifiedIdent )+ )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1031:6: ^( IDENTIFIER ( qualifiedIdent )+ )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_1);

                    if ( !(stream_qualifiedIdent.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_qualifiedIdent.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_qualifiedIdent.Next());

                    }
                    stream_qualifiedIdent.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 65, identifier_StartIndex);
            }
            }
            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;
		}
		// $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;
		}
Пример #4
0
        // throws RecognitionException [1]
        // $ANTLR start expressionList
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1222:1: expressionList : assignmentExpression ( COMMA assignmentExpression )* -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* ) ;
        public expressionList_return expressionList()
        {
            expressionList_return retval = new expressionList_return();
            retval.start = input.LT(1);
            int expressionList_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken COMMA227 = null;
            assignmentExpression_return assignmentExpression226 = null;

            assignmentExpression_return assignmentExpression228 = null;

            CommonTree COMMA227_tree=null;
            RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");
            RewriteRuleSubtreeStream stream_assignmentExpression = new RewriteRuleSubtreeStream(adaptor,"rule assignmentExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 86) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1223:4: ( assignmentExpression ( COMMA assignmentExpression )* -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1223:4: assignmentExpression ( COMMA assignmentExpression )*
            {
                PushFollow(FOLLOW_assignmentExpression_in_expressionList4132);
                assignmentExpression226 = assignmentExpression();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_assignmentExpression.Add(assignmentExpression226.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1224:3: ( COMMA assignmentExpression )*
                do
                {
                    int alt66 = 2;
                    int LA66_0 = input.LA(1);

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

                    switch (alt66)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1225:4: COMMA assignmentExpression
                            {
                                COMMA227 = (CommonToken)input.LT(1);
                                Match(input,COMMA,FOLLOW_COMMA_in_expressionList4142); if (failed) return retval;
                                if ( backtracking==0 ) stream_COMMA.Add(COMMA227);

                                if ( backtracking == 0 )
                                {
                                  buffer.Append(options.SpaceBetweenArguments ? ", " : ",");
                                }
                                PushFollow(FOLLOW_assignmentExpression_in_expressionList4154);
                                assignmentExpression228 = assignmentExpression();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_assignmentExpression.Add(assignmentExpression228.Tree);

                            }
                            break;

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

                loop66:
                    ;	// Stops C# compiler whinging that label 'loop66' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1227:6: -> ^( ELIST assignmentExpression ( COMMA assignmentExpression )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1227:9: ^( ELIST assignmentExpression ( COMMA assignmentExpression )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ELIST, "ELIST"), root_1);

                    adaptor.AddChild(root_1, stream_assignmentExpression.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1227:38: ( COMMA assignmentExpression )*
                    while ( stream_assignmentExpression.HasNext() || stream_COMMA.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_COMMA.Next());
                        adaptor.AddChild(root_1, stream_assignmentExpression.Next());

                    }
                    stream_assignmentExpression.Reset();
                    stream_COMMA.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 86, expressionList_StartIndex);
            }
            }
            return retval;
        }
Пример #5
0
        // throws RecognitionException [1]
        // $ANTLR start functionDefinition
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1549:1: functionDefinition : f= FUNCTION parameterDeclarationList (type_exp= typeExpression )? block -> ^( FUNC_DEF parameterDeclarationList ( typeExpression )? block ) ;
        public functionDefinition_return functionDefinition()
        {
            functionDefinition_return retval = new functionDefinition_return();
            retval.start = input.LT(1);
            int functionDefinition_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken f = null;
            typeExpression_return type_exp = null;

            parameterDeclarationList_return parameterDeclarationList322 = null;

            block_return block323 = null;

            CommonTree f_tree=null;
            RewriteRuleTokenStream stream_FUNCTION = new RewriteRuleTokenStream(adaptor,"token FUNCTION");
            RewriteRuleSubtreeStream stream_parameterDeclarationList = new RewriteRuleSubtreeStream(adaptor,"rule parameterDeclarationList");
            RewriteRuleSubtreeStream stream_block = new RewriteRuleSubtreeStream(adaptor,"rule block");
            RewriteRuleSubtreeStream stream_typeExpression = new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 123) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1550:4: (f= FUNCTION parameterDeclarationList (type_exp= typeExpression )? block -> ^( FUNC_DEF parameterDeclarationList ( typeExpression )? block ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1550:4: f= FUNCTION parameterDeclarationList (type_exp= typeExpression )? block
            {
                f = (CommonToken)input.LT(1);
                Match(input,FUNCTION,FOLLOW_FUNCTION_in_functionDefinition5699); if (failed) return retval;
                if ( backtracking==0 ) stream_FUNCTION.Add(f);

                if ( backtracking == 0 )
                {
                   buffer.Append(f.Text + (options.SpaceBeforeMethodDef ? " " : ""));
                }
                PushFollow(FOLLOW_parameterDeclarationList_in_functionDefinition5706);
                parameterDeclarationList322 = parameterDeclarationList();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_parameterDeclarationList.Add(parameterDeclarationList322.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1552:11: (type_exp= typeExpression )?
                int alt91 = 2;
                int LA91_0 = input.LA(1);

                if ( (LA91_0 == COLON) )
                {
                    alt91 = 1;
                }
                switch (alt91)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: type_exp= typeExpression
                        {
                            PushFollow(FOLLOW_typeExpression_in_functionDefinition5713);
                            type_exp = typeExpression();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_typeExpression.Add(type_exp.Tree);

                        }
                        break;

                }

                if ( backtracking == 0 )
                {

                  										if(options.NewlineAfterMethod) buffer.Append(NewLine + tab);
                  										buffer.Append("{");
                  										CurrentTab++;

                }
                PushFollow(FOLLOW_block_in_functionDefinition5729);
                block323 = block();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_block.Add(block323.Tree);
                if ( backtracking == 0 )
                {

                  										CurrentTab--;
                  										buffer.Append(NewLine + tab);
                  										buffer.Append("}");
                  										//buffer.Append(NewLine + tab);

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1565:3: -> ^( FUNC_DEF parameterDeclarationList ( typeExpression )? block )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1565:6: ^( FUNC_DEF parameterDeclarationList ( typeExpression )? block )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(FUNC_DEF, "FUNC_DEF"), root_1);

                    adaptor.AddChild(root_1, stream_parameterDeclarationList.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1565:42: ( typeExpression )?
                    if ( stream_typeExpression.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeExpression.Next());

                    }
                    stream_typeExpression.Reset();
                    adaptor.AddChild(root_1, stream_block.Next());

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 123, functionDefinition_StartIndex);
            }
            }
            return retval;
        }
Пример #6
0
        // throws RecognitionException [1]
        // $ANTLR start basicParameterDeclaration
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:635:1: basicParameterDeclaration : ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )? -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? ) ;
        public basicParameterDeclaration_return basicParameterDeclaration()
        {
            basicParameterDeclaration_return retval = new basicParameterDeclaration_return();
            retval.start = input.LT(1);
            int basicParameterDeclaration_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken CONST68 = null;
            ident_return ide = null;

            typeExpression_return type_exp = null;

            parameterDefault_return parameterDefault69 = null;

            CommonTree CONST68_tree=null;
            RewriteRuleTokenStream stream_CONST = new RewriteRuleTokenStream(adaptor,"token CONST");
            RewriteRuleSubtreeStream stream_parameterDefault = new RewriteRuleSubtreeStream(adaptor,"rule parameterDefault");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            RewriteRuleSubtreeStream stream_typeExpression = new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 31) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )? -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( CONST )? ide= ident (type_exp= typeExpression )? ( parameterDefault )?
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:636:4: ( CONST )?
                int alt25 = 2;
                int LA25_0 = input.LA(1);

                if ( (LA25_0 == CONST) )
                {
                    alt25 = 1;
                }
                switch (alt25)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: CONST
                        {
                            CONST68 = (CommonToken)input.LT(1);
                            Match(input,CONST,FOLLOW_CONST_in_basicParameterDeclaration1807); if (failed) return retval;
                            if ( backtracking==0 ) stream_CONST.Add(CONST68);

                        }
                        break;

                }

                PushFollow(FOLLOW_ident_in_basicParameterDeclaration1815);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)ide.Tree).Text);
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:638:11: (type_exp= typeExpression )?
                int alt26 = 2;
                int LA26_0 = input.LA(1);

                if ( (LA26_0 == COLON) )
                {
                    alt26 = 1;
                }
                switch (alt26)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: type_exp= typeExpression
                        {
                            PushFollow(FOLLOW_typeExpression_in_basicParameterDeclaration1827);
                            type_exp = typeExpression();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_typeExpression.Add(type_exp.Tree);

                        }
                        break;

                }

                if ( backtracking == 0 )
                {

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:639:3: ( parameterDefault )?
                int alt27 = 2;
                int LA27_0 = input.LA(1);

                if ( (LA27_0 == ASSIGN) )
                {
                    alt27 = 1;
                }
                switch (alt27)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: parameterDefault
                        {
                            PushFollow(FOLLOW_parameterDefault_in_basicParameterDeclaration1834);
                            parameterDefault69 = parameterDefault();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_parameterDefault.Add(parameterDefault69.Tree);

                        }
                        break;

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 640:3: -> ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:6: ^( PARAM ( CONST )? ident ( typeExpression )? ( parameterDefault )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(PARAM, "PARAM"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:14: ( CONST )?
                    if ( stream_CONST.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_CONST.Next());

                    }
                    stream_CONST.Reset();
                    adaptor.AddChild(root_1, stream_ident.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:27: ( typeExpression )?
                    if ( stream_typeExpression.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeExpression.Next());

                    }
                    stream_typeExpression.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:640:43: ( parameterDefault )?
                    if ( stream_parameterDefault.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_parameterDefault.Next());

                    }
                    stream_parameterDefault.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 31, basicParameterDeclaration_StartIndex);
            }
            }
            return retval;
        }
Пример #7
0
        // throws RecognitionException [1]
        // $ANTLR start comment
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1512:1: comment : ( singleCommentStatement ( comment )* -> ^( COMMENT_ENTRY singleCommentStatement ) ( comment )* | multiCommentStatement ( comment )* -> ^( COMMENT_ENTRY multiCommentStatement ) ( comment )* );
        public comment_return comment()
        {
            comment_return retval = new comment_return();
            retval.start = input.LT(1);
            int comment_StartIndex = input.Index();
            CommonTree root_0 = null;

            singleCommentStatement_return singleCommentStatement310 = null;

            comment_return comment311 = null;

            multiCommentStatement_return multiCommentStatement312 = null;

            comment_return comment313 = null;

            RewriteRuleSubtreeStream stream_multiCommentStatement = new RewriteRuleSubtreeStream(adaptor,"rule multiCommentStatement");
            RewriteRuleSubtreeStream stream_singleCommentStatement = new RewriteRuleSubtreeStream(adaptor,"rule singleCommentStatement");
            RewriteRuleSubtreeStream stream_comment = new RewriteRuleSubtreeStream(adaptor,"rule comment");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 118) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1513:4: ( singleCommentStatement ( comment )* -> ^( COMMENT_ENTRY singleCommentStatement ) ( comment )* | multiCommentStatement ( comment )* -> ^( COMMENT_ENTRY multiCommentStatement ) ( comment )* )
            int alt90 = 2;
            int LA90_0 = input.LA(1);

            if ( (LA90_0 == SL_COMMENT) )
            {
                alt90 = 1;
            }
            else if ( (LA90_0 == ML_COMMENT) )
            {
                alt90 = 2;
            }
            else
            {
                if ( backtracking > 0 ) {failed = true; return retval;}
                NoViableAltException nvae_d90s0 =
                    new NoViableAltException("1512:1: comment : ( singleCommentStatement ( comment )* -> ^( COMMENT_ENTRY singleCommentStatement ) ( comment )* | multiCommentStatement ( comment )* -> ^( COMMENT_ENTRY multiCommentStatement ) ( comment )* );", 90, 0, input);

                throw nvae_d90s0;
            }
            switch (alt90)
            {
                case 1 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1513:4: singleCommentStatement ( comment )*
                    {
                        PushFollow(FOLLOW_singleCommentStatement_in_comment5523);
                        singleCommentStatement310 = singleCommentStatement();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_singleCommentStatement.Add(singleCommentStatement310.Tree);
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1513:27: ( comment )*
                        do
                        {
                            int alt88 = 2;
                            int LA88_0 = input.LA(1);

                            if ( (LA88_0 == SL_COMMENT) )
                            {
                                int LA88_15 = input.LA(2);

                                if ( (synpred177()) )
                                {
                                    alt88 = 1;
                                }

                            }
                            else if ( (LA88_0 == ML_COMMENT) )
                            {
                                int LA88_16 = input.LA(2);

                                if ( (synpred177()) )
                                {
                                    alt88 = 1;
                                }

                            }

                            switch (alt88)
                            {
                                case 1 :
                                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: comment
                                    {
                                        PushFollow(FOLLOW_comment_in_comment5525);
                                        comment311 = comment();
                                        followingStackPointer_--;
                                        if (failed) return retval;
                                        if ( backtracking==0 ) stream_comment.Add(comment311.Tree);

                                    }
                                    break;

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

                        loop88:
                            ;	// Stops C# compiler whinging that label 'loop88' has no statements

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

                        root_0 = (CommonTree)adaptor.GetNilNode();
                        // 1513:36: -> ^( COMMENT_ENTRY singleCommentStatement ) ( comment )*
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1513:39: ^( COMMENT_ENTRY singleCommentStatement )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(COMMENT_ENTRY, "COMMENT_ENTRY"), root_1);

                            adaptor.AddChild(root_1, stream_singleCommentStatement.Next());

                            adaptor.AddChild(root_0, root_1);
                            }
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1513:79: ( comment )*
                            while ( stream_comment.HasNext() )
                            {
                                adaptor.AddChild(root_0, stream_comment.Next());

                            }
                            stream_comment.Reset();

                        }

                        }

                    }
                    break;
                case 2 :
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1514:4: multiCommentStatement ( comment )*
                    {
                        PushFollow(FOLLOW_multiCommentStatement_in_comment5542);
                        multiCommentStatement312 = multiCommentStatement();
                        followingStackPointer_--;
                        if (failed) return retval;
                        if ( backtracking==0 ) stream_multiCommentStatement.Add(multiCommentStatement312.Tree);
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1514:27: ( comment )*
                        do
                        {
                            int alt89 = 2;
                            int LA89_0 = input.LA(1);

                            if ( (LA89_0 == SL_COMMENT) )
                            {
                                int LA89_15 = input.LA(2);

                                if ( (synpred179()) )
                                {
                                    alt89 = 1;
                                }

                            }
                            else if ( (LA89_0 == ML_COMMENT) )
                            {
                                int LA89_16 = input.LA(2);

                                if ( (synpred179()) )
                                {
                                    alt89 = 1;
                                }

                            }

                            switch (alt89)
                            {
                                case 1 :
                                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: comment
                                    {
                                        PushFollow(FOLLOW_comment_in_comment5545);
                                        comment313 = comment();
                                        followingStackPointer_--;
                                        if (failed) return retval;
                                        if ( backtracking==0 ) stream_comment.Add(comment313.Tree);

                                    }
                                    break;

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

                        loop89:
                            ;	// Stops C# compiler whinging that label 'loop89' has no statements

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

                        root_0 = (CommonTree)adaptor.GetNilNode();
                        // 1514:36: -> ^( COMMENT_ENTRY multiCommentStatement ) ( comment )*
                        {
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1514:39: ^( COMMENT_ENTRY multiCommentStatement )
                            {
                            CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                            root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(COMMENT_ENTRY, "COMMENT_ENTRY"), root_1);

                            adaptor.AddChild(root_1, stream_multiCommentStatement.Next());

                            adaptor.AddChild(root_0, root_1);
                            }
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1514:78: ( comment )*
                            while ( stream_comment.HasNext() )
                            {
                                adaptor.AddChild(root_0, stream_comment.Next());

                            }
                            stream_comment.Reset();

                        }

                        }

                    }
                    break;

            }
            retval.stop = input.LT(-1);

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 118, comment_StartIndex);
            }
            }
            return retval;
        }
Пример #8
0
        // throws RecognitionException [1]
        // $ANTLR start optionalAccessorRole
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:546:1: optionalAccessorRole : ( accessorRole )? -> ^( ACCESSOR_ROLE ( accessorRole )? ) ;
        public optionalAccessorRole_return optionalAccessorRole()
        {
            optionalAccessorRole_return retval = new optionalAccessorRole_return();
            retval.start = input.LT(1);
            int optionalAccessorRole_StartIndex = input.Index();
            CommonTree root_0 = null;

            accessorRole_return accessorRole47 = null;

            RewriteRuleSubtreeStream stream_accessorRole = new RewriteRuleSubtreeStream(adaptor,"rule accessorRole");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 21) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:547:4: ( ( accessorRole )? -> ^( ACCESSOR_ROLE ( accessorRole )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:547:4: ( accessorRole )?
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:547:4: ( accessorRole )?
                int alt17 = 2;
                int LA17_0 = input.LA(1);

                if ( (LA17_0 == GET) )
                {
                    int LA17_1 = input.LA(2);

                    if ( ((LA17_1 >= GET && LA17_1 <= SET) || LA17_1 == IDENT || LA17_1 == DYNAMIC || (LA17_1 >= IS && LA17_1 <= AS) || (LA17_1 >= USE && LA17_1 <= XML)) )
                    {
                        alt17 = 1;
                    }
                }
                else if ( (LA17_0 == SET) )
                {
                    int LA17_2 = input.LA(2);

                    if ( ((LA17_2 >= GET && LA17_2 <= SET) || LA17_2 == IDENT || LA17_2 == DYNAMIC || (LA17_2 >= IS && LA17_2 <= AS) || (LA17_2 >= USE && LA17_2 <= XML)) )
                    {
                        alt17 = 1;
                    }
                }
                switch (alt17)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: accessorRole
                        {
                            PushFollow(FOLLOW_accessorRole_in_optionalAccessorRole1447);
                            accessorRole47 = accessorRole();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_accessorRole.Add(accessorRole47.Tree);

                        }
                        break;

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 548:3: -> ^( ACCESSOR_ROLE ( accessorRole )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:548:6: ^( ACCESSOR_ROLE ( accessorRole )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ACCESSOR_ROLE, "ACCESSOR_ROLE"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:548:22: ( accessorRole )?
                    if ( stream_accessorRole.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_accessorRole.Next());

                    }
                    stream_accessorRole.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 21, optionalAccessorRole_StartIndex);
            }
            }
            return retval;
        }
Пример #9
0
        // throws RecognitionException [1]
        // $ANTLR start parameterDeclarationList
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:618:1: parameterDeclarationList : LPAREN ( parameterDeclaration ( COMMA parameterDeclaration )* )? RPAREN -> ^( PARAMS ( parameterDeclaration )* ) ;
        public parameterDeclarationList_return parameterDeclarationList()
        {
            parameterDeclarationList_return retval = new parameterDeclarationList_return();
            retval.start = input.LT(1);
            int parameterDeclarationList_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LPAREN62 = null;
            CommonToken COMMA64 = null;
            CommonToken RPAREN66 = null;
            parameterDeclaration_return parameterDeclaration63 = null;

            parameterDeclaration_return parameterDeclaration65 = null;

            CommonTree LPAREN62_tree=null;
            CommonTree COMMA64_tree=null;
            CommonTree RPAREN66_tree=null;
            RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");
            RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor,"token RPAREN");
            RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor,"token LPAREN");
            RewriteRuleSubtreeStream stream_parameterDeclaration = new RewriteRuleSubtreeStream(adaptor,"rule parameterDeclaration");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 29) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:619:4: ( LPAREN ( parameterDeclaration ( COMMA parameterDeclaration )* )? RPAREN -> ^( PARAMS ( parameterDeclaration )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:619:4: LPAREN ( parameterDeclaration ( COMMA parameterDeclaration )* )? RPAREN
            {
                LPAREN62 = (CommonToken)input.LT(1);
                Match(input,LPAREN,FOLLOW_LPAREN_in_parameterDeclarationList1724); if (failed) return retval;
                if ( backtracking==0 ) stream_LPAREN.Add(LPAREN62);

                if ( backtracking == 0 )
                {
                   buffer.Append(options.SpaceBeforeMethodDef ? " (" : "(");
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:620:3: ( parameterDeclaration ( COMMA parameterDeclaration )* )?
                int alt24 = 2;
                int LA24_0 = input.LA(1);

                if ( ((LA24_0 >= GET && LA24_0 <= SET) || LA24_0 == CONST || LA24_0 == IDENT || LA24_0 == DYNAMIC || (LA24_0 >= IS && LA24_0 <= AS) || (LA24_0 >= USE && LA24_0 <= XML)) )
                {
                    alt24 = 1;
                }
                switch (alt24)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:620:5: parameterDeclaration ( COMMA parameterDeclaration )*
                        {
                            PushFollow(FOLLOW_parameterDeclaration_in_parameterDeclarationList1734);
                            parameterDeclaration63 = parameterDeclaration();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_parameterDeclaration.Add(parameterDeclaration63.Tree);
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:621:4: ( COMMA parameterDeclaration )*
                            do
                            {
                                int alt23 = 2;
                                int LA23_0 = input.LA(1);

                                if ( (LA23_0 == COMMA) )
                                {
                                    alt23 = 1;
                                }

                                switch (alt23)
                                {
                                    case 1 :
                                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:622:5: COMMA parameterDeclaration
                                        {
                                            COMMA64 = (CommonToken)input.LT(1);
                                            Match(input,COMMA,FOLLOW_COMMA_in_parameterDeclarationList1745); if (failed) return retval;
                                            if ( backtracking==0 ) stream_COMMA.Add(COMMA64);

                                            if ( backtracking == 0 )
                                            {
                                               buffer.Append(options.SpaceBetweenArguments ? ", " : ",");
                                            }
                                            PushFollow(FOLLOW_parameterDeclaration_in_parameterDeclarationList1754);
                                            parameterDeclaration65 = parameterDeclaration();
                                            followingStackPointer_--;
                                            if (failed) return retval;
                                            if ( backtracking==0 ) stream_parameterDeclaration.Add(parameterDeclaration65.Tree);

                                        }
                                        break;

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

                            loop23:
                                ;	// Stops C# compiler whinging that label 'loop23' has no statements

                        }
                        break;

                }

                RPAREN66 = (CommonToken)input.LT(1);
                Match(input,RPAREN,FOLLOW_RPAREN_in_parameterDeclarationList1769); if (failed) return retval;
                if ( backtracking==0 ) stream_RPAREN.Add(RPAREN66);

                if ( backtracking == 0 )
                {
                   buffer.Append(")");
                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 627:3: -> ^( PARAMS ( parameterDeclaration )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:627:6: ^( PARAMS ( parameterDeclaration )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(PARAMS, "PARAMS"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:627:15: ( parameterDeclaration )*
                    while ( stream_parameterDeclaration.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_parameterDeclaration.Next());

                    }
                    stream_parameterDeclaration.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 29, parameterDeclarationList_StartIndex);
            }
            }
            return retval;
        }
Пример #10
0
        // throws RecognitionException [1]
        // $ANTLR start modifiers
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1097:1: modifiers : ( modifier )* -> ^( MODIFIERS ( modifier )* ) ;
        public modifiers_return modifiers()
        {
            modifiers_return retval = new modifiers_return();
            retval.start = input.LT(1);
            int modifiers_StartIndex = input.Index();
            CommonTree root_0 = null;

            modifier_return modifier193 = null;

            RewriteRuleSubtreeStream stream_modifier = new RewriteRuleSubtreeStream(adaptor,"rule modifier");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 74) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1098:4: ( ( modifier )* -> ^( MODIFIERS ( modifier )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1098:4: ( modifier )*
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1098:4: ( modifier )*
                do
                {
                    int alt55 = 2;
                    int LA55_0 = input.LA(1);

                    if ( ((LA55_0 >= IDENT && LA55_0 <= INTERNAL) || (LA55_0 >= STATIC && LA55_0 <= DYNAMIC) || (LA55_0 >= 180 && LA55_0 <= 184)) )
                    {
                        alt55 = 1;
                    }

                    switch (alt55)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: modifier
                            {
                                PushFollow(FOLLOW_modifier_in_modifiers3690);
                                modifier193 = modifier();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_modifier.Add(modifier193.Tree);

                            }
                            break;

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

                loop55:
                    ;	// Stops C# compiler whinging that label 'loop55' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1099:3: -> ^( MODIFIERS ( modifier )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1099:6: ^( MODIFIERS ( modifier )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(MODIFIERS, "MODIFIERS"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1099:18: ( modifier )*
                    while ( stream_modifier.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_modifier.Next());

                    }
                    stream_modifier.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 74, modifiers_StartIndex);
            }
            }
            return retval;
        }
Пример #11
0
        // throws RecognitionException [1]
        // $ANTLR start objectLiteral
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1159:1: objectLiteral : LCURLY ( fieldList )? RCURLY -> ^( OBJECT_LITERAL ( fieldList )? ) ;
        public objectLiteral_return objectLiteral()
        {
            objectLiteral_return retval = new objectLiteral_return();
            retval.start = input.LT(1);
            int objectLiteral_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LCURLY217 = null;
            CommonToken RCURLY219 = null;
            fieldList_return fieldList218 = null;

            CommonTree LCURLY217_tree=null;
            CommonTree RCURLY219_tree=null;
            RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor,"token LCURLY");
            RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor,"token RCURLY");
            RewriteRuleSubtreeStream stream_fieldList = new RewriteRuleSubtreeStream(adaptor,"rule fieldList");

            int next_token = -1;

            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 81) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1163:4: ( LCURLY ( fieldList )? RCURLY -> ^( OBJECT_LITERAL ( fieldList )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1163:4: LCURLY ( fieldList )? RCURLY
            {
                LCURLY217 = (CommonToken)input.LT(1);
                Match(input,LCURLY,FOLLOW_LCURLY_in_objectLiteral3958); if (failed) return retval;
                if ( backtracking==0 ) stream_LCURLY.Add(LCURLY217);

                if ( backtracking == 0 )
                {

                  							buffer.Append("{");
                  							next_token = input.LA(1);
                  							if(next_token != ASLexer.RCURLY && options.NewlineBetweenFields)
                  							{
                  								CurrentTab++;
                  								buffer.Append(NewLine + tab);
                  							}

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1172:3: ( fieldList )?
                int alt62 = 2;
                int LA62_0 = input.LA(1);

                if ( ((LA62_0 >= GET && LA62_0 <= SET) || LA62_0 == IDENT || LA62_0 == DYNAMIC || (LA62_0 >= IS && LA62_0 <= AS) || (LA62_0 >= HEX_LITERAL && LA62_0 <= FLOAT_LITERAL) || (LA62_0 >= USE && LA62_0 <= XML)) )
                {
                    alt62 = 1;
                }
                switch (alt62)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: fieldList
                        {
                            PushFollow(FOLLOW_fieldList_in_objectLiteral3967);
                            fieldList218 = fieldList();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_fieldList.Add(fieldList218.Tree);

                        }
                        break;

                }

                RCURLY219 = (CommonToken)input.LT(1);
                Match(input,RCURLY,FOLLOW_RCURLY_in_objectLiteral3973); if (failed) return retval;
                if ( backtracking==0 ) stream_RCURLY.Add(RCURLY219);

                if ( backtracking == 0 )
                {

                  							if(next_token != ASLexer.RCURLY && options.NewlineBetweenFields)
                  							{
                  								CurrentTab--;
                  								buffer.Append(NewLine + tab);
                  							}
                  							buffer.Append("}");

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1181:3: -> ^( OBJECT_LITERAL ( fieldList )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1181:6: ^( OBJECT_LITERAL ( fieldList )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(OBJECT_LITERAL, "OBJECT_LITERAL"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1181:23: ( fieldList )?
                    if ( stream_fieldList.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_fieldList.Next());

                    }
                    stream_fieldList.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 81, objectLiteral_StartIndex);
            }
            }
            return retval;
        }
Пример #12
0
        // throws RecognitionException [1]
        // $ANTLR start methodDefinition
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:511:1: methodDefinition[CommonTree mods] : FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( (c1= comments )? block semi ) -> ^( METHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? block ) ;
        public methodDefinition_return methodDefinition(CommonTree mods)
        {
            methodDefinition_return retval = new methodDefinition_return();
            retval.start = input.LT(1);
            int methodDefinition_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken FUNCTION43 = null;
            optionalAccessorRole_return r = null;

            ident_return ide = null;

            typeExpression_return type_exp = null;

            comments_return c1 = null;

            parameterDeclarationList_return parameterDeclarationList44 = null;

            block_return block45 = null;

            semi_return semi46 = null;

            CommonTree FUNCTION43_tree=null;
            RewriteRuleTokenStream stream_FUNCTION = new RewriteRuleTokenStream(adaptor,"token FUNCTION");
            RewriteRuleSubtreeStream stream_optionalAccessorRole = new RewriteRuleSubtreeStream(adaptor,"rule optionalAccessorRole");
            RewriteRuleSubtreeStream stream_semi = new RewriteRuleSubtreeStream(adaptor,"rule semi");
            RewriteRuleSubtreeStream stream_parameterDeclarationList = new RewriteRuleSubtreeStream(adaptor,"rule parameterDeclarationList");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            RewriteRuleSubtreeStream stream_comments = new RewriteRuleSubtreeStream(adaptor,"rule comments");
            RewriteRuleSubtreeStream stream_block = new RewriteRuleSubtreeStream(adaptor,"rule block");
            RewriteRuleSubtreeStream stream_typeExpression = new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 20) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:512:4: ( FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( (c1= comments )? block semi ) -> ^( METHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? block ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:512:4: FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( (c1= comments )? block semi )
            {
                if ( backtracking == 0 )
                {

                  			if(mods.ChildCount > 0)
                  				buffer.Append(fromModifiers(mods) + " ");

                }
                FUNCTION43 = (CommonToken)input.LT(1);
                Match(input,FUNCTION,FOLLOW_FUNCTION_in_methodDefinition1283); if (failed) return retval;
                if ( backtracking==0 ) stream_FUNCTION.Add(FUNCTION43);

                if ( backtracking == 0 )
                {
                   buffer.Append("function ");
                }
                PushFollow(FOLLOW_optionalAccessorRole_in_methodDefinition1295);
                r = optionalAccessorRole();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_optionalAccessorRole.Add(r.Tree);
                PushFollow(FOLLOW_ident_in_methodDefinition1301);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)ide.Tree).Text);
                }
                PushFollow(FOLLOW_parameterDeclarationList_in_methodDefinition1319);
                parameterDeclarationList44 = parameterDeclarationList();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_parameterDeclarationList.Add(parameterDeclarationList44.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:522:11: (type_exp= typeExpression )?
                int alt15 = 2;
                int LA15_0 = input.LA(1);

                if ( (LA15_0 == COLON) )
                {
                    alt15 = 1;
                }
                switch (alt15)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: type_exp= typeExpression
                        {
                            PushFollow(FOLLOW_typeExpression_in_methodDefinition1325);
                            type_exp = typeExpression();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_typeExpression.Add(type_exp.Tree);

                        }
                        break;

                }

                if ( backtracking == 0 )
                {

                  										if(options.NewlineAfterMethod) buffer.Append(NewLine + tab);
                  										buffer.Append("{");
                  										CurrentTab++;

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:528:3: ( (c1= comments )? block semi )
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:529:4: (c1= comments )? block semi
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:529:6: (c1= comments )?
                    int alt16 = 2;
                    int LA16_0 = input.LA(1);

                    if ( ((LA16_0 >= SL_COMMENT && LA16_0 <= ML_COMMENT)) )
                    {
                        alt16 = 1;
                    }
                    switch (alt16)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: c1= comments
                            {
                                PushFollow(FOLLOW_comments_in_methodDefinition1348);
                                c1 = comments();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_comments.Add(c1.Tree);

                            }
                            break;

                    }

                    if ( backtracking == 0 )
                    {
                       insertComment(c1, true, false);
                    }
                    PushFollow(FOLLOW_block_in_methodDefinition1358);
                    block45 = block();
                    followingStackPointer_--;
                    if (failed) return retval;
                    if ( backtracking==0 ) stream_block.Add(block45.Tree);
                    PushFollow(FOLLOW_semi_in_methodDefinition1360);
                    semi46 = semi();
                    followingStackPointer_--;
                    if (failed) return retval;
                    if ( backtracking==0 ) stream_semi.Add(semi46.Tree);

                }

                if ( backtracking == 0 )
                {

                  										CurrentTab--;
                  										buffer.Append(NewLine + tab);
                  										buffer.Append("}");
                  										buffer.Append(NewLine + tab);

                }

                // AST REWRITE
                // elements:          block, parameterDeclarationList, ident, typeExpression, optionalAccessorRole
                // token labels:
                // rule labels:       retval
                // token list labels:
                // rule list labels:
                if ( backtracking==0 ) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "token retval", (retval!=null ? retval.Tree : null));

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 538:3: -> ^( METHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? block )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:538:6: ^( METHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? block )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(METHOD_DEF, "METHOD_DEF"), root_1);

                    adaptor.AddChild(root_1, mods);
                    adaptor.AddChild(root_1, stream_optionalAccessorRole.Next());
                    adaptor.AddChild(root_1, stream_ident.Next());
                    adaptor.AddChild(root_1, stream_parameterDeclarationList.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:541:7: ( typeExpression )?
                    if ( stream_typeExpression.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeExpression.Next());

                    }
                    stream_typeExpression.Reset();
                    adaptor.AddChild(root_1, stream_block.Next());

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 20, methodDefinition_StartIndex);
            }
            }
            return retval;
        }
Пример #13
0
        // throws RecognitionException [1]
        // $ANTLR start interfaceMethodDefinition
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:492:1: interfaceMethodDefinition[CommonTree mods] : FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( semi ) -> ^( IMETHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? ) ;
        public interfaceMethodDefinition_return interfaceMethodDefinition(CommonTree mods)
        {
            interfaceMethodDefinition_return retval = new interfaceMethodDefinition_return();
            retval.start = input.LT(1);
            int interfaceMethodDefinition_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken FUNCTION40 = null;
            optionalAccessorRole_return r = null;

            ident_return ide = null;

            typeExpression_return type_exp = null;

            parameterDeclarationList_return parameterDeclarationList41 = null;

            semi_return semi42 = null;

            CommonTree FUNCTION40_tree=null;
            RewriteRuleTokenStream stream_FUNCTION = new RewriteRuleTokenStream(adaptor,"token FUNCTION");
            RewriteRuleSubtreeStream stream_optionalAccessorRole = new RewriteRuleSubtreeStream(adaptor,"rule optionalAccessorRole");
            RewriteRuleSubtreeStream stream_semi = new RewriteRuleSubtreeStream(adaptor,"rule semi");
            RewriteRuleSubtreeStream stream_parameterDeclarationList = new RewriteRuleSubtreeStream(adaptor,"rule parameterDeclarationList");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            RewriteRuleSubtreeStream stream_typeExpression = new RewriteRuleSubtreeStream(adaptor,"rule typeExpression");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 19) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:493:4: ( FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( semi ) -> ^( IMETHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:493:4: FUNCTION r= optionalAccessorRole ide= ident parameterDeclarationList (type_exp= typeExpression )? ( semi )
            {
                FUNCTION40 = (CommonToken)input.LT(1);
                Match(input,FUNCTION,FOLLOW_FUNCTION_in_interfaceMethodDefinition1170); if (failed) return retval;
                if ( backtracking==0 ) stream_FUNCTION.Add(FUNCTION40);

                if ( backtracking == 0 )
                {
                   buffer.Append("function ");
                }
                PushFollow(FOLLOW_optionalAccessorRole_in_interfaceMethodDefinition1182);
                r = optionalAccessorRole();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_optionalAccessorRole.Add(r.Tree);
                PushFollow(FOLLOW_ident_in_interfaceMethodDefinition1188);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)ide.Tree).Text);
                }
                PushFollow(FOLLOW_parameterDeclarationList_in_interfaceMethodDefinition1198);
                parameterDeclarationList41 = parameterDeclarationList();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_parameterDeclarationList.Add(parameterDeclarationList41.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:497:11: (type_exp= typeExpression )?
                int alt14 = 2;
                int LA14_0 = input.LA(1);

                if ( (LA14_0 == COLON) )
                {
                    alt14 = 1;
                }
                switch (alt14)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: type_exp= typeExpression
                        {
                            PushFollow(FOLLOW_typeExpression_in_interfaceMethodDefinition1204);
                            type_exp = typeExpression();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_typeExpression.Add(type_exp.Tree);

                        }
                        break;

                }

                if ( backtracking == 0 )
                {

                  										if(options.NewlineAfterMethod) buffer.Append(NewLine + tab);
                  										buffer.Append("{");
                  										CurrentTab++;

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:502:3: ( semi )
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:502:4: semi
                {
                    PushFollow(FOLLOW_semi_in_interfaceMethodDefinition1212);
                    semi42 = semi();
                    followingStackPointer_--;
                    if (failed) return retval;
                    if ( backtracking==0 ) stream_semi.Add(semi42.Tree);

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 503:3: -> ^( IMETHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:503:6: ^( IMETHOD_DEF optionalAccessorRole ident parameterDeclarationList ( typeExpression )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(IMETHOD_DEF, "IMETHOD_DEF"), root_1);

                    adaptor.AddChild(root_1, mods);
                    adaptor.AddChild(root_1, stream_optionalAccessorRole.Next());
                    adaptor.AddChild(root_1, stream_ident.Next());
                    adaptor.AddChild(root_1, stream_parameterDeclarationList.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:506:7: ( typeExpression )?
                    if ( stream_typeExpression.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeExpression.Next());

                    }
                    stream_typeExpression.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 19, interfaceMethodDefinition_StartIndex);
            }
            }
            return retval;
        }
Пример #14
0
        // throws RecognitionException [1]
        // $ANTLR start identifierStar
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1049:1: identifierStar : ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )? -> ^( IDENTIFIER ( ident )+ ( STAR )? ) ;
        public identifierStar_return identifierStar()
        {
            identifierStar_return retval = new identifierStar_return();
            retval.start = input.LT(1);
            int identifierStar_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken DOT178 = null;
            CommonToken DOT179 = null;
            CommonToken STAR180 = null;
            ident_return ide = null;

            ident_return ide2 = null;

            CommonTree DOT178_tree=null;
            CommonTree DOT179_tree=null;
            CommonTree STAR180_tree=null;
            RewriteRuleTokenStream stream_STAR = new RewriteRuleTokenStream(adaptor,"token STAR");
            RewriteRuleTokenStream stream_DOT = new RewriteRuleTokenStream(adaptor,"token DOT");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 69) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1050:4: (ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )? -> ^( IDENTIFIER ( ident )+ ( STAR )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1050:4: ide= ident ( options {greedy=true; } : DOT ide2= ident )* ( DOT STAR )?
            {
                PushFollow(FOLLOW_ident_in_identifierStar3335);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1051:3: ( options {greedy=true; } : DOT ide2= ident )*
                do
                {
                    int alt48 = 2;
                    int LA48_0 = input.LA(1);

                    if ( (LA48_0 == DOT) )
                    {
                        int LA48_1 = input.LA(2);

                        if ( ((LA48_1 >= GET && LA48_1 <= SET) || LA48_1 == IDENT || LA48_1 == DYNAMIC || (LA48_1 >= IS && LA48_1 <= AS) || (LA48_1 >= USE && LA48_1 <= XML)) )
                        {
                            alt48 = 1;
                        }

                    }

                    switch (alt48)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1052:5: DOT ide2= ident
                            {
                                DOT178 = (CommonToken)input.LT(1);
                                Match(input,DOT,FOLLOW_DOT_in_identifierStar3357); if (failed) return retval;
                                if ( backtracking==0 ) stream_DOT.Add(DOT178);

                                PushFollow(FOLLOW_ident_in_identifierStar3361);
                                ide2 = ident();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_ident.Add(ide2.Tree);

                            }
                            break;

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

                loop48:
                    ;	// Stops C# compiler whinging that label 'loop48' has no statements

                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1054:3: ( DOT STAR )?
                int alt49 = 2;
                int LA49_0 = input.LA(1);

                if ( (LA49_0 == DOT) )
                {
                    alt49 = 1;
                }
                switch (alt49)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1054:5: DOT STAR
                        {
                            DOT179 = (CommonToken)input.LT(1);
                            Match(input,DOT,FOLLOW_DOT_in_identifierStar3376); if (failed) return retval;
                            if ( backtracking==0 ) stream_DOT.Add(DOT179);

                            STAR180 = (CommonToken)input.LT(1);
                            Match(input,STAR,FOLLOW_STAR_in_identifierStar3378); if (failed) return retval;
                            if ( backtracking==0 ) stream_STAR.Add(STAR180);

                        }
                        break;

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1056:3: -> ^( IDENTIFIER ( ident )+ ( STAR )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1056:6: ^( IDENTIFIER ( ident )+ ( STAR )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(IDENTIFIER, "IDENTIFIER"), root_1);

                    if ( !(stream_ident.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_ident.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_ident.Next());

                    }
                    stream_ident.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1056:26: ( STAR )?
                    if ( stream_STAR.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_STAR.Next());

                    }
                    stream_STAR.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 69, identifierStar_StartIndex);
            }
            }
            return retval;
        }
Пример #15
0
        // throws RecognitionException [1]
        // $ANTLR start annotations
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1059:1: annotations : ( ( annotation ) | ( includeDirective ) )+ -> ^( ANNOTATIONS ( annotation )+ ) ;
        public annotations_return annotations()
        {
            annotations_return retval = new annotations_return();
            retval.start = input.LT(1);
            int annotations_StartIndex = input.Index();
            CommonTree root_0 = null;

            annotation_return annotation181 = null;

            includeDirective_return includeDirective182 = null;

            RewriteRuleSubtreeStream stream_includeDirective = new RewriteRuleSubtreeStream(adaptor,"rule includeDirective");
            RewriteRuleSubtreeStream stream_annotation = new RewriteRuleSubtreeStream(adaptor,"rule annotation");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 70) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1060:4: ( ( ( annotation ) | ( includeDirective ) )+ -> ^( ANNOTATIONS ( annotation )+ ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1060:4: ( ( annotation ) | ( includeDirective ) )+
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1060:4: ( ( annotation ) | ( includeDirective ) )+
                int cnt50 = 0;
                do
                {
                    int alt50 = 3;
                    int LA50_0 = input.LA(1);

                    if ( (LA50_0 == LBRACK) )
                    {
                        int LA50_13 = input.LA(2);

                        if ( (synpred78()) )
                        {
                            alt50 = 1;
                        }

                    }
                    else if ( (LA50_0 == 175) )
                    {
                        int LA50_14 = input.LA(2);

                        if ( (synpred79()) )
                        {
                            alt50 = 2;
                        }

                    }

                    switch (alt50)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1061:5: ( annotation )
                            {
                                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1061:5: ( annotation )
                                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1061:7: annotation
                                {
                                    if ( backtracking == 0 )
                                    {
                                       buffer.Append(NewLine + tab);
                                    }
                                    PushFollow(FOLLOW_annotation_in_annotations3424);
                                    annotation181 = annotation();
                                    followingStackPointer_--;
                                    if (failed) return retval;
                                    if ( backtracking==0 ) stream_annotation.Add(annotation181.Tree);

                                }

                            }
                            break;
                        case 2 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1062:6: ( includeDirective )
                            {
                                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1062:6: ( includeDirective )
                                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1062:8: includeDirective
                                {
                                    if ( backtracking == 0 )
                                    {
                                       buffer.Append(NewLine + tab);
                                    }
                                    PushFollow(FOLLOW_includeDirective_in_annotations3437);
                                    includeDirective182 = includeDirective();
                                    followingStackPointer_--;
                                    if (failed) return retval;
                                    if ( backtracking==0 ) stream_includeDirective.Add(includeDirective182.Tree);

                                }

                            }
                            break;

                        default:
                            if ( cnt50 >= 1 ) goto loop50;
                            if ( backtracking > 0 ) {failed = true; return retval;}
                                EarlyExitException eee =
                                    new EarlyExitException(50, input);
                                throw eee;
                    }
                    cnt50++;
                } while (true);

                loop50:
                    ;	// Stops C# compiler whinging that label 'loop50' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1064:3: -> ^( ANNOTATIONS ( annotation )+ )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1064:6: ^( ANNOTATIONS ( annotation )+ )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ANNOTATIONS, "ANNOTATIONS"), root_1);

                    if ( !(stream_annotation.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_annotation.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_annotation.Next());

                    }
                    stream_annotation.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 70, annotations_StartIndex);
            }
            }
            return retval;
        }
Пример #16
0
        // throws RecognitionException [1]
        // $ANTLR start annotation
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1067:1: annotation : LBRACK ide= ident ( annotationParamList )? RBRACK -> ^( ANNOTATION ident ( annotationParamList )? ) ;
        public annotation_return annotation()
        {
            annotation_return retval = new annotation_return();
            retval.start = input.LT(1);
            int annotation_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LBRACK183 = null;
            CommonToken RBRACK185 = null;
            ident_return ide = null;

            annotationParamList_return annotationParamList184 = null;

            CommonTree LBRACK183_tree=null;
            CommonTree RBRACK185_tree=null;
            RewriteRuleTokenStream stream_LBRACK = new RewriteRuleTokenStream(adaptor,"token LBRACK");
            RewriteRuleTokenStream stream_RBRACK = new RewriteRuleTokenStream(adaptor,"token RBRACK");
            RewriteRuleSubtreeStream stream_annotationParamList = new RewriteRuleSubtreeStream(adaptor,"rule annotationParamList");
            RewriteRuleSubtreeStream stream_ident = new RewriteRuleSubtreeStream(adaptor,"rule ident");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 71) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1068:4: ( LBRACK ide= ident ( annotationParamList )? RBRACK -> ^( ANNOTATION ident ( annotationParamList )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1068:4: LBRACK ide= ident ( annotationParamList )? RBRACK
            {
                LBRACK183 = (CommonToken)input.LT(1);
                Match(input,LBRACK,FOLLOW_LBRACK_in_annotation3466); if (failed) return retval;
                if ( backtracking==0 ) stream_LBRACK.Add(LBRACK183);

                if ( backtracking == 0 )
                {
                   buffer.Append("[");
                }
                PushFollow(FOLLOW_ident_in_annotation3478);
                ide = ident();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_ident.Add(ide.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)ide.Tree).Text);
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1070:3: ( annotationParamList )?
                int alt51 = 2;
                int LA51_0 = input.LA(1);

                if ( (LA51_0 == LPAREN) )
                {
                    alt51 = 1;
                }
                switch (alt51)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: annotationParamList
                        {
                            PushFollow(FOLLOW_annotationParamList_in_annotation3487);
                            annotationParamList184 = annotationParamList();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_annotationParamList.Add(annotationParamList184.Tree);

                        }
                        break;

                }

                RBRACK185 = (CommonToken)input.LT(1);
                Match(input,RBRACK,FOLLOW_RBRACK_in_annotation3492); if (failed) return retval;
                if ( backtracking==0 ) stream_RBRACK.Add(RBRACK185);

                if ( backtracking == 0 )
                {
                   buffer.Append("]");
                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1072:3: -> ^( ANNOTATION ident ( annotationParamList )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1072:6: ^( ANNOTATION ident ( annotationParamList )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ANNOTATION, "ANNOTATION"), root_1);

                    adaptor.AddChild(root_1, stream_ident.Next());
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1072:25: ( annotationParamList )?
                    if ( stream_annotationParamList.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_annotationParamList.Next());

                    }
                    stream_annotationParamList.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 71, annotation_StartIndex);
            }
            }
            return retval;
        }
Пример #17
0
        // throws RecognitionException [1]
        // $ANTLR start arrayLiteral
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1133:1: arrayLiteral : LBRACK ( elementList )? RBRACK -> ^( ARRAY_LITERAL ( elementList )? ) ;
        public arrayLiteral_return arrayLiteral()
        {
            arrayLiteral_return retval = new arrayLiteral_return();
            retval.start = input.LT(1);
            int arrayLiteral_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LBRACK208 = null;
            CommonToken RBRACK210 = null;
            elementList_return elementList209 = null;

            CommonTree LBRACK208_tree=null;
            CommonTree RBRACK210_tree=null;
            RewriteRuleTokenStream stream_LBRACK = new RewriteRuleTokenStream(adaptor,"token LBRACK");
            RewriteRuleTokenStream stream_RBRACK = new RewriteRuleTokenStream(adaptor,"token RBRACK");
            RewriteRuleSubtreeStream stream_elementList = new RewriteRuleSubtreeStream(adaptor,"rule elementList");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 78) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1134:4: ( LBRACK ( elementList )? RBRACK -> ^( ARRAY_LITERAL ( elementList )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1134:4: LBRACK ( elementList )? RBRACK
            {
                LBRACK208 = (CommonToken)input.LT(1);
                Match(input,LBRACK,FOLLOW_LBRACK_in_arrayLiteral3832); if (failed) return retval;
                if ( backtracking==0 ) stream_LBRACK.Add(LBRACK208);

                if ( backtracking == 0 )
                {
                   buffer.Append("[");
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1134:35: ( elementList )?
                int alt58 = 2;
                int LA58_0 = input.LA(1);

                if ( (LA58_0 == LCURLY || (LA58_0 >= STRING_LITERAL && LA58_0 <= SET) || LA58_0 == LPAREN || LA58_0 == VOID || LA58_0 == IDENT || LA58_0 == LBRACK || LA58_0 == DYNAMIC || (LA58_0 >= IS && LA58_0 <= AS) || (LA58_0 >= PLUS && LA58_0 <= MINUS) || (LA58_0 >= INC && LA58_0 <= NEW) || (LA58_0 >= USE && LA58_0 <= XML)) )
                {
                    alt58 = 1;
                }
                switch (alt58)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: elementList
                        {
                            PushFollow(FOLLOW_elementList_in_arrayLiteral3836);
                            elementList209 = elementList();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_elementList.Add(elementList209.Tree);

                        }
                        break;

                }

                RBRACK210 = (CommonToken)input.LT(1);
                Match(input,RBRACK,FOLLOW_RBRACK_in_arrayLiteral3839); if (failed) return retval;
                if ( backtracking==0 ) stream_RBRACK.Add(RBRACK210);

                if ( backtracking == 0 )
                {
                   buffer.Append("]");
                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1135:3: -> ^( ARRAY_LITERAL ( elementList )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1135:6: ^( ARRAY_LITERAL ( elementList )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ARRAY_LITERAL, "ARRAY_LITERAL"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1135:22: ( elementList )?
                    if ( stream_elementList.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_elementList.Next());

                    }
                    stream_elementList.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 78, arrayLiteral_StartIndex);
            }
            }
            return retval;
        }
Пример #18
0
        // throws RecognitionException [1]
        // $ANTLR start switchBlock
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:830:1: switchBlock : LCURLY ( caseStatement )* ( defaultStatement )? RCURLY -> ^( BLOCK ( caseStatement )* ( defaultStatement )? ) ;
        public switchBlock_return switchBlock()
        {
            switchBlock_return retval = new switchBlock_return();
            retval.start = input.LT(1);
            int switchBlock_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LCURLY130 = null;
            CommonToken RCURLY133 = null;
            caseStatement_return caseStatement131 = null;

            defaultStatement_return defaultStatement132 = null;

            CommonTree LCURLY130_tree=null;
            CommonTree RCURLY133_tree=null;
            RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor,"token LCURLY");
            RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor,"token RCURLY");
            RewriteRuleSubtreeStream stream_caseStatement = new RewriteRuleSubtreeStream(adaptor,"rule caseStatement");
            RewriteRuleSubtreeStream stream_defaultStatement = new RewriteRuleSubtreeStream(adaptor,"rule defaultStatement");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 49) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:831:4: ( LCURLY ( caseStatement )* ( defaultStatement )? RCURLY -> ^( BLOCK ( caseStatement )* ( defaultStatement )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:831:4: LCURLY ( caseStatement )* ( defaultStatement )? RCURLY
            {
                LCURLY130 = (CommonToken)input.LT(1);
                Match(input,LCURLY,FOLLOW_LCURLY_in_switchBlock2512); if (failed) return retval;
                if ( backtracking==0 ) stream_LCURLY.Add(LCURLY130);

                if ( backtracking == 0 )
                {

                  												buffer.Append((options.NewlineAfterCondition ? NewLine + tab : "") + "{");
                  												CurrentTab++;

                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:835:3: ( caseStatement )*
                do
                {
                    int alt37 = 2;
                    int LA37_0 = input.LA(1);

                    if ( (LA37_0 == CASE) )
                    {
                        alt37 = 1;
                    }

                    switch (alt37)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:835:5: caseStatement
                            {
                                if ( backtracking == 0 )
                                {
                                  buffer.Append(NewLine + tab);
                                }
                                PushFollow(FOLLOW_caseStatement_in_switchBlock2529);
                                caseStatement131 = caseStatement();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_caseStatement.Add(caseStatement131.Tree);

                            }
                            break;

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

                loop37:
                    ;	// Stops C# compiler whinging that label 'loop37' has no statements

                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:836:3: ( defaultStatement )?
                int alt38 = 2;
                int LA38_0 = input.LA(1);

                if ( (LA38_0 == DEFAULT) )
                {
                    alt38 = 1;
                }
                switch (alt38)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:836:5: defaultStatement
                        {
                            if ( backtracking == 0 )
                            {
                              buffer.Append(NewLine + tab);
                            }
                            PushFollow(FOLLOW_defaultStatement_in_switchBlock2539);
                            defaultStatement132 = defaultStatement();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_defaultStatement.Add(defaultStatement132.Tree);

                        }
                        break;

                }

                RCURLY133 = (CommonToken)input.LT(1);
                Match(input,RCURLY,FOLLOW_RCURLY_in_switchBlock2545); if (failed) return retval;
                if ( backtracking==0 ) stream_RCURLY.Add(RCURLY133);

                if ( backtracking == 0 )
                {

                  												CurrentTab--;
                  												buffer.Append(NewLine + tab);
                  												buffer.Append("}");

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 842:3: -> ^( BLOCK ( caseStatement )* ( defaultStatement )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:842:6: ^( BLOCK ( caseStatement )* ( defaultStatement )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(BLOCK, "BLOCK"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:842:14: ( caseStatement )*
                    while ( stream_caseStatement.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_caseStatement.Next());

                    }
                    stream_caseStatement.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:842:29: ( defaultStatement )?
                    if ( stream_defaultStatement.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_defaultStatement.Next());

                    }
                    stream_defaultStatement.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 49, switchBlock_StartIndex);
            }
            }
            return retval;
        }
Пример #19
0
        // throws RecognitionException [1]
        // $ANTLR start block
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:652:1: block : LCURLY ( blockEntry )* RCURLY -> ^( BLOCK ( blockEntry )* ) ;
        public block_return block()
        {
            block_return retval = new block_return();
            retval.start = input.LT(1);
            int block_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LCURLY72 = null;
            CommonToken RCURLY74 = null;
            blockEntry_return blockEntry73 = null;

            CommonTree LCURLY72_tree=null;
            CommonTree RCURLY74_tree=null;
            RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor,"token LCURLY");
            RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor,"token RCURLY");
            RewriteRuleSubtreeStream stream_blockEntry = new RewriteRuleSubtreeStream(adaptor,"rule blockEntry");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 33) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:653:4: ( LCURLY ( blockEntry )* RCURLY -> ^( BLOCK ( blockEntry )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:653:4: LCURLY ( blockEntry )* RCURLY
            {
                LCURLY72 = (CommonToken)input.LT(1);
                Match(input,LCURLY,FOLLOW_LCURLY_in_block1892); if (failed) return retval;
                if ( backtracking==0 ) stream_LCURLY.Add(LCURLY72);

                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:654:3: ( blockEntry )*
                do
                {
                    int alt28 = 2;
                    int LA28_0 = input.LA(1);

                    if ( (LA28_0 == SEMI || LA28_0 == LCURLY || (LA28_0 >= STRING_LITERAL && LA28_0 <= CONST) || LA28_0 == LPAREN || LA28_0 == IF || (LA28_0 >= RETURN && LA28_0 <= SWITCH) || LA28_0 == FOR || (LA28_0 >= WHILE && LA28_0 <= VOID) || LA28_0 == IDENT || LA28_0 == LBRACK || LA28_0 == DYNAMIC || (LA28_0 >= IS && LA28_0 <= AS) || (LA28_0 >= PLUS && LA28_0 <= MINUS) || (LA28_0 >= INC && LA28_0 <= XML) || (LA28_0 >= 176 && LA28_0 <= 177)) )
                    {
                        alt28 = 1;
                    }

                    switch (alt28)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: blockEntry
                            {
                                PushFollow(FOLLOW_blockEntry_in_block1896);
                                blockEntry73 = blockEntry();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_blockEntry.Add(blockEntry73.Tree);

                            }
                            break;

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

                loop28:
                    ;	// Stops C# compiler whinging that label 'loop28' has no statements

                RCURLY74 = (CommonToken)input.LT(1);
                Match(input,RCURLY,FOLLOW_RCURLY_in_block1902); if (failed) return retval;
                if ( backtracking==0 ) stream_RCURLY.Add(RCURLY74);

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 656:3: -> ^( BLOCK ( blockEntry )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:656:6: ^( BLOCK ( blockEntry )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(BLOCK, "BLOCK"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:656:14: ( blockEntry )*
                    while ( stream_blockEntry.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_blockEntry.Next());

                    }
                    stream_blockEntry.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 33, block_StartIndex);
            }
            }
            return retval;
        }
Пример #20
0
        // throws RecognitionException [1]
        // $ANTLR start switchStatementList
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:866:1: switchStatementList : ( statement )* -> ^( SWITCH_STATEMENT_LIST ( statement )* ) ;
        public switchStatementList_return switchStatementList()
        {
            switchStatementList_return retval = new switchStatementList_return();
            retval.start = input.LT(1);
            int switchStatementList_StartIndex = input.Index();
            CommonTree root_0 = null;

            statement_return statement139 = null;

            RewriteRuleSubtreeStream stream_statement = new RewriteRuleSubtreeStream(adaptor,"rule statement");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 52) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:4: ( ( statement )* -> ^( SWITCH_STATEMENT_LIST ( statement )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:4: ( statement )*
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:4: ( statement )*
                do
                {
                    int alt39 = 2;
                    int LA39_0 = input.LA(1);

                    if ( (LA39_0 == SEMI || LA39_0 == LCURLY || (LA39_0 >= STRING_LITERAL && LA39_0 <= CONST) || LA39_0 == LPAREN || LA39_0 == IF || (LA39_0 >= RETURN && LA39_0 <= SWITCH) || LA39_0 == FOR || (LA39_0 >= WHILE && LA39_0 <= VOID) || LA39_0 == IDENT || LA39_0 == LBRACK || LA39_0 == DYNAMIC || (LA39_0 >= IS && LA39_0 <= AS) || (LA39_0 >= PLUS && LA39_0 <= MINUS) || (LA39_0 >= INC && LA39_0 <= XML) || (LA39_0 >= 176 && LA39_0 <= 177)) )
                    {
                        alt39 = 1;
                    }

                    switch (alt39)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:6: statement
                            {
                                if ( backtracking == 0 )
                                {
                                  buffer.Append(NewLine + tab);
                                }
                                PushFollow(FOLLOW_statement_in_switchStatementList2661);
                                statement139 = statement();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_statement.Add(statement139.Tree);

                            }
                            break;

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

                loop39:
                    ;	// Stops C# compiler whinging that label 'loop39' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 867:51: -> ^( SWITCH_STATEMENT_LIST ( statement )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:54: ^( SWITCH_STATEMENT_LIST ( statement )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(SWITCH_STATEMENT_LIST, "SWITCH_STATEMENT_LIST"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:867:78: ( statement )*
                    while ( stream_statement.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_statement.Next());

                    }
                    stream_statement.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 52, switchStatementList_StartIndex);
            }
            }
            return retval;
        }
Пример #21
0
        // throws RecognitionException [1]
        // $ANTLR start comments
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1501:1: comments : ( comment )+ -> ^( COMMENT_LIST ( comment )+ ) ;
        public comments_return comments()
        {
            comments_return retval = new comments_return();
            retval.start = input.LT(1);
            int comments_StartIndex = input.Index();
            CommonTree root_0 = null;

            comment_return comment309 = null;

            RewriteRuleSubtreeStream stream_comment = new RewriteRuleSubtreeStream(adaptor,"rule comment");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 117) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1509:4: ( ( comment )+ -> ^( COMMENT_LIST ( comment )+ ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1509:4: ( comment )+
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1509:4: ( comment )+
                int cnt87 = 0;
                do
                {
                    int alt87 = 2;
                    int LA87_0 = input.LA(1);

                    if ( (LA87_0 == SL_COMMENT) )
                    {
                        int LA87_15 = input.LA(2);

                        if ( (synpred176()) )
                        {
                            alt87 = 1;
                        }

                    }
                    else if ( (LA87_0 == ML_COMMENT) )
                    {
                        int LA87_16 = input.LA(2);

                        if ( (synpred176()) )
                        {
                            alt87 = 1;
                        }

                    }

                    switch (alt87)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: comment
                            {
                                PushFollow(FOLLOW_comment_in_comments5502);
                                comment309 = comment();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_comment.Add(comment309.Tree);

                            }
                            break;

                        default:
                            if ( cnt87 >= 1 ) goto loop87;
                            if ( backtracking > 0 ) {failed = true; return retval;}
                                EarlyExitException eee =
                                    new EarlyExitException(87, input);
                                throw eee;
                    }
                    cnt87++;
                } while (true);

                loop87:
                    ;	// Stops C# compiler whinging that label 'loop87' has no statements

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1509:13: -> ^( COMMENT_LIST ( comment )+ )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1509:16: ^( COMMENT_LIST ( comment )+ )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(COMMENT_LIST, "COMMENT_LIST"), root_1);

                    if ( !(stream_comment.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_comment.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_comment.Next());

                    }
                    stream_comment.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 117, comments_StartIndex);
            }
            }
            return retval;
        }
Пример #22
0
        // throws RecognitionException [1]
        // $ANTLR start typeBlock
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:453:1: typeBlock : LCURLY ( typeBlockEntry )* RCURLY -> ^( TYPE_BLOCK ( typeBlockEntry )* ) ;
        public typeBlock_return typeBlock()
        {
            typeBlock_return retval = new typeBlock_return();
            retval.start = input.LT(1);
            int typeBlock_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LCURLY24 = null;
            CommonToken RCURLY26 = null;
            typeBlockEntry_return typeBlockEntry25 = null;

            CommonTree LCURLY24_tree=null;
            CommonTree RCURLY26_tree=null;
            RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor,"token LCURLY");
            RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor,"token RCURLY");
            RewriteRuleSubtreeStream stream_typeBlockEntry = new RewriteRuleSubtreeStream(adaptor,"rule typeBlockEntry");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 14) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:454:4: ( LCURLY ( typeBlockEntry )* RCURLY -> ^( TYPE_BLOCK ( typeBlockEntry )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:454:4: LCURLY ( typeBlockEntry )* RCURLY
            {
                LCURLY24 = (CommonToken)input.LT(1);
                Match(input,LCURLY,FOLLOW_LCURLY_in_typeBlock973); if (failed) return retval;
                if ( backtracking==0 ) stream_LCURLY.Add(LCURLY24);

                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:455:3: ( typeBlockEntry )*
                do
                {
                    int alt10 = 2;
                    int LA10_0 = input.LA(1);

                    if ( (LA10_0 == IMPORT || LA10_0 == INCLUDE_DIRECTIVE || LA10_0 == FUNCTION || (LA10_0 >= VAR && LA10_0 <= CONST) || (LA10_0 >= IDENT && LA10_0 <= LBRACK) || (LA10_0 >= STATIC && LA10_0 <= DYNAMIC) || (LA10_0 >= SL_COMMENT && LA10_0 <= ML_COMMENT) || LA10_0 == 175 || (LA10_0 >= 180 && LA10_0 <= 184)) )
                    {
                        alt10 = 1;
                    }

                    switch (alt10)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:455:4: typeBlockEntry
                            {
                                PushFollow(FOLLOW_typeBlockEntry_in_typeBlock978);
                                typeBlockEntry25 = typeBlockEntry();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_typeBlockEntry.Add(typeBlockEntry25.Tree);

                            }
                            break;

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

                loop10:
                    ;	// Stops C# compiler whinging that label 'loop10' has no statements

                RCURLY26 = (CommonToken)input.LT(1);
                Match(input,RCURLY,FOLLOW_RCURLY_in_typeBlock984); if (failed) return retval;
                if ( backtracking==0 ) stream_RCURLY.Add(RCURLY26);

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 457:3: -> ^( TYPE_BLOCK ( typeBlockEntry )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:457:6: ^( TYPE_BLOCK ( typeBlockEntry )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(TYPE_BLOCK, "TYPE_BLOCK"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:457:19: ( typeBlockEntry )*
                    while ( stream_typeBlockEntry.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_typeBlockEntry.Next());

                    }
                    stream_typeBlockEntry.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 14, typeBlock_StartIndex);
            }
            }
            return retval;
        }
Пример #23
0
        // throws RecognitionException [1]
        // $ANTLR start forIter
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:958:1: forIter : ( expressionList )? -> ^( FOR_ITERATOR ( expressionList )? ) ;
        public forIter_return forIter()
        {
            InOperator_stack.Push(new InOperator_scope());

            forIter_return retval = new forIter_return();
            retval.start = input.LT(1);
            int forIter_StartIndex = input.Index();
            CommonTree root_0 = null;

            expressionList_return expressionList157 = null;

            RewriteRuleSubtreeStream stream_expressionList = new RewriteRuleSubtreeStream(adaptor,"rule expressionList");

            ((InOperator_scope)InOperator_stack.Peek()).allowed =  true;

            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 60) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:963:4: ( ( expressionList )? -> ^( FOR_ITERATOR ( expressionList )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:963:4: ( expressionList )?
            {
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:963:4: ( expressionList )?
                int alt44 = 2;
                int LA44_0 = input.LA(1);

                if ( (LA44_0 == LCURLY || (LA44_0 >= STRING_LITERAL && LA44_0 <= SET) || LA44_0 == LPAREN || LA44_0 == VOID || LA44_0 == IDENT || LA44_0 == LBRACK || LA44_0 == DYNAMIC || (LA44_0 >= IS && LA44_0 <= AS) || (LA44_0 >= PLUS && LA44_0 <= MINUS) || (LA44_0 >= INC && LA44_0 <= NEW) || (LA44_0 >= USE && LA44_0 <= XML)) )
                {
                    alt44 = 1;
                }
                switch (alt44)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:0:0: expressionList
                        {
                            PushFollow(FOLLOW_expressionList_in_forIter3016);
                            expressionList157 = expressionList();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_expressionList.Add(expressionList157.Tree);

                        }
                        break;

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 964:3: -> ^( FOR_ITERATOR ( expressionList )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:964:6: ^( FOR_ITERATOR ( expressionList )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(FOR_ITERATOR, "FOR_ITERATOR"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:964:21: ( expressionList )?
                    if ( stream_expressionList.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_expressionList.Next());

                    }
                    stream_expressionList.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 60, forIter_StartIndex);
            }
            InOperator_stack.Pop();

            }
            return retval;
        }
Пример #24
0
        // throws RecognitionException [1]
        // $ANTLR start typeExpression
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1015:1: typeExpression : c= COLON ( identifier | VOID | STAR ) -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? ) ;
        public typeExpression_return typeExpression()
        {
            typeExpression_return retval = new typeExpression_return();
            retval.start = input.LT(1);
            int typeExpression_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken c = null;
            CommonToken VOID170 = null;
            CommonToken STAR171 = null;
            identifier_return identifier169 = null;

            CommonTree c_tree=null;
            CommonTree VOID170_tree=null;
            CommonTree STAR171_tree=null;
            RewriteRuleTokenStream stream_STAR = new RewriteRuleTokenStream(adaptor,"token STAR");
            RewriteRuleTokenStream stream_COLON = new RewriteRuleTokenStream(adaptor,"token COLON");
            RewriteRuleTokenStream stream_VOID = new RewriteRuleTokenStream(adaptor,"token VOID");
            RewriteRuleSubtreeStream stream_identifier = new RewriteRuleSubtreeStream(adaptor,"rule identifier");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 64) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1017:3: (c= COLON ( identifier | VOID | STAR ) -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1017:3: c= COLON ( identifier | VOID | STAR )
            {
                c = (CommonToken)input.LT(1);
                Match(input,COLON,FOLLOW_COLON_in_typeExpression3152); if (failed) return retval;
                if ( backtracking==0 ) stream_COLON.Add(c);

                if ( backtracking == 0 )
                {
                   buffer.Append(options.SpaceBetweenType ? " : " : ":");
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1018:3: ( identifier | VOID | STAR )
                int alt45 = 3;
                switch ( input.LA(1) )
                {
                case GET:
                case SET:
                case IDENT:
                case DYNAMIC:
                case IS:
                case AS:
                case USE:
                case XML:
                    {
                    alt45 = 1;
                    }
                    break;
                case VOID:
                    {
                    alt45 = 2;
                    }
                    break;
                case STAR:
                    {
                    alt45 = 3;
                    }
                    break;
                    default:
                        if ( backtracking > 0 ) {failed = true; return retval;}
                        NoViableAltException nvae_d45s0 =
                            new NoViableAltException("1018:3: ( identifier | VOID | STAR )", 45, 0, input);

                        throw nvae_d45s0;
                }

                switch (alt45)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1019:4: identifier
                        {
                            PushFollow(FOLLOW_identifier_in_typeExpression3165);
                            identifier169 = identifier();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_identifier.Add(identifier169.Tree);

                        }
                        break;
                    case 2 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1020:6: VOID
                        {
                            VOID170 = (CommonToken)input.LT(1);
                            Match(input,VOID,FOLLOW_VOID_in_typeExpression3173); if (failed) return retval;
                            if ( backtracking==0 ) stream_VOID.Add(VOID170);

                            if ( backtracking == 0 )
                            {
                               buffer.Append("Void");
                            }

                        }
                        break;
                    case 3 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1021:6: STAR
                        {
                            STAR171 = (CommonToken)input.LT(1);
                            Match(input,STAR,FOLLOW_STAR_in_typeExpression3183); if (failed) return retval;
                            if ( backtracking==0 ) stream_STAR.Add(STAR171);

                            if ( backtracking == 0 )
                            {
                               buffer.Append("*");
                            }

                        }
                        break;

                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1023:3: -> ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:6: ^( TYPE_SPEC[$c] ( identifier )? ( VOID )? ( STAR )? )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(TYPE_SPEC, c), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:22: ( identifier )?
                    if ( stream_identifier.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_identifier.Next());

                    }
                    stream_identifier.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:34: ( VOID )?
                    if ( stream_VOID.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_VOID.Next());

                    }
                    stream_VOID.Reset();
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1023:40: ( STAR )?
                    if ( stream_STAR.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_STAR.Next());

                    }
                    stream_STAR.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 64, typeExpression_StartIndex);
            }
            }
            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;
		}
Пример #26
0
        // throws RecognitionException [1]
        // $ANTLR start variableDefinition
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:556:1: variableDefinition[CommonTree mods] : decl= varOrConst variableDeclarator ( COMMA variableDeclarator )* semi -> ^( VAR_DEF $decl ( variableDeclarator )+ ) ;
        public variableDefinition_return variableDefinition(CommonTree mods)
        {
            InOperator_stack.Push(new InOperator_scope());

            variableDefinition_return retval = new variableDefinition_return();
            retval.start = input.LT(1);
            int variableDefinition_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken COMMA51 = null;
            varOrConst_return decl = null;

            variableDeclarator_return variableDeclarator50 = null;

            variableDeclarator_return variableDeclarator52 = null;

            semi_return semi53 = null;

            CommonTree COMMA51_tree=null;
            RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");
            RewriteRuleSubtreeStream stream_semi = new RewriteRuleSubtreeStream(adaptor,"rule semi");
            RewriteRuleSubtreeStream stream_varOrConst = new RewriteRuleSubtreeStream(adaptor,"rule varOrConst");
            RewriteRuleSubtreeStream stream_variableDeclarator = new RewriteRuleSubtreeStream(adaptor,"rule variableDeclarator");

            ((InOperator_scope)InOperator_stack.Peek()).allowed =  true;

            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 23) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:561:4: (decl= varOrConst variableDeclarator ( COMMA variableDeclarator )* semi -> ^( VAR_DEF $decl ( variableDeclarator )+ ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:561:4: decl= varOrConst variableDeclarator ( COMMA variableDeclarator )* semi
            {
                if ( backtracking == 0 )
                {

                  			if(mods.ChildCount > 0) buffer.Append(fromModifiers(mods) + " ");

                }
                PushFollow(FOLLOW_varOrConst_in_variableDefinition1509);
                decl = varOrConst();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_varOrConst.Add(decl.Tree);
                if ( backtracking == 0 )
                {
                   buffer.Append(((CommonTree)decl.Tree).Text + " ");
                }
                PushFollow(FOLLOW_variableDeclarator_in_variableDefinition1518);
                variableDeclarator50 = variableDeclarator();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_variableDeclarator.Add(variableDeclarator50.Tree);
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:566:3: ( COMMA variableDeclarator )*
                do
                {
                    int alt19 = 2;
                    int LA19_0 = input.LA(1);

                    if ( (LA19_0 == COMMA) )
                    {
                        alt19 = 1;
                    }

                    switch (alt19)
                    {
                        case 1 :
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:567:10: COMMA variableDeclarator
                            {
                                if ( backtracking == 0 )
                                {
                                  	buffer.Append(";");
                                }
                                COMMA51 = (CommonToken)input.LT(1);
                                Match(input,COMMA,FOLLOW_COMMA_in_variableDefinition1538); if (failed) return retval;
                                if ( backtracking==0 ) stream_COMMA.Add(COMMA51);

                                if ( backtracking == 0 )
                                {

                                  										buffer.Append(NewLine + tab);
                                  										if(mods.ChildCount > 0) buffer.Append(fromModifiers(mods) + " ");
                                  										buffer.Append(((CommonTree)decl.Tree).Text + " ");

                                }
                                PushFollow(FOLLOW_variableDeclarator_in_variableDefinition1549);
                                variableDeclarator52 = variableDeclarator();
                                followingStackPointer_--;
                                if (failed) return retval;
                                if ( backtracking==0 ) stream_variableDeclarator.Add(variableDeclarator52.Tree);

                            }
                            break;

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

                loop19:
                    ;	// Stops C# compiler whinging that label 'loop19' has no statements

                PushFollow(FOLLOW_semi_in_variableDefinition1558);
                semi53 = semi();
                followingStackPointer_--;
                if (failed) return retval;
                if ( backtracking==0 ) stream_semi.Add(semi53.Tree);

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 576:3: -> ^( VAR_DEF $decl ( variableDeclarator )+ )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:576:6: ^( VAR_DEF $decl ( variableDeclarator )+ )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(VAR_DEF, "VAR_DEF"), root_1);

                    adaptor.AddChild(root_1, mods);
                    adaptor.AddChild(root_1, stream_decl.Next());
                    if ( !(stream_variableDeclarator.HasNext()) ) {
                        throw new RewriteEarlyExitException();
                    }
                    while ( stream_variableDeclarator.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_variableDeclarator.Next());

                    }
                    stream_variableDeclarator.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 23, variableDefinition_StartIndex);
            }
            InOperator_stack.Pop();

            }
            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;
		}
Пример #28
0
        // throws RecognitionException [1]
        // $ANTLR start annotationParamList
        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1075:1: annotationParamList : LPAREN ( annotationParam ( COMMA annotationParam )* )? RPAREN -> ^( ANNOTATION_PARAMS ( annotationParam )* ) ;
        public annotationParamList_return annotationParamList()
        {
            annotationParamList_return retval = new annotationParamList_return();
            retval.start = input.LT(1);
            int annotationParamList_StartIndex = input.Index();
            CommonTree root_0 = null;

            CommonToken LPAREN186 = null;
            CommonToken COMMA188 = null;
            CommonToken RPAREN190 = null;
            annotationParam_return annotationParam187 = null;

            annotationParam_return annotationParam189 = null;

            CommonTree LPAREN186_tree=null;
            CommonTree COMMA188_tree=null;
            CommonTree RPAREN190_tree=null;
            RewriteRuleTokenStream stream_COMMA = new RewriteRuleTokenStream(adaptor,"token COMMA");
            RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor,"token RPAREN");
            RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor,"token LPAREN");
            RewriteRuleSubtreeStream stream_annotationParam = new RewriteRuleSubtreeStream(adaptor,"rule annotationParam");
            try
            {
            if ( (backtracking > 0) && AlreadyParsedRule(input, 72) )
            {
                return retval;
            }
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1077:3: ( LPAREN ( annotationParam ( COMMA annotationParam )* )? RPAREN -> ^( ANNOTATION_PARAMS ( annotationParam )* ) )
            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1077:3: LPAREN ( annotationParam ( COMMA annotationParam )* )? RPAREN
            {
                LPAREN186 = (CommonToken)input.LT(1);
                Match(input,LPAREN,FOLLOW_LPAREN_in_annotationParamList3524); if (failed) return retval;
                if ( backtracking==0 ) stream_LPAREN.Add(LPAREN186);

                if ( backtracking == 0 )
                {
                   buffer.Append("(");
                }
                // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1078:3: ( annotationParam ( COMMA annotationParam )* )?
                int alt53 = 2;
                int LA53_0 = input.LA(1);

                if ( (LA53_0 == STRING_LITERAL || (LA53_0 >= GET && LA53_0 <= SET) || LA53_0 == IDENT || LA53_0 == DYNAMIC || (LA53_0 >= IS && LA53_0 <= AS) || (LA53_0 >= TRUE && LA53_0 <= FLOAT_LITERAL) || (LA53_0 >= USE && LA53_0 <= XML)) )
                {
                    alt53 = 1;
                }
                switch (alt53)
                {
                    case 1 :
                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1078:5: annotationParam ( COMMA annotationParam )*
                        {
                            PushFollow(FOLLOW_annotationParam_in_annotationParamList3537);
                            annotationParam187 = annotationParam();
                            followingStackPointer_--;
                            if (failed) return retval;
                            if ( backtracking==0 ) stream_annotationParam.Add(annotationParam187.Tree);
                            // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1079:4: ( COMMA annotationParam )*
                            do
                            {
                                int alt52 = 2;
                                int LA52_0 = input.LA(1);

                                if ( (LA52_0 == COMMA) )
                                {
                                    alt52 = 1;
                                }

                                switch (alt52)
                                {
                                    case 1 :
                                        // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1080:5: COMMA annotationParam
                                        {
                                            COMMA188 = (CommonToken)input.LT(1);
                                            Match(input,COMMA,FOLLOW_COMMA_in_annotationParamList3548); if (failed) return retval;
                                            if ( backtracking==0 ) stream_COMMA.Add(COMMA188);

                                            if ( backtracking == 0 )
                                            {
                                               buffer.Append(",");
                                            }
                                            PushFollow(FOLLOW_annotationParam_in_annotationParamList3559);
                                            annotationParam189 = annotationParam();
                                            followingStackPointer_--;
                                            if (failed) return retval;
                                            if ( backtracking==0 ) stream_annotationParam.Add(annotationParam189.Tree);

                                        }
                                        break;

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

                            loop52:
                                ;	// Stops C# compiler whinging that label 'loop52' has no statements

                        }
                        break;

                }

                RPAREN190 = (CommonToken)input.LT(1);
                Match(input,RPAREN,FOLLOW_RPAREN_in_annotationParamList3574); if (failed) return retval;
                if ( backtracking==0 ) stream_RPAREN.Add(RPAREN190);

                if ( backtracking == 0 )
                {
                   buffer.Append(")");
                }

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

                root_0 = (CommonTree)adaptor.GetNilNode();
                // 1085:3: -> ^( ANNOTATION_PARAMS ( annotationParam )* )
                {
                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1085:6: ^( ANNOTATION_PARAMS ( annotationParam )* )
                    {
                    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    root_1 = (CommonTree)adaptor.BecomeRoot(adaptor.Create(ANNOTATION_PARAMS, "ANNOTATION_PARAMS"), root_1);

                    // C:\\Users\\sephiroth\\Documents\\Visual Studio 2005\\Projects\\CodeReformatter\\CodeReformatter\\AS.g:1085:26: ( annotationParam )*
                    while ( stream_annotationParam.HasNext() )
                    {
                        adaptor.AddChild(root_1, stream_annotationParam.Next());

                    }
                    stream_annotationParam.Reset();

                    adaptor.AddChild(root_0, root_1);
                    }

                }

                }

            }

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

            if ( backtracking==0 )
            {	retval.tree = (CommonTree)adaptor.RulePostProcessing(root_0);
                adaptor.SetTokenBoundaries(retval.Tree, retval.start, retval.stop);
            }
            }

            catch (NoViableAltException e)
            {
                Debug.WriteLine("NoValiable alt: token=" + e.Token + " (decision=" + e.decisionNumber + " state " + e.stateNumber + ")" + " decision=<<" + e.grammarDecisionDescription + ">>");
                throw e;
            }
            catch (MismatchedTokenException e)
            {
                Debug.WriteLine("[" + e.Line + ":" + e.Index + "]: " + e.Message + ". Unexpected " + e.UnexpectedType.ToString() +  "( expecting: "+ e.expecting + " )");
                throw e;
            }
            catch(RecognitionException e)
            {
                Debug.WriteLine("RecognitionException: " + e);
                throw e;
            }
            finally
            {
            if ( backtracking > 0 )
            {
                Memoize(input, 72, annotationParamList_StartIndex);
            }
            }
            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
    // $ANTLR start "optionalFromTokenFromClause"
    // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:165:1: optionalFromTokenFromClause : optionalFromTokenFromClause2 path ( asAlias )? -> ^( FROM ^( RANGE path ( asAlias )? ) ) ;
    public HqlParser.optionalFromTokenFromClause_return optionalFromTokenFromClause() // throws RecognitionException [1]
    {   
        HqlParser.optionalFromTokenFromClause_return retval = new HqlParser.optionalFromTokenFromClause_return();
        retval.Start = input.LT(1);

        IASTNode root_0 = null;

        HqlParser.optionalFromTokenFromClause2_return optionalFromTokenFromClause222 = default(HqlParser.optionalFromTokenFromClause2_return);

        HqlParser.path_return path23 = default(HqlParser.path_return);

        HqlParser.asAlias_return asAlias24 = default(HqlParser.asAlias_return);


        RewriteRuleSubtreeStream stream_path = new RewriteRuleSubtreeStream(adaptor,"rule path");
        RewriteRuleSubtreeStream stream_asAlias = new RewriteRuleSubtreeStream(adaptor,"rule asAlias");
        RewriteRuleSubtreeStream stream_optionalFromTokenFromClause2 = new RewriteRuleSubtreeStream(adaptor,"rule optionalFromTokenFromClause2");
        try 
    	{
            // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:166:2: ( optionalFromTokenFromClause2 path ( asAlias )? -> ^( FROM ^( RANGE path ( asAlias )? ) ) )
            // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:166:4: optionalFromTokenFromClause2 path ( asAlias )?
            {
            	PushFollow(FOLLOW_optionalFromTokenFromClause2_in_optionalFromTokenFromClause745);
            	optionalFromTokenFromClause222 = optionalFromTokenFromClause2();
            	state.followingStackPointer--;

            	stream_optionalFromTokenFromClause2.Add(optionalFromTokenFromClause222.Tree);
            	PushFollow(FOLLOW_path_in_optionalFromTokenFromClause747);
            	path23 = path();
            	state.followingStackPointer--;

            	stream_path.Add(path23.Tree);
            	// /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:166:38: ( asAlias )?
            	int alt6 = 2;
            	int LA6_0 = input.LA(1);

            	if ( (LA6_0 == AS || LA6_0 == IDENT) )
            	{
            	    alt6 = 1;
            	}
            	switch (alt6) 
            	{
            	    case 1 :
            	        // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:166:39: asAlias
            	        {
            	        	PushFollow(FOLLOW_asAlias_in_optionalFromTokenFromClause750);
            	        	asAlias24 = asAlias();
            	        	state.followingStackPointer--;

            	        	stream_asAlias.Add(asAlias24.Tree);

            	        }
            	        break;

            	}



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

            	root_0 = (IASTNode)adaptor.GetNilNode();
            	// 167:3: -> ^( FROM ^( RANGE path ( asAlias )? ) )
            	{
            	    // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:167:6: ^( FROM ^( RANGE path ( asAlias )? ) )
            	    {
            	    IASTNode root_1 = (IASTNode)adaptor.GetNilNode();
            	    root_1 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(FROM, "FROM"), root_1);

            	    // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:167:13: ^( RANGE path ( asAlias )? )
            	    {
            	    IASTNode root_2 = (IASTNode)adaptor.GetNilNode();
            	    root_2 = (IASTNode)adaptor.BecomeRoot((IASTNode)adaptor.Create(RANGE, "RANGE"), root_2);

            	    adaptor.AddChild(root_2, stream_path.NextTree());
            	    // /Users/Steve/Projects/NHibernate/Branches/2.1.x/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Hql.g:167:26: ( asAlias )?
            	    if ( stream_asAlias.HasNext() )
            	    {
            	        adaptor.AddChild(root_2, stream_asAlias.NextTree());

            	    }
            	    stream_asAlias.Reset();

            	    adaptor.AddChild(root_1, root_2);
            	    }

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

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

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

            	retval.Tree = (IASTNode)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (IASTNode)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }