Search in sources :

Example 31 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project drools by kiegroup.

the class DSLMapParser method condition_key.

// $ANTLR start "condition_key"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:251:1: condition_key :{...}?value= LITERAL -> VT_CONDITION[$value] ;
public final DSLMapParser.condition_key_return condition_key() throws RecognitionException {
    DSLMapParser.condition_key_return retval = new DSLMapParser.condition_key_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token value = null;
    Object value_tree = null;
    RewriteRuleTokenStream stream_LITERAL = new RewriteRuleTokenStream(adaptor, "token LITERAL");
    try {
        // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:252:5: ({...}?value= LITERAL -> VT_CONDITION[$value] )
        // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:252:7: {...}?value= LITERAL
        {
            if (!((validateIdentifierKey("condition") || validateIdentifierKey("when")))) {
                if (state.backtracking > 0) {
                    state.failed = true;
                    return retval;
                }
                throw new FailedPredicateException(input, "condition_key", "validateIdentifierKey(\"condition\")||validateIdentifierKey(\"when\")");
            }
            value = (Token) match(input, LITERAL, FOLLOW_LITERAL_in_condition_key1599);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_LITERAL.add(value);
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                root_0 = (Object) adaptor.nil();
                // 253:5: -> VT_CONDITION[$value]
                {
                    adaptor.addChild(root_0, (Object) adaptor.create(VT_CONDITION, value));
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) CommonToken(org.antlr.runtime.CommonToken) FailedPredicateException(org.antlr.runtime.FailedPredicateException) RecognitionException(org.antlr.runtime.RecognitionException)

Example 32 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project drools by kiegroup.

the class DSLMapParser method variable_reference.

// $ANTLR start "variable_reference"
// src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:228:1: variable_reference : lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) ;
public final DSLMapParser.variable_reference_return variable_reference() throws RecognitionException {
    DSLMapParser.variable_reference_return retval = new DSLMapParser.variable_reference_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token lc = null;
    Token rc = null;
    ParserRuleReturnScope name = null;
    Object lc_tree = null;
    Object rc_tree = null;
    RewriteRuleTokenStream stream_RIGHT_CURLY = new RewriteRuleTokenStream(adaptor, "token RIGHT_CURLY");
    RewriteRuleTokenStream stream_LEFT_CURLY = new RewriteRuleTokenStream(adaptor, "token LEFT_CURLY");
    RewriteRuleSubtreeStream stream_variable_reference_expr = new RewriteRuleSubtreeStream(adaptor, "rule variable_reference_expr");
    boolean hasSpaceBefore = false;
    boolean hasSpaceAfter = false;
    String text = "";
    try {
        // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:234:5: (lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) )
        // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:234:7: lc= LEFT_CURLY name= variable_reference_expr rc= RIGHT_CURLY
        {
            lc = (Token) match(input, LEFT_CURLY, FOLLOW_LEFT_CURLY_in_variable_reference1389);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_LEFT_CURLY.add(lc);
            if (state.backtracking == 0) {
                CommonToken back2 = (CommonToken) input.LT(-2);
                if (back2 != null && back2.getStopIndex() < ((CommonToken) lc).getStartIndex() - 1)
                    hasSpaceBefore = true;
            }
            pushFollow(FOLLOW_variable_reference_expr_in_variable_reference1409);
            name = variable_reference_expr();
            state._fsp--;
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_variable_reference_expr.add(name.getTree());
            rc = (Token) match(input, RIGHT_CURLY, FOLLOW_RIGHT_CURLY_in_variable_reference1413);
            if (state.failed)
                return retval;
            if (state.backtracking == 0)
                stream_RIGHT_CURLY.add(rc);
            if (state.backtracking == 0) {
                if (((CommonToken) rc).getStopIndex() < ((CommonToken) input.LT(1)).getStartIndex() - 1)
                    hasSpaceAfter = true;
            }
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.getTree() : null);
                root_0 = (Object) adaptor.nil();
                // 241:5: -> { hasSpaceBefore && hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE
                if (hasSpaceBefore && hasSpaceAfter) {
                    adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
                    // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:241:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
                        adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
                        adaptor.addChild(root_0, root_1);
                    }
                    adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
                } else // 242:5: -> { hasSpaceBefore && !hasSpaceAfter}? VT_SPACE ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                if (hasSpaceBefore && !hasSpaceAfter) {
                    adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
                    // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:242:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
                        adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
                        adaptor.addChild(root_0, root_1);
                    }
                } else // 243:5: -> {!hasSpaceBefore && hasSpaceAfter}? ^( VT_VAR_REF LITERAL[$name.start,$name.text] ) VT_SPACE
                if (!hasSpaceBefore && hasSpaceAfter) {
                    // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:243:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
                        adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
                        adaptor.addChild(root_0, root_1);
                    }
                    adaptor.addChild(root_0, (Object) adaptor.create(VT_SPACE, "VT_SPACE"));
                } else // 244:5: -> ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                {
                    // src/main/resources/org/drools/compiler/lang/dsl/DSLMap.g:244:54: ^( VT_VAR_REF LITERAL[$name.start,$name.text] )
                    {
                        Object root_1 = (Object) adaptor.nil();
                        root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(VT_VAR_REF, "VT_VAR_REF"), root_1);
                        adaptor.addChild(root_1, (Object) adaptor.create(LITERAL, (name != null ? (name.start) : null), (name != null ? input.toString(name.start, name.stop) : null)));
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (Object) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    // do for sure before leaving
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) CommonToken(org.antlr.runtime.CommonToken) ParserRuleReturnScope(org.antlr.runtime.ParserRuleReturnScope) CommonToken(org.antlr.runtime.CommonToken) RecognitionException(org.antlr.runtime.RecognitionException)

