Search in sources :

Example 66 with NoViableAltException

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

the class CssParser method importRule.

// $ANTLR start "importRule"
// /home/langera/dev/freud/src/grammar/Css.g:44:1: importRule : ( '@import' | '@include' ) IDENT -> ^( IMPORT IDENT ) ;
public final CssParser.importRule_return importRule() throws RecognitionException {
    CssParser.importRule_return retval = new CssParser.importRule_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token string_literal4 = null;
    Token string_literal5 = null;
    Token IDENT6 = null;
    CommonTree string_literal4_tree = null;
    CommonTree string_literal5_tree = null;
    CommonTree IDENT6_tree = null;
    RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor, "token IDENT");
    RewriteRuleTokenStream stream_26 = new RewriteRuleTokenStream(adaptor, "token 26");
    RewriteRuleTokenStream stream_27 = new RewriteRuleTokenStream(adaptor, "token 27");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:45:2: ( ( '@import' | '@include' ) IDENT -> ^( IMPORT IDENT ) )
        // /home/langera/dev/freud/src/grammar/Css.g:45:4: ( '@import' | '@include' ) IDENT
        {
            // /home/langera/dev/freud/src/grammar/Css.g:45:4: ( '@import' | '@include' )
            int alt3 = 2;
            int LA3_0 = input.LA(1);
            if ((LA3_0 == 26)) {
                alt3 = 1;
            } else if ((LA3_0 == 27)) {
                alt3 = 2;
            } else {
                NoViableAltException nvae = new NoViableAltException("", 3, 0, input);
                throw nvae;
            }
            switch(alt3) {
                case 1:
                    // /home/langera/dev/freud/src/grammar/Css.g:45:5: '@import'
                    {
                        string_literal4 = (Token) match(input, 26, FOLLOW_26_in_importRule153);
                        stream_26.add(string_literal4);
                    }
                    break;
                case 2:
                    // /home/langera/dev/freud/src/grammar/Css.g:45:17: '@include'
                    {
                        string_literal5 = (Token) match(input, 27, FOLLOW_27_in_importRule157);
                        stream_27.add(string_literal5);
                    }
                    break;
            }
            IDENT6 = (Token) match(input, IDENT, FOLLOW_IDENT_in_importRule161);
            stream_IDENT.add(IDENT6);
            // 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();
            // 45:36: -> ^( IMPORT IDENT )
            {
                // /home/langera/dev/freud/src/grammar/Css.g:45:39: ^( IMPORT IDENT )
                {
                    CommonTree root_1 = (CommonTree) adaptor.nil();
                    root_1 = (CommonTree) adaptor.becomeRoot((CommonTree) adaptor.create(IMPORT, "IMPORT"), root_1);
                    adaptor.addChild(root_1, stream_IDENT.nextNode());
                    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) NoViableAltException(org.antlr.runtime.NoViableAltException) RewriteRuleSubtreeStream(org.antlr.runtime.tree.RewriteRuleSubtreeStream) Token(org.antlr.runtime.Token) RecognitionException(org.antlr.runtime.RecognitionException)

Example 67 with NoViableAltException

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

the class JavaLexer method mDECIMAL_LITERAL.

// $ANTLR end "HEX_LITERAL"
// $ANTLR start "DECIMAL_LITERAL"
public final void mDECIMAL_LITERAL() throws RecognitionException {
    try {
        int _type = DECIMAL_LITERAL;
        int _channel = DEFAULT_TOKEN_CHANNEL;
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:17: ( ( '0' | '1' .. '9' ( '0' .. '9' )* ) ( INTEGER_TYPE_SUFFIX )? )
        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:19: ( '0' | '1' .. '9' ( '0' .. '9' )* ) ( INTEGER_TYPE_SUFFIX )?
        {
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:19: ( '0' | '1' .. '9' ( '0' .. '9' )* )
            int alt4 = 2;
            int LA4_0 = input.LA(1);
            if ((LA4_0 == '0')) {
                alt4 = 1;
            } else if (((LA4_0 >= '1' && LA4_0 <= '9'))) {
                alt4 = 2;
            } else {
                NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
                throw nvae;
            }
            switch(alt4) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:20: '0'
                    {
                        match('0');
                    }
                    break;
                case 2:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:26: '1' .. '9' ( '0' .. '9' )*
                    {
                        matchRange('1', '9');
                        // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:35: ( '0' .. '9' )*
                        loop3: do {
                            int alt3 = 2;
                            int LA3_0 = input.LA(1);
                            if (((LA3_0 >= '0' && LA3_0 <= '9'))) {
                                alt3 = 1;
                            }
                            switch(alt3) {
                                case 1:
                                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:35: '0' .. '9'
                                    {
                                        matchRange('0', '9');
                                    }
                                    break;
                                default:
                                    break loop3;
                            }
                        } while (true);
                    }
                    break;
            }
            // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:46: ( INTEGER_TYPE_SUFFIX )?
            int alt5 = 2;
            int LA5_0 = input.LA(1);
            if ((LA5_0 == 'L' || LA5_0 == 'l')) {
                alt5 = 1;
            }
            switch(alt5) {
                case 1:
                    // /home/langera/dev/freud/trunk/src/grammar/Java.g:1172:46: INTEGER_TYPE_SUFFIX
                    {
                        mINTEGER_TYPE_SUFFIX();
                    }
                    break;
            }
        }
        state.type = _type;
        state.channel = _channel;
    } finally {
    }
}
Also used : NoViableAltException(org.antlr.runtime.NoViableAltException)

Example 68 with NoViableAltException

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

the class CssParser method selectop.

// $ANTLR start "selectop"
// /home/langera/dev/freud/src/grammar/Css.g:72:1: selectop : ( '>' -> CHILD | '+' -> ADJACENT_SIBLING );
public final CssParser.selectop_return selectop() throws RecognitionException {
    CssParser.selectop_return retval = new CssParser.selectop_return();
    retval.start = input.LT(1);
    CommonTree root_0 = null;
    Token char_literal29 = null;
    Token char_literal30 = null;
    CommonTree char_literal29_tree = null;
    CommonTree char_literal30_tree = null;
    RewriteRuleTokenStream stream_32 = new RewriteRuleTokenStream(adaptor, "token 32");
    RewriteRuleTokenStream stream_33 = new RewriteRuleTokenStream(adaptor, "token 33");
    try {
        // /home/langera/dev/freud/src/grammar/Css.g:73:2: ( '>' -> CHILD | '+' -> ADJACENT_SIBLING )
        int alt14 = 2;
        int LA14_0 = input.LA(1);
        if ((LA14_0 == 32)) {
            alt14 = 1;
        } else if ((LA14_0 == 33)) {
            alt14 = 2;
        } else {
            NoViableAltException nvae = new NoViableAltException("", 14, 0, input);
            throw nvae;
        }
        switch(alt14) {
            case 1:
                // /home/langera/dev/freud/src/grammar/Css.g:73:4: '>'
                {
                    char_literal29 = (Token) match(input, 32, FOLLOW_32_in_selectop363);
                    stream_32.add(char_literal29);
                    // AST REWRITE
                    // elements:
                    // 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();
                    // 73:8: -> CHILD
                    {
                        adaptor.addChild(root_0, (CommonTree) adaptor.create(CHILD, "CHILD"));
                    }
                    retval.tree = root_0;
                }
                break;
            case 2:
                // /home/langera/dev/freud/src/grammar/Css.g:74:11: '+'
                {
                    char_literal30 = (Token) match(input, 33, FOLLOW_33_in_selectop379);
                    stream_33.add(char_literal30);
                    // AST REWRITE
                    // elements:
                    // 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();
                    // 74:16: -> ADJACENT_SIBLING
                    {
                        adaptor.addChild(root_0, (CommonTree) adaptor.create(ADJACENT_SIBLING, "ADJACENT_SIBLING"));
                    }
                    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

NoViableAltException (org.antlr.runtime.NoViableAltException)68 RecognitionException (org.antlr.runtime.RecognitionException)50 Token (org.antlr.runtime.Token)43 CommonTree (org.antlr.runtime.tree.CommonTree)33 RewriteRuleSubtreeStream (org.antlr.runtime.tree.RewriteRuleSubtreeStream)28 RewriteRuleTokenStream (org.antlr.runtime.tree.RewriteRuleTokenStream)24 ParserRuleReturnScope (org.antlr.runtime.ParserRuleReturnScope)10 CommonToken (org.antlr.runtime.CommonToken)7 MismatchedSetException (org.antlr.runtime.MismatchedSetException)6 EarlyExitException (org.antlr.runtime.EarlyExitException)4 FailedPredicateException (org.antlr.runtime.FailedPredicateException)3 RewriteEarlyExitException (org.antlr.runtime.tree.RewriteEarlyExitException)3 ArrayList (java.util.ArrayList)2 MismatchedNotSetException (org.antlr.runtime.MismatchedNotSetException)2 MismatchedTokenException (org.antlr.runtime.MismatchedTokenException)2 MismatchedTreeNodeException (org.antlr.runtime.MismatchedTreeNodeException)2 RewriteEmptyStreamException (org.antlr.runtime.tree.RewriteEmptyStreamException)2