Exemplo n.º 1
0
    TokenRewriteStream tokens; // avoid typecasts all over



    // $ANTLR start program
    // T.g:26:1: program : ( method )+ ;
    public void program() // throws RecognitionException [1]
    {
        TParser.method_return method1 = null;



        tokens = (TokenRewriteStream)input;
        IToken start = input.LT(1);

        try
        {
            // T.g:31:5: ( ( method )+ )
            // T.g:31:9: ( method )+
            {
                // T.g:31:9: ( method )+
                int cnt1 = 0;
                do
                {
                    int alt1  = 2;
                    int LA1_0 = input.LA(1);

                    if ((LA1_0 == 7))
                    {
                        alt1 = 1;
                    }


                    switch (alt1)
                    {
                    case 1:
                        // T.g:31:9: method
                    {
                        PushFollow(FOLLOW_method_in_program46);
                        method1 = method();
                        state.followingStackPointer--;
                    }
                    break;

                    default:
                        if (cnt1 >= 1)
                        {
                            goto loop1;
                        }
                        EarlyExitException eee =
                            new EarlyExitException(1, input);
                        throw eee;
                    }
                    cnt1++;
                } while (true);

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


                tokens.InsertBefore(start, "public class Wrapper {\n");
                // note the reference to the last token matched for method:
                tokens.InsertAfter(((method1 != null) ? ((IToken)method1.stop) : null), "\n}\n");
            }
        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input, re);
        }
        finally
        {
        }
        return;
    }
Exemplo n.º 2
0
    // throws RecognitionException [1]
    // $ANTLR start program
    // T.g:26:1: program : ( method )+ ;
    public void program()
    {
        TParser.method_return method1 = null;

            tokens = (TokenRewriteStream)input;
            IToken start = input.LT(1);

        try
        {
            // T.g:31:5: ( ( method )+ )
            // T.g:31:9: ( method )+
            {
                // T.g:31:9: ( method )+
                int cnt1 = 0;
                do
                {
                    int alt1 = 2;
                    int LA1_0 = input.LA(1);

                    if ( (LA1_0 == 7) )
                    {
                        alt1 = 1;
                    }

                    switch (alt1)
                    {
                        case 1 :
                            // T.g:31:9: method
                            {
                                PushFollow(FOLLOW_method_in_program46);
                                method1 = method();
                                state.followingStackPointer--;

                            }
                            break;

                        default:
                            if ( cnt1 >= 1 ) goto loop1;
                                EarlyExitException eee =
                                    new EarlyExitException(1, input);
                                throw eee;
                    }
                    cnt1++;
                } while (true);

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

                        tokens.InsertBefore(start,"public class Wrapper {\n");
                        // note the reference to the last token matched for method:
                        tokens.InsertAfter(((method1 != null) ? ((IToken)method1.stop) : null), "\n}\n");

            }

        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input,re);
        }
        finally
        {
        }
        return ;
    }
Exemplo n.º 3
0
    // $ANTLR end method


    // $ANTLR start body
    // T.g:44:1: body : lcurly= '{' ( stat )* '}' ;
    public void body() // throws RecognitionException [1]
    {
        body_stack.Push(new body_scope());
        IToken lcurly = null;


        $body::decls = new Hashtable();

        try
        {
            // T.g:55:5: (lcurly= '{' ( stat )* '}' )
            // T.g:55:9: lcurly= '{' ( stat )* '}'
            {
                lcurly = (IToken)input.LT(1);
                Match(input, 10, FOLLOW_10_in_body127);
                // T.g:55:20: ( stat )*
                do
                {
                    int alt2  = 2;
                    int LA2_0 = input.LA(1);

                    if ((LA2_0 == ID))
                    {
                        alt2 = 1;
                    }


                    switch (alt2)
                    {
                    case 1:
                        // T.g:55:20: stat
                    {
                        PushFollow(FOLLOW_stat_in_body129);
                        stat();
                        state.followingStackPointer--;
                    }
                    break;

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

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

                Match(input, 11, FOLLOW_11_in_body132);

                // dump declarations for all identifiers seen in statement list
                foreach (DictionaryEntry e in $body::decls)
                {
                    tokens.InsertAfter(lcurly, "\nint " + e.Value + ";");
                }
            }
        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input, re);
        }
        finally
        {
            body_stack.Pop();
        }
        return;
    }