Example 33 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project binnavi by google.

the class ConditionParser method primaryExpression.

// $ANTLR end "multExpression"
// $ANTLR start "primaryExpression"
// C:\\Dokumente und
// Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:92:1:
// primaryExpression : ( IDENTIFIER | NUMBER | HEX_NUMBER | '[' formula ']' -> ^(
// MEMORY_EXPRESSION formula ) | '(' formula ')' -> ^( SUB_EXPRESSION formula ) );
public final ConditionParser.primaryExpression_return primaryExpression() throws RecognitionException {
    final ConditionParser.primaryExpression_return retval = new ConditionParser.primaryExpression_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token IDENTIFIER30 = null;
    Token NUMBER31 = null;
    Token HEX_NUMBER32 = null;
    Token char_literal33 = null;
    Token char_literal35 = null;
    Token char_literal36 = null;
    Token char_literal38 = null;
    ConditionParser.formula_return formula34 = null;
    ConditionParser.formula_return formula37 = null;
    Object IDENTIFIER30_tree = null;
    Object NUMBER31_tree = null;
    Object HEX_NUMBER32_tree = null;
    final Object char_literal33_tree = null;
    final Object char_literal35_tree = null;
    final Object char_literal36_tree = null;
    final Object char_literal38_tree = null;
    final RewriteRuleTokenStream stream_32 = new RewriteRuleTokenStream(adaptor, "token 32");
    final RewriteRuleTokenStream stream_31 = new RewriteRuleTokenStream(adaptor, "token 31");
    final RewriteRuleTokenStream stream_33 = new RewriteRuleTokenStream(adaptor, "token 33");
    final RewriteRuleTokenStream stream_34 = new RewriteRuleTokenStream(adaptor, "token 34");
    final RewriteRuleSubtreeStream stream_formula = new RewriteRuleSubtreeStream(adaptor, "rule formula");
    try {
        // C:\\Dokumente und
        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:93:3:
        // ( IDENTIFIER | NUMBER | HEX_NUMBER | '[' formula ']' -> ^( MEMORY_EXPRESSION formula ) |
        // '(' formula ')' -> ^( SUB_EXPRESSION formula ) )
        int alt9 = 5;
        switch(input.LA(1)) {
            case IDENTIFIER:
                {
                    alt9 = 1;
                }
                break;
            case NUMBER:
                {
                    alt9 = 2;
                }
                break;
            case HEX_NUMBER:
                {
                    alt9 = 3;
                }
                break;
            case 31:
                {
                    alt9 = 4;
                }
                break;
            case 33:
                {
                    alt9 = 5;
                }
                break;
            default:
                final NoViableAltException nvae = new NoViableAltException("", 9, 0, input);
                throw nvae;
        }
        switch(alt9) {
            case 1:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:93:5:
                // IDENTIFIER
                {
                    root_0 = (Object) adaptor.nil();
                    IDENTIFIER30 = (Token) match(input, IDENTIFIER, FOLLOW_IDENTIFIER_in_primaryExpression558);
                    IDENTIFIER30_tree = (Object) adaptor.create(IDENTIFIER30);
                    adaptor.addChild(root_0, IDENTIFIER30_tree);
                }
                break;
            case 2:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:94:5:
                // NUMBER
                {
                    root_0 = (Object) adaptor.nil();
                    NUMBER31 = (Token) match(input, NUMBER, FOLLOW_NUMBER_in_primaryExpression564);
                    NUMBER31_tree = (Object) adaptor.create(NUMBER31);
                    adaptor.addChild(root_0, NUMBER31_tree);
                }
                break;
            case 3:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:95:5:
                // HEX_NUMBER
                {
                    root_0 = (Object) adaptor.nil();
                    HEX_NUMBER32 = (Token) match(input, HEX_NUMBER, FOLLOW_HEX_NUMBER_in_primaryExpression570);
                    HEX_NUMBER32_tree = (Object) adaptor.create(HEX_NUMBER32);
                    adaptor.addChild(root_0, HEX_NUMBER32_tree);
                }
                break;
            case 4:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:96:5:
                // '[' formula ']'
                {
                    char_literal33 = (Token) match(input, 31, FOLLOW_31_in_primaryExpression576);
                    stream_31.add(char_literal33);
                    pushFollow(FOLLOW_formula_in_primaryExpression578);
                    formula34 = formula();
                    state._fsp--;
                    stream_formula.add(formula34.getTree());
                    char_literal35 = (Token) match(input, 32, FOLLOW_32_in_primaryExpression580);
                    stream_32.add(char_literal35);
                    // AST REWRITE
                    // elements: formula
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    final RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = (Object) adaptor.nil();
                    // 96:21: -> ^( MEMORY_EXPRESSION formula )
                    {
                        // C:\\Dokumente und
                        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:96:24:
                        // ^( MEMORY_EXPRESSION formula )
                        {
                            Object root_1 = (Object) adaptor.nil();
                            root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(MEMORY_EXPRESSION, "MEMORY_EXPRESSION"), root_1);
                            adaptor.addChild(root_1, stream_formula.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
            case 5:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:97:5:
                // '(' formula ')'
                {
                    char_literal36 = (Token) match(input, 33, FOLLOW_33_in_primaryExpression594);
                    stream_33.add(char_literal36);
                    pushFollow(FOLLOW_formula_in_primaryExpression596);
                    formula37 = formula();
                    state._fsp--;
                    stream_formula.add(formula37.getTree());
                    char_literal38 = (Token) match(input, 34, FOLLOW_34_in_primaryExpression598);
                    stream_34.add(char_literal38);
                    // AST REWRITE
                    // elements: formula
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    final RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = (Object) adaptor.nil();
                    // 97:21: -> ^( SUB_EXPRESSION formula )
                    {
                        // C:\\Dokumente und
                        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\BreakpointCondition\\Condition.g:97:24:
                        // ^( SUB_EXPRESSION formula )
                        {
                            Object root_1 = (Object) adaptor.nil();
                            root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(SUB_EXPRESSION, "SUB_EXPRESSION"), root_1);
                            adaptor.addChild(root_1, stream_formula.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
        }
        retval.stop = input.LT(-1);
        retval.tree = (Object) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (final RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (Object) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 34 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project binnavi by google.

the class FilterParser method primaryExpression.

// $ANTLR start "primaryExpression"
// C:\\Dokumente und
// Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:30:1:
// primaryExpression : ( PREDICATE | '(' expression ')' -> ^( SUB_EXPRESSION expression ) );
public final FilterParser.primaryExpression_return primaryExpression() throws RecognitionException {
    final FilterParser.primaryExpression_return retval = new FilterParser.primaryExpression_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token PREDICATE8 = null;
    Token char_literal9 = null;
    Token char_literal11 = null;
    FilterParser.expression_return expression10 = null;
    Object PREDICATE8_tree = null;
    final Object char_literal9_tree = null;
    final Object char_literal11_tree = null;
    final RewriteRuleTokenStream stream_10 = new RewriteRuleTokenStream(adaptor, "token 10");
    final RewriteRuleTokenStream stream_9 = new RewriteRuleTokenStream(adaptor, "token 9");
    final RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
    try {
        // C:\\Dokumente und
        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:31:3:
        // ( PREDICATE | '(' expression ')' -> ^( SUB_EXPRESSION expression ) )
        int alt3 = 2;
        final int LA3_0 = input.LA(1);
        if ((LA3_0 == PREDICATE)) {
            alt3 = 1;
        } else if ((LA3_0 == 9)) {
            alt3 = 2;
        } else {
            final NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
            throw nvae;
        }
        switch(alt3) {
            case 1:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:31:5:
                // PREDICATE
                {
                    root_0 = adaptor.nil();
                    PREDICATE8 = (Token) match(input, PREDICATE, FOLLOW_PREDICATE_in_primaryExpression183);
                    PREDICATE8_tree = adaptor.create(PREDICATE8);
                    adaptor.addChild(root_0, PREDICATE8_tree);
                }
                break;
            case 2:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:32:5:
                // '(' expression ')'
                {
                    char_literal9 = (Token) match(input, 9, FOLLOW_9_in_primaryExpression189);
                    stream_9.add(char_literal9);
                    pushFollow(FOLLOW_expression_in_primaryExpression191);
                    expression10 = expression();
                    state._fsp--;
                    stream_expression.add(expression10.getTree());
                    char_literal11 = (Token) match(input, 10, FOLLOW_10_in_primaryExpression193);
                    stream_10.add(char_literal11);
                    // AST REWRITE
                    // elements: expression
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    final RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = adaptor.nil();
                    // 32:24: -> ^( SUB_EXPRESSION expression )
                    {
                        // C:\\Dokumente und
                        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\filter\\Filter.g:32:27:
                        // ^( SUB_EXPRESSION expression )
                        {
                            Object root_1 = adaptor.nil();
                            root_1 = adaptor.becomeRoot(adaptor.create(SUB_EXPRESSION, "SUB_EXPRESSION"), root_1);
                            adaptor.addChild(root_1, stream_expression.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
        }
        retval.stop = input.LT(-1);
        retval.tree = adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (final RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 35 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project binnavi by google.

the class MemoryExpressionParser method primaryExpression.

// $ANTLR end "multExpression"
// $ANTLR start "primaryExpression"
// C:\\Dokumente und
// Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:46:1:
// primaryExpression : ( REGISTER | NUMBER | HEX_NUMBER | '[' expression ']' -> ^( MEM_EXPRESSION
// expression ) | '(' expression ')' -> ^( SUB_EXPRESSION expression ) );
public final MemoryExpressionParser.primaryExpression_return primaryExpression() throws RecognitionException {
    final MemoryExpressionParser.primaryExpression_return retval = new MemoryExpressionParser.primaryExpression_return();
    retval.start = input.LT(1);
    Object root_0 = null;
    Token REGISTER11 = null;
    Token NUMBER12 = null;
    Token HEX_NUMBER13 = null;
    Token char_literal14 = null;
    Token char_literal16 = null;
    Token char_literal17 = null;
    Token char_literal19 = null;
    MemoryExpressionParser.expression_return expression15 = null;
    MemoryExpressionParser.expression_return expression18 = null;
    Object REGISTER11_tree = null;
    Object NUMBER12_tree = null;
    Object HEX_NUMBER13_tree = null;
    final Object char_literal14_tree = null;
    final Object char_literal16_tree = null;
    final Object char_literal17_tree = null;
    final Object char_literal19_tree = null;
    final RewriteRuleTokenStream stream_21 = new RewriteRuleTokenStream(adaptor, "token 21");
    final RewriteRuleTokenStream stream_20 = new RewriteRuleTokenStream(adaptor, "token 20");
    final RewriteRuleTokenStream stream_19 = new RewriteRuleTokenStream(adaptor, "token 19");
    final RewriteRuleTokenStream stream_18 = new RewriteRuleTokenStream(adaptor, "token 18");
    final RewriteRuleSubtreeStream stream_expression = new RewriteRuleSubtreeStream(adaptor, "rule expression");
    try {
        // C:\\Dokumente und
        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:47:3:
        // ( REGISTER | NUMBER | HEX_NUMBER | '[' expression ']' -> ^( MEM_EXPRESSION expression ) |
        // '(' expression ')' -> ^( SUB_EXPRESSION expression ) )
        int alt4 = 5;
        switch(input.LA(1)) {
            case REGISTER:
                {
                    alt4 = 1;
                }
                break;
            case NUMBER:
                {
                    alt4 = 2;
                }
                break;
            case HEX_NUMBER:
                {
                    alt4 = 3;
                }
                break;
            case 18:
                {
                    alt4 = 4;
                }
                break;
            case 20:
                {
                    alt4 = 5;
                }
                break;
            default:
                final NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
                throw nvae;
        }
        switch(alt4) {
            case 1:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:47:5:
                // REGISTER
                {
                    root_0 = (Object) adaptor.nil();
                    REGISTER11 = (Token) match(input, REGISTER, FOLLOW_REGISTER_in_primaryExpression260);
                    REGISTER11_tree = (Object) adaptor.create(REGISTER11);
                    adaptor.addChild(root_0, REGISTER11_tree);
                }
                break;
            case 2:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:48:5:
                // NUMBER
                {
                    root_0 = (Object) adaptor.nil();
                    NUMBER12 = (Token) match(input, NUMBER, FOLLOW_NUMBER_in_primaryExpression266);
                    NUMBER12_tree = (Object) adaptor.create(NUMBER12);
                    adaptor.addChild(root_0, NUMBER12_tree);
                }
                break;
            case 3:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:49:5:
                // HEX_NUMBER
                {
                    root_0 = (Object) adaptor.nil();
                    HEX_NUMBER13 = (Token) match(input, HEX_NUMBER, FOLLOW_HEX_NUMBER_in_primaryExpression272);
                    HEX_NUMBER13_tree = (Object) adaptor.create(HEX_NUMBER13);
                    adaptor.addChild(root_0, HEX_NUMBER13_tree);
                }
                break;
            case 4:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:50:5:
                // '[' expression ']'
                {
                    char_literal14 = (Token) match(input, 18, FOLLOW_18_in_primaryExpression278);
                    stream_18.add(char_literal14);
                    pushFollow(FOLLOW_expression_in_primaryExpression280);
                    expression15 = expression();
                    state._fsp--;
                    stream_expression.add(expression15.getTree());
                    char_literal16 = (Token) match(input, 19, FOLLOW_19_in_primaryExpression282);
                    stream_19.add(char_literal16);
                    // AST REWRITE
                    // elements: expression
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    final RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = (Object) adaptor.nil();
                    // 50:24: -> ^( MEM_EXPRESSION expression )
                    {
                        // C:\\Dokumente und
                        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:50:27:
                        // ^( MEM_EXPRESSION expression )
                        {
                            Object root_1 = (Object) adaptor.nil();
                            root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(MEM_EXPRESSION, "MEM_EXPRESSION"), root_1);
                            adaptor.addChild(root_1, stream_expression.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
            case 5:
                // C:\\Dokumente und
                // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:51:5:
                // '(' expression ')'
                {
                    char_literal17 = (Token) match(input, 20, FOLLOW_20_in_primaryExpression296);
                    stream_20.add(char_literal17);
                    pushFollow(FOLLOW_expression_in_primaryExpression298);
                    expression18 = expression();
                    state._fsp--;
                    stream_expression.add(expression18.getTree());
                    char_literal19 = (Token) match(input, 21, FOLLOW_21_in_primaryExpression300);
                    stream_21.add(char_literal19);
                    // AST REWRITE
                    // elements: expression
                    // token labels:
                    // rule labels: retval
                    // token list labels:
                    // rule list labels:
                    // wildcard labels:
                    retval.tree = root_0;
                    final RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                    root_0 = (Object) adaptor.nil();
                    // 51:24: -> ^( SUB_EXPRESSION expression )
                    {
                        // C:\\Dokumente und
                        // Einstellungen\\sp\\workspace\\com.google.security.zynamics.binnavi-Trunk\\src\\com.google.security.zynamics.binnavi\\parsers\\gotomem\\MemoryExpression.g:51:27:
                        // ^( SUB_EXPRESSION expression )
                        {
                            Object root_1 = (Object) adaptor.nil();
                            root_1 = (Object) adaptor.becomeRoot((Object) adaptor.create(SUB_EXPRESSION, "SUB_EXPRESSION"), root_1);
                            adaptor.addChild(root_1, stream_expression.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
        }
        retval.stop = input.LT(-1);
        retval.tree = (Object) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (final RecognitionException e) {
        throw e;
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Aggregations

RecognitionException (org.antlr.runtime.RecognitionException)74 Token (org.antlr.runtime.Token)74 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)74 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)74 CommonTree (org.antlr.runtime.tree.CommonTree)62 NoViableAltException (org.antlr.runtime.NoViableAltException)22 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)12 CommonToken (org.antlr.runtime.CommonToken)9 FailedPredicateException (org.antlr.runtime.FailedPredicateException)4 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)4 EarlyExitException (org.antlr.runtime.EarlyExitException)1 RewriteEmptyStreamException (org.antlr.runtime.tree.RewriteEmptyStreamException)1