Search in sources :

Example 11 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method annotationScopeDeclarations.

// $ANTLR start "annotationScopeDeclarations"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:809:1: annotationScopeDeclarations : ( modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) ) | typeDeclaration );
public final JavaParser.annotationScopeDeclarations_return annotationScopeDeclarations() throws RecognitionException {
    JavaParser.annotationScopeDeclarations_return retval = new JavaParser.annotationScopeDeclarations_return();
    retval.start = input.LT(1);
    int annotationScopeDeclarations_StartIndex = input.index();
    CommonTree root_0 = null;
    Token IDENT255 = null;
    Token LPAREN256 = null;
    Token RPAREN257 = null;
    Token SEMI259 = null;
    Token SEMI261 = null;
    JavaParser.modifierList_return modifierList253 = null;
    JavaParser.type_return type254 = null;
    JavaParser.annotationDefaultValue_return annotationDefaultValue258 = null;
    JavaParser.classFieldDeclaratorList_return classFieldDeclaratorList260 = null;
    JavaParser.typeDeclaration_return typeDeclaration262 = null;
    CommonTree IDENT255_tree = null;
    CommonTree LPAREN256_tree = null;
    CommonTree RPAREN257_tree = null;
    CommonTree SEMI259_tree = null;
    CommonTree SEMI261_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_RPAREN = new RewriteRuleTokenStream(adaptor, "token RPAREN");
    RewriteRuleTokenStream stream_SEMI = new RewriteRuleTokenStream(adaptor, "token SEMI");
    RewriteRuleTokenStream stream_LPAREN = new RewriteRuleTokenStream(adaptor, "token LPAREN");
    RewriteRuleSubtreeStream stream_modifierList = new RewriteRuleSubtreeStream(adaptor, "rule modifierList");
    RewriteRuleSubtreeStream stream_annotationDefaultValue = new RewriteRuleSubtreeStream(adaptor, "rule annotationDefaultValue");
    RewriteRuleSubtreeStream stream_type = new RewriteRuleSubtreeStream(adaptor, "rule type");
    RewriteRuleSubtreeStream stream_classFieldDeclaratorList = new RewriteRuleSubtreeStream(adaptor, "rule classFieldDeclaratorList");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 70)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:810:5: ( modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) ) | typeDeclaration )
        int alt87 = 2;
        alt87 = dfa87.predict(input);
        switch(alt87) {
            case 1:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:810:9: modifierList type ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) )
                {
                    pushFollow(FOLLOW_modifierList_in_annotationScopeDeclarations8256);
                    modifierList253 = modifierList();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_modifierList.add(modifierList253.getTree());
                    }
                    pushFollow(FOLLOW_type_in_annotationScopeDeclarations8258);
                    type254 = type();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        stream_type.add(type254.getTree());
                    }
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:9: ( IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? ) | classFieldDeclaratorList SEMI -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList ) )
                    int alt86 = 2;
                    int LA86_0 = input.LA(1);
                    if ((LA86_0 == IDENT)) {
                        int LA86_1 = input.LA(2);
                        if ((LA86_1 == LPAREN)) {
                            alt86 = 1;
                        } else if ((LA86_1 == ASSIGN || LA86_1 == COMMA || LA86_1 == LBRACK || LA86_1 == SEMI)) {
                            alt86 = 2;
                        } else {
                            if (state.backtracking > 0) {
                                state.failed = true;
                                return retval;
                            }
                            NoViableAltException nvae = new NoViableAltException("", 86, 1, input);
                            throw nvae;
                        }
                    } else {
                        if (state.backtracking > 0) {
                            state.failed = true;
                            return retval;
                        }
                        NoViableAltException nvae = new NoViableAltException("", 86, 0, input);
                        throw nvae;
                    }
                    switch(alt86) {
                        case 1:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:13: IDENT LPAREN RPAREN ( annotationDefaultValue )? SEMI
                            {
                                IDENT255 = (Token) match(input, IDENT, FOLLOW_IDENT_in_annotationScopeDeclarations8272);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_IDENT.add(IDENT255);
                                }
                                LPAREN256 = (Token) match(input, LPAREN, FOLLOW_LPAREN_in_annotationScopeDeclarations8274);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_LPAREN.add(LPAREN256);
                                }
                                RPAREN257 = (Token) match(input, RPAREN, FOLLOW_RPAREN_in_annotationScopeDeclarations8276);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_RPAREN.add(RPAREN257);
                                }
                                // /home/langera/dev/freud/trunk/src/grammar/Java.g:811:33: ( annotationDefaultValue )?
                                int alt85 = 2;
                                int LA85_0 = input.LA(1);
                                if ((LA85_0 == DEFAULT)) {
                                    alt85 = 1;
                                }
                                switch(alt85) {
                                    case 1:
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: annotationDefaultValue
                                        {
                                            pushFollow(FOLLOW_annotationDefaultValue_in_annotationScopeDeclarations8278);
                                            annotationDefaultValue258 = annotationDefaultValue();
                                            state._fsp--;
                                            if (state.failed) {
                                                return retval;
                                            }
                                            if (state.backtracking == 0) {
                                                stream_annotationDefaultValue.add(annotationDefaultValue258.getTree());
                                            }
                                        }
                                        break;
                                }
                                SEMI259 = (Token) match(input, SEMI, FOLLOW_SEMI_in_annotationScopeDeclarations8281);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI259);
                                }
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 812:13: -> ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:812:17: ^( ANNOTATION_METHOD_DECL modifierList type IDENT ( annotationDefaultValue )? )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ANNOTATION_METHOD_DECL, "ANNOTATION_METHOD_DECL"), root_1);
                                            adaptor.addChild(root_1, stream_modifierList.nextTree());
                                            adaptor.addChild(root_1, stream_type.nextTree());
                                            adaptor.addChild(root_1, stream_IDENT.nextNode());
                                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:812:66: ( annotationDefaultValue )?
                                            if (stream_annotationDefaultValue.hasNext()) {
                                                adaptor.addChild(root_1, stream_annotationDefaultValue.nextTree());
                                            }
                                            stream_annotationDefaultValue.reset();
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/trunk/src/grammar/Java.g:813:13: classFieldDeclaratorList SEMI
                            {
                                pushFollow(FOLLOW_classFieldDeclaratorList_in_annotationScopeDeclarations8323);
                                classFieldDeclaratorList260 = classFieldDeclaratorList();
                                state._fsp--;
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_classFieldDeclaratorList.add(classFieldDeclaratorList260.getTree());
                                }
                                SEMI261 = (Token) match(input, SEMI, FOLLOW_SEMI_in_annotationScopeDeclarations8325);
                                if (state.failed) {
                                    return retval;
                                }
                                if (state.backtracking == 0) {
                                    stream_SEMI.add(SEMI261);
                                }
                                // wildcard labels:
                                if (state.backtracking == 0) {
                                    retval.tree = root_0;
                                    RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                                    root_0 = (CommonTree) adaptor.nil();
                                    // 814:13: -> ^( VAR_DECLARATION modifierList type classFieldDeclaratorList )
                                    {
                                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:814:17: ^( VAR_DECLARATION modifierList type classFieldDeclaratorList )
                                        {
                                            CommonTree root_1 = (CommonTree) adaptor.nil();
                                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(VAR_DECLARATION, "VAR_DECLARATION"), root_1);
                                            adaptor.addChild(root_1, stream_modifierList.nextTree());
                                            adaptor.addChild(root_1, stream_type.nextTree());
                                            adaptor.addChild(root_1, stream_classFieldDeclaratorList.nextTree());
                                            adaptor.addChild(root_0, root_1);
                                        }
                                    }
                                    retval.tree = root_0;
                                }
                            }
                            break;
                    }
                }
                break;
            case 2:
                // /home/langera/dev/freud/trunk/src/grammar/Java.g:816:9: typeDeclaration
                {
                    root_0 = (CommonTree) adaptor.nil();
                    pushFollow(FOLLOW_typeDeclaration_in_annotationScopeDeclarations8370);
                    typeDeclaration262 = typeDeclaration();
                    state._fsp--;
                    if (state.failed) {
                        return retval;
                    }
                    if (state.backtracking == 0) {
                        adaptor.addChild(root_0, typeDeclaration262.getTree());
                    }
                }
                break;
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 70, annotationScopeDeclarations_StartIndex);
        }
    }
    return retval;
}
Also used : CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) NoViableAltException(org.antlr.runtime.NoViableAltException) RecognitionException(org.antlr.runtime.RecognitionException)

