Beispiel #1
0
    // throws RecognitionException [1]
    // $ANTLR end "mathexpr"
    // $ANTLR start "term"
    // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:117:1: term returns [Expr arit] : left= factor (s= ( '*' | '/' ) right= factor )* ;
    public Expr term()
    {
        Expr arit = null;

        IToken s = null;
        Expr left = null;

        Expr right = null;

        try
        {
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:118:2: (left= factor (s= ( '*' | '/' ) right= factor )* )
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:118:4: left= factor (s= ( '*' | '/' ) right= factor )*
            {
                PushFollow(FOLLOW_factor_in_term799);
                left = factor();
                state.followingStackPointer--;

                        arit = left;

                // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:122:2: (s= ( '*' | '/' ) right= factor )*
                do
                {
                    int alt7 = 2;
                    int LA7_0 = input.LA(1);

                    if ( (LA7_0 == 19 || LA7_0 == 35) )
                    {
                        alt7 = 1;
                    }

                    switch (alt7)
                    {
                        case 1 :
                            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:122:3: s= ( '*' | '/' ) right= factor
                            {
                                s = (IToken)input.LT(1);
                                if ( input.LA(1) == 19 || input.LA(1) == 35 )
                                {
                                    input.Consume();
                                    state.errorRecovery = false;
                                }
                                else
                                {
                                    MismatchedSetException mse = new MismatchedSetException(null,input);
                                    throw mse;
                                }

                                PushFollow(FOLLOW_factor_in_term816);
                                right = factor();
                                state.followingStackPointer--;

                                        arit = new AritExpr(s.Text[0], left, right);
                                        left = arit;

                            }
                            break;

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

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

            }

        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input,re);
        }
        finally
        {
        }
        return arit;
    }
Beispiel #2
0
    // throws RecognitionException [1]
    // $ANTLR end "expr"
    // $ANTLR start "mathexpr"
    // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:104:1: mathexpr returns [Expr arit] : left= term (s= ( '+' | '-' ) right= term )* ;
    public Expr mathexpr()
    {
        Expr arit = null;

        IToken s = null;
        Expr left = null;

        Expr right = null;

        try
        {
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:105:2: (left= term (s= ( '+' | '-' ) right= term )* )
            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:105:4: left= term (s= ( '+' | '-' ) right= term )*
            {
                PushFollow(FOLLOW_term_in_mathexpr753);
                left = term();
                state.followingStackPointer--;

                        arit = left;

                // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:109:2: (s= ( '+' | '-' ) right= term )*
                do
                {
                    int alt6 = 2;
                    int LA6_0 = input.LA(1);

                    if ( (LA6_0 == 18 || LA6_0 == 34) )
                    {
                        alt6 = 1;
                    }

                    switch (alt6)
                    {
                        case 1 :
                            // C:\\Users\\otavio\\Desktop\\Fruki\\San2Markov\\SAN.g:109:3: s= ( '+' | '-' ) right= term
                            {
                                s = (IToken)input.LT(1);
                                if ( input.LA(1) == 18 || input.LA(1) == 34 )
                                {
                                    input.Consume();
                                    state.errorRecovery = false;
                                }
                                else
                                {
                                    MismatchedSetException mse = new MismatchedSetException(null,input);
                                    throw mse;
                                }

                                PushFollow(FOLLOW_term_in_mathexpr774);
                                right = term();
                                state.followingStackPointer--;

                                        arit = new AritExpr(s.Text[0], left, right);
                                        left = arit;

                            }
                            break;

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

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

            }

        }
        catch (RecognitionException re)
        {
            ReportError(re);
            Recover(input,re);
        }
        finally
        {
        }
        return arit;
    }