Example 12 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class JavaParser method classBody.

// $ANTLR start "classBody"
// /home/langera/dev/freud/trunk/src/grammar/Java.g:525:1: classBody : LCURLY ( classScopeDeclarations )* RCURLY -> ^( CLASS_TOP_LEVEL_SCOPE[$LCURLY, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* ) ;
public final JavaParser.classBody_return classBody() throws RecognitionException {
    JavaParser.classBody_return retval = new JavaParser.classBody_return();
    retval.start = input.LT(1);
    int classBody_StartIndex = input.index();
    CommonTree root_0 = null;
    Token LCURLY74 = null;
    Token RCURLY76 = null;
    JavaParser.classScopeDeclarations_return classScopeDeclarations75 = null;
    CommonTree LCURLY74_tree = null;
    CommonTree RCURLY76_tree = null;
    RewriteRuleTokenStream stream_LCURLY = new RewriteRuleTokenStream(adaptor, "token LCURLY");
    RewriteRuleTokenStream stream_RCURLY = new RewriteRuleTokenStream(adaptor, "token RCURLY");
    RewriteRuleSubtreeStream stream_classScopeDeclarations = new RewriteRuleSubtreeStream(adaptor, "rule classScopeDeclarations");
    try {
        if (state.backtracking > 0 && alreadyParsedRule(input, 23)) {
            return retval;
        }
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:526:5: ( LCURLY ( classScopeDeclarations )* RCURLY -> ^( CLASS_TOP_LEVEL_SCOPE[$LCURLY, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* ) )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:526:9: LCURLY ( classScopeDeclarations )* RCURLY
        {
            LCURLY74 = (Token) match(input, LCURLY, FOLLOW_LCURLY_in_classBody5496);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_LCURLY.add(LCURLY74);
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:526:16: ( classScopeDeclarations )*
            loop26: do {
                int alt26 = 2;
                int LA26_0 = input.LA(1);
                if ((LA26_0 == AT || LA26_0 == LCURLY || LA26_0 == LESS_THAN || LA26_0 == SEMI || LA26_0 == ABSTRACT || LA26_0 == BOOLEAN || LA26_0 == BYTE || (LA26_0 >= CHAR && LA26_0 <= CLASS) || LA26_0 == DOUBLE || LA26_0 == ENUM || LA26_0 == FINAL || LA26_0 == FLOAT || LA26_0 == INTERFACE || (LA26_0 >= INT && LA26_0 <= NATIVE) || (LA26_0 >= PRIVATE && LA26_0 <= PUBLIC) || (LA26_0 >= SHORT && LA26_0 <= STRICTFP) || LA26_0 == SYNCHRONIZED || LA26_0 == TRANSIENT || (LA26_0 >= VOID && LA26_0 <= VOLATILE) || LA26_0 == IDENT)) {
                    alt26 = 1;
                }
                switch(alt26) {
                    case 1:
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:0:0: classScopeDeclarations
                        {
                            pushFollow(FOLLOW_classScopeDeclarations_in_classBody5498);
                            classScopeDeclarations75 = classScopeDeclarations();
                            state._fsp--;
                            if (state.failed) {
                                return retval;
                            }
                            if (state.backtracking == 0) {
                                stream_classScopeDeclarations.add(classScopeDeclarations75.getTree());
                            }
                        }
                        break;
                    default:
                        break loop26;
                }
            } while (true);
            RCURLY76 = (Token) match(input, RCURLY, FOLLOW_RCURLY_in_classBody5501);
            if (state.failed) {
                return retval;
            }
            if (state.backtracking == 0) {
                stream_RCURLY.add(RCURLY76);
            }
            // wildcard labels:
            if (state.backtracking == 0) {
                retval.tree = root_0;
                RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval != null ? retval.tree : null);
                root_0 = (CommonTree) adaptor.nil();
                // 527:9: -> ^( CLASS_TOP_LEVEL_SCOPE[$LCURLY, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* )
                {
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:527:13: ^( CLASS_TOP_LEVEL_SCOPE[$LCURLY, \"CLASS_TOP_LEVEL_SCOPE\"] ( classScopeDeclarations )* )
                    {
                        CommonTree root_1 = (CommonTree) adaptor.nil();
                        root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(CLASS_TOP_LEVEL_SCOPE, LCURLY74, "CLASS_TOP_LEVEL_SCOPE"), root_1);
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:527:71: ( classScopeDeclarations )*
                        while (stream_classScopeDeclarations.hasNext()) {
                            adaptor.addChild(root_1, stream_classScopeDeclarations.nextTree());
                        }
                        stream_classScopeDeclarations.reset();
                        adaptor.addChild(root_0, root_1);
                    }
                }
                retval.tree = root_0;
            }
        }
        retval.stop = input.LT(-1);
        if (state.backtracking == 0) {
            retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
        }
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
        if (state.backtracking > 0) {
            memoize(input, 23, classBody_StartIndex);
        }
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 13 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class CssParser method nest.

// $ANTLR start "nest"
// /home/langera/dev/freud/src/grammar/Css.g:52:1: nest : IDENT ( IDENT )* ( pseudo )* -> ^( NEST IDENT ( IDENT )* ( pseudo )* ) ;
public final CssParser.nest_return nest() throws RecognitionException {
    CssParser.nest_return retval = new CssParser.nest_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token IDENT13 = null;
    Token IDENT14 = null;
    CssParser.pseudo_return pseudo15 = null;
    CommonTree IDENT13_tree = null;
    CommonTree IDENT14_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleSubtreeStream stream_pseudo = new RewriteRuleSubtreeStream(adaptor, "rule pseudo");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:53:2: ( IDENT ( IDENT )* ( pseudo )* -> ^( NEST IDENT ( IDENT )* ( pseudo )* ) )
        // /home/langera/dev/freud/src/grammar/Css.g:53:4: IDENT ( IDENT )* ( pseudo )*
        {
            IDENT13 = (Token) match(input, IDENT, FOLLOW_IDENT_in_nest222);
            stream_IDENT.add(IDENT13);
            // /home/langera/dev/freud/src/grammar/Css.g:53:10: ( IDENT )*
            loop6: do {
                int alt6 = 2;
                int LA6_0 = input.LA(1);
                if ((LA6_0 == IDENT)) {
                    alt6 = 1;
                }
                switch(alt6) {
                    case 1:
                        // /home/langera/dev/freud/src/grammar/Css.g:53:10: IDENT
                        {
                            IDENT14 = (Token) match(input, IDENT, FOLLOW_IDENT_in_nest224);
                            stream_IDENT.add(IDENT14);
                        }
                        break;
                    default:
                        break loop6;
                }
            } while (true);
            // /home/langera/dev/freud/src/grammar/Css.g:53:17: ( pseudo )*
            loop7: do {
                int alt7 = 2;
                int LA7_0 = input.LA(1);
                if (((LA7_0 >= 38 && LA7_0 <= 39))) {
                    alt7 = 1;
                }
                switch(alt7) {
                    case 1:
                        // /home/langera/dev/freud/src/grammar/Css.g:53:17: pseudo
                        {
                            pushFollow(FOLLOW_pseudo_in_nest227);
                            pseudo15 = pseudo();
                            state._fsp--;
                            stream_pseudo.add(pseudo15.getTree());
                        }
                        break;
                    default:
                        break loop7;
                }
            } while (true);
            // AST REWRITE
            // elements: pseudo, IDENT, IDENT
            // 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 = (CommonTree) adaptor.nil();
            // 53:25: -> ^( NEST IDENT ( IDENT )* ( pseudo )* )
            {
                // /home/langera/dev/freud/src/grammar/Css.g:53:28: ^( NEST IDENT ( IDENT )* ( pseudo )* )
                {
                    CommonTree root_1 = (CommonTree) adaptor.nil();
                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(NEST, "NEST"), root_1);
                    adaptor.addChild(root_1, stream_IDENT.nextNode());
                    // /home/langera/dev/freud/src/grammar/Css.g:53:42: ( IDENT )*
                    while (stream_IDENT.hasNext()) {
                        adaptor.addChild(root_1, stream_IDENT.nextNode());
                    }
                    stream_IDENT.reset();
                    // /home/langera/dev/freud/src/grammar/Css.g:53:49: ( pseudo )*
                    while (stream_pseudo.hasNext()) {
                        adaptor.addChild(root_1, stream_pseudo.nextTree());
                    }
                    stream_pseudo.reset();
                    adaptor.addChild(root_0, root_1);
                }
            }
            retval.tree = root_0;
        }
        retval.stop = input.LT(-1);
        retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 14 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class CssParser method attrib.

// $ANTLR start "attrib"
// /home/langera/dev/freud/src/grammar/Css.g:93:1: attrib : '[' IDENT ( attribRelate IDENT )? ']' -> ^( ATTRIB IDENT ( attribRelate ( IDENT )* )? ) ;
public final CssParser.attrib_return attrib() throws RecognitionException {
    CssParser.attrib_return retval = new CssParser.attrib_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token char_literal46 = null;
    Token IDENT47 = null;
    Token IDENT49 = null;
    Token char_literal50 = null;
    CssParser.attribRelate_return attribRelate48 = null;
    CommonTree char_literal46_tree = null;
    CommonTree IDENT47_tree = null;
    CommonTree IDENT49_tree = null;
    CommonTree char_literal50_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_41 = new RewriteRuleTokenStream(adaptor, "token 41");
    RewriteRuleTokenStream stream_40 = new RewriteRuleTokenStream(adaptor, "token 40");
    RewriteRuleSubtreeStream stream_attribRelate = new RewriteRuleSubtreeStream(adaptor, "rule attribRelate");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:94:2: ( '[' IDENT ( attribRelate IDENT )? ']' -> ^( ATTRIB IDENT ( attribRelate ( IDENT )* )? ) )
        // /home/langera/dev/freud/src/grammar/Css.g:94:4: '[' IDENT ( attribRelate IDENT )? ']'
        {
            char_literal46 = (Token) match(input, 40, FOLLOW_40_in_attrib540);
            stream_40.add(char_literal46);
            IDENT47 = (Token) match(input, IDENT, FOLLOW_IDENT_in_attrib542);
            stream_IDENT.add(IDENT47);
            // /home/langera/dev/freud/src/grammar/Css.g:94:14: ( attribRelate IDENT )?
            int alt21 = 2;
            int LA21_0 = input.LA(1);
            if (((LA21_0 >= 42 && LA21_0 <= 44))) {
                alt21 = 1;
            }
            switch(alt21) {
                case 1:
                    // /home/langera/dev/freud/src/grammar/Css.g:94:15: attribRelate IDENT
                    {
                        pushFollow(FOLLOW_attribRelate_in_attrib545);
                        attribRelate48 = attribRelate();
                        state._fsp--;
                        stream_attribRelate.add(attribRelate48.getTree());
                        IDENT49 = (Token) match(input, IDENT, FOLLOW_IDENT_in_attrib547);
                        stream_IDENT.add(IDENT49);
                    }
                    break;
            }
            char_literal50 = (Token) match(input, 41, FOLLOW_41_in_attrib551);
            stream_41.add(char_literal50);
            // AST REWRITE
            // elements: attribRelate, IDENT, IDENT
            // 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 = (CommonTree) adaptor.nil();
            // 94:40: -> ^( ATTRIB IDENT ( attribRelate ( IDENT )* )? )
            {
                // /home/langera/dev/freud/src/grammar/Css.g:94:43: ^( ATTRIB IDENT ( attribRelate ( IDENT )* )? )
                {
                    CommonTree root_1 = (CommonTree) adaptor.nil();
                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(ATTRIB, "ATTRIB"), root_1);
                    adaptor.addChild(root_1, stream_IDENT.nextNode());
                    // /home/langera/dev/freud/src/grammar/Css.g:94:59: ( attribRelate ( IDENT )* )?
                    if (stream_attribRelate.hasNext() || stream_IDENT.hasNext()) {
                        adaptor.addChild(root_1, stream_attribRelate.nextTree());
                        // /home/langera/dev/freud/src/grammar/Css.g:94:73: ( IDENT )*
                        while (stream_IDENT.hasNext()) {
                            adaptor.addChild(root_1, stream_IDENT.nextNode());
                        }
                        stream_IDENT.reset();
                    }
                    stream_attribRelate.reset();
                    stream_IDENT.reset();
                    adaptor.addChild(root_0, root_1);
                }
            }
            retval.tree = root_0;
        }
        retval.stop = input.LT(-1);
        retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 15 with RewriteRuleTokenStream

use of org.antlr.runtime.tree.RewriteRuleTokenStream in project freud by LMAX-Exchange.

the class CssParser method pseudo.

// $ANTLR start "pseudo"
// /home/langera/dev/freud/src/grammar/Css.g:88:1: pseudo : ( ( ':' | '::' ) IDENT -> ^( PSEUDO IDENT ) | ( ':' | '::' ) function -> ^( PSEUDO function ) );
public final CssParser.pseudo_return pseudo() throws RecognitionException {
    CssParser.pseudo_return retval = new CssParser.pseudo_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token char_literal40 = null;
    Token string_literal41 = null;
    Token IDENT42 = null;
    Token char_literal43 = null;
    Token string_literal44 = null;
    CssParser.function_return function45 = null;
    CommonTree char_literal40_tree = null;
    CommonTree string_literal41_tree = null;
    CommonTree IDENT42_tree = null;
    CommonTree char_literal43_tree = null;
    CommonTree string_literal44_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_39 = new RewriteRuleTokenStream(adaptor, "token 39");
    RewriteRuleTokenStream stream_38 = new RewriteRuleTokenStream(adaptor, "token 38");
    RewriteRuleSubtreeStream stream_function = new RewriteRuleSubtreeStream(adaptor, "rule function");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:89:2: ( ( ':' | '::' ) IDENT -> ^( PSEUDO IDENT ) | ( ':' | '::' ) function -> ^( PSEUDO function ) )
        int alt20 = 2;
        alt20 = dfa20.predict(input);
        switch(alt20) {
            case 1:
                // /home/langera/dev/freud/src/grammar/Css.g:89:4: ( ':' | '::' ) IDENT
                {
                    // /home/langera/dev/freud/src/grammar/Css.g:89:4: ( ':' | '::' )
                    int alt18 = 2;
                    int LA18_0 = input.LA(1);
                    if ((LA18_0 == 38)) {
                        alt18 = 1;
                    } else if ((LA18_0 == 39)) {
                        alt18 = 2;
                    } else {
                        NoViableAltException nvae = new NoViableAltException("", 18, 0, input);
                        throw nvae;
                    }
                    switch(alt18) {
                        case 1:
                            // /home/langera/dev/freud/src/grammar/Css.g:89:5: ':'
                            {
                                char_literal40 = (Token) match(input, 38, FOLLOW_38_in_pseudo493);
                                stream_38.add(char_literal40);
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/src/grammar/Css.g:89:9: '::'
                            {
                                string_literal41 = (Token) match(input, 39, FOLLOW_39_in_pseudo495);
                                stream_39.add(string_literal41);
                            }
                            break;
                    }
                    IDENT42 = (Token) match(input, IDENT, FOLLOW_IDENT_in_pseudo498);
                    stream_IDENT.add(IDENT42);
                    // AST REWRITE
                    // elements: IDENT
                    // 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 = (CommonTree) adaptor.nil();
                    // 89:21: -> ^( PSEUDO IDENT )
                    {
                        // /home/langera/dev/freud/src/grammar/Css.g:89:24: ^( PSEUDO IDENT )
                        {
                            CommonTree root_1 = (CommonTree) adaptor.nil();
                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(PSEUDO, "PSEUDO"), root_1);
                            adaptor.addChild(root_1, stream_IDENT.nextNode());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
            case 2:
                // /home/langera/dev/freud/src/grammar/Css.g:90:4: ( ':' | '::' ) function
                {
                    // /home/langera/dev/freud/src/grammar/Css.g:90:4: ( ':' | '::' )
                    int alt19 = 2;
                    int LA19_0 = input.LA(1);
                    if ((LA19_0 == 38)) {
                        alt19 = 1;
                    } else if ((LA19_0 == 39)) {
                        alt19 = 2;
                    } else {
                        NoViableAltException nvae = new NoViableAltException("", 19, 0, input);
                        throw nvae;
                    }
                    switch(alt19) {
                        case 1:
                            // /home/langera/dev/freud/src/grammar/Css.g:90:5: ':'
                            {
                                char_literal43 = (Token) match(input, 38, FOLLOW_38_in_pseudo514);
                                stream_38.add(char_literal43);
                            }
                            break;
                        case 2:
                            // /home/langera/dev/freud/src/grammar/Css.g:90:9: '::'
                            {
                                string_literal44 = (Token) match(input, 39, FOLLOW_39_in_pseudo516);
                                stream_39.add(string_literal44);
                            }
                            break;
                    }
                    pushFollow(FOLLOW_function_in_pseudo519);
                    function45 = function();
                    state._fsp--;
                    stream_function.add(function45.getTree());
                    // AST REWRITE
                    // elements: function
                    // 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 = (CommonTree) adaptor.nil();
                    // 90:24: -> ^( PSEUDO function )
                    {
                        // /home/langera/dev/freud/src/grammar/Css.g:90:27: ^( PSEUDO function )
                        {
                            CommonTree root_1 = (CommonTree) adaptor.nil();
                            root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(PSEUDO, "PSEUDO"), root_1);
                            adaptor.addChild(root_1, stream_function.nextTree());
                            adaptor.addChild(root_0, root_1);
                        }
                    }
                    retval.tree = root_0;
                }
                break;
        }
        retval.stop = input.LT(-1);
        retval.tree = (CommonTree) adaptor.rulePostProcessing(root_0);
        adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    } catch (RecognitionException re) {
        reportError(re);
        recover(input, re);
        retval.tree = (CommonTree) adaptor.errorNode(input, retval.start, input.LT(-1), re);
    } finally {
    }
    return retval;
}
Also used : RewriteRuleTokenStream(org.antlr.runtime.tree.RewriteRuleTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) 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