Package net.sf.jcontracts.antlr

Source Code of net.sf.jcontracts.antlr.ANTLRParser

/*
* Copyright 1997-2000 Reto Kramer
* Copyright 2006 John Swapceinski
* Copyright 2006, 2008 Johan Stuyts
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.sf.jcontracts.antlr;

import net.sf.jcontracts.antlr.collections.impl.BitSet;

public class ANTLRParser extends LLkParserNoInteractive implements ANTLRTokenTypes
{

    public ANTLRParser(TokenBuffer tokenBuf)
    {
        this(tokenBuf, 2);
    }

    protected ANTLRParser(TokenBuffer tokenBuf, int k)
    {
        super(tokenBuf, k);
        blockNesting = -1;
        tokenNames_ = TOKEN_NAMES;
    }

    public ANTLRParser(TokenBuffer tokenBuf, ANTLRGrammarParseBehavior behavior_, Tool tool_)
    {
        super(tokenBuf, 1);
        blockNesting = -1;
        tokenNames_ = TOKEN_NAMES;
        behavior = behavior_;
        tool = tool_;
    }

    public ANTLRParser(Tokenizer lexer)
    {
        this(lexer, 2);
    }

    protected ANTLRParser(Tokenizer lexer, int k)
    {
        super(lexer, k);
        blockNesting = -1;
        tokenNames_ = TOKEN_NAMES;
    }

    public final void alternative() throws ParserException
    {
        boolean altAutoGen = true;
        if (la_1 == 34)
        {
            match(34);
            if (guessing == 0)
            {
                altAutoGen = false;
            }
        }
        if (guessing == 0)
        {
            behavior.beginAlt(altAutoGen);
        }
        while (_tokenSet_1.member(la_1))
        {
            element();
        }
        if (la_1 == 37)
        {
            exceptionSpecNoLabel();
        }
        if (guessing == 0)
        {
            behavior.endAlt();
        }
    }

    public final int ast_type_spec() throws ParserException
    {
        int autoGen = 1;
        switch (la_1)
        {
            default:
                break;

            case 46: // '.'
                match(46);
                if (guessing == 0)
                {
                    autoGen = 2;
                }
                break;

            case 34: // '"'
                match(34);
                if (guessing == 0)
                {
                    autoGen = 3;
                }
                break;
        }
        return autoGen;
    }

    public final void block() throws ParserException
    {
        if (guessing == 0)
        {
            blockNesting++;
        }
        alternative();
        while (la_1 == 21)
        {
            match(21);
            alternative();
        }
        if (guessing == 0)
        {
            blockNesting--;
        }
    }

    public final BitSet charSet() throws ParserException
    {
        BitSet b = null;
        BitSet tmpSet = null;
        b = setBlockElement();
        do
        {
            if (la_1 != 21)
            {
                break;
            }
            match(21);
            tmpSet = setBlockElement();
            if (guessing == 0)
            {
                b.orInPlace(tmpSet);
            }
        }
        while (true);
        return b;
    }

    public final void classDef() throws ParserException
    {
        Token a = null;
        try
        {
            if (la_1 == 5)
            {
                a = LT(1);
                match(5);
                if (guessing == 0)
                {
                    behavior.refPreambleAction(a);
                }
            }
            boolean synPredMatched13 = false;
            if ((la_1 == 6 || la_1 == 7) && (la_2 == 24 || la_2 == 28))
            {
                int _m13 = mark();
                synPredMatched13 = true;
                guessing++;
                try
                {
                    switch (la_1)
                    {
                        case 6: // '\006'
                            match(6);
                            break;

                        case 7: // '\007'
                            match(7);
                            id();
                            match(8);
                            match(9);
                            break;

                        default:
                            throw new NoViableAltException(LT(1));
                    }
                }
                catch (ParserException _ex)
                {
                    synPredMatched13 = false;
                }
                rewind(_m13);
                guessing--;
            }
            if (synPredMatched13)
            {
                lexerSpec();
            }
            else
            {
                boolean synPredMatched15 = false;
                if (la_1 == 7 && (la_2 == 24 || la_2 == 28))
                {
                    int _m15 = mark();
                    synPredMatched15 = true;
                    guessing++;
                    try
                    {
                        match(7);
                        id();
                        match(8);
                        match(10);
                    }
                    catch (ParserException _ex)
                    {
                        synPredMatched15 = false;
                    }
                    rewind(_m15);
                    guessing--;
                }
                if (synPredMatched15)
                {
                    treeParserSpec();
                }
                else if (la_1 == 7 && (la_2 == 24 || la_2 == 28))
                {
                    parserSpec();
                }
                else
                {
                    throw new NoViableAltException(LT(1));
                }
            }
            rules();
            if (guessing == 0)
            {
                behavior.endGrammar();
            }
        }
        catch (ParserException ex)
        {
            if (guessing == 0)
            {
                reportError("rule classDef trapped: " + ex.toString());
                behavior.abortGrammar();
                boolean consuming = true;
                while (consuming)
                {
                    consume();
                    switch (LA(1))
                    {
                        case 1: // '\001'
                        case 6: // '\006'
                        case 7: // '\007'
                            consuming = false;
                            break;
                    }
                }
            }
            else
            {
                throw ex;
            }
        }
    }

    public final void dummy() throws ParserException
    {
        match(26);
    }

    public final void ebnf(Token label, boolean not) throws ParserException
    {
        Token lp = null;
        Token aa = null;
        lp = LT(1);
        match(27);
        if (guessing == 0)
        {
            behavior.beginSubRule(label, lp.getLine(), not);
        }
        boolean synPredMatched159 = false;
        if (la_1 == 5 && la_2 == 12)
        {
            int _m159 = mark();
            synPredMatched159 = true;
            guessing++;
            try
            {
                match(5);
                match(12);
            }
            catch (ParserException _ex)
            {
                synPredMatched159 = false;
            }
            rewind(_m159);
            guessing--;
        }
        if (synPredMatched159)
        {
            aa = LT(1);
            match(5);
            match(12);
            if (guessing == 0)
            {
                behavior.refInitAction(aa);
            }
            block();
            match(29);
        }
        else if (_tokenSet_6.member(la_1) && _tokenSet_7.member(la_2))
        {
            block();
            match(29);
        }
        else
        {
            throw new NoViableAltException(LT(1));
        }
        switch (la_1)
        {
            case 5: // '\005'
            case 15: // '\017'
            case 18: // '\022'
            case 19: // '\023'
            case 21: // '\025'
            case 24: // '\030'
            case 27: // '\033'
            case 28: // '\034'
            case 29: // '\035'
            case 34: // '"'
            case 37: // '%'
            case 39: // '\''
            case 40: // '('
            case 41: // ')'
            case 42: // '*'
            case 43: // '+'
            case 44: // ','
            case 47: // '/'
                switch (la_1)
                {
                    case 42: // '*'
                        match(42);
                        if (guessing == 0)
                        {
                            behavior.optionalSubRule();
                        }
                        break;

                    case 43: // '+'
                        match(43);
                        if (guessing == 0)
                        {
                            behavior.zeroOrMoreSubRule();
                        }
                        break;

                    case 44: // ','
                        match(44);
                        if (guessing == 0)
                        {
                            behavior.oneOrMoreSubRule();
                        }
                        break;
                }
                if (la_1 == 34)
                {
                    match(34);
                    if (guessing == 0)
                    {
                        behavior.noASTSubRule();
                    }
                }
                break;

            case 45: // '-'
                match(45);
                if (guessing == 0)
                {
                    behavior.synPred();
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        if (guessing == 0)
        {
            behavior.endSubRule();
        }
    }

    public final void element() throws ParserException
    {
        Token rr = null;
        Token aa = null;
        Token tr = null;
        Token aa2 = null;
        Token r2 = null;
        Token aa3 = null;
        Token a = null;
        Token p = null;
        Token label = null;
        Token assignId = null;
        Token args = null;
        int autoGen = 1;
        label0: switch (la_1)
        {
            case 5: // '\005'
                a = LT(1);
                match(5);
                if (guessing == 0)
                {
                    behavior.refAction(a);
                }
                break;

            case 40: // '('
                p = LT(1);
                match(40);
                if (guessing == 0)
                {
                    behavior.refSemPred(p);
                }
                break;

            case 41: // ')'
                tree();
                break;

            default:
                if ((la_1 == 24 || la_1 == 28) && la_2 == 14)
                {
                    assignId = id();
                    match(14);
                    if ((la_1 == 24 || la_1 == 28) && la_2 == 12)
                    {
                        label = id();
                        match(12);
                    }
                    switch (la_1)
                    {
                        case 28: // '\034'
                            rr = LT(1);
                            match(28);
                            if (la_1 == 35)
                            {
                                aa = LT(1);
                                match(35);
                                if (guessing == 0)
                                {
                                    args = aa;
                                }
                            }
                            if (la_1 == 34)
                            {
                                match(34);
                                if (guessing == 0)
                                {
                                    autoGen = 3;
                                }
                            }
                            if (guessing == 0)
                            {
                                behavior.refRule(assignId, rr, label, args, autoGen);
                            }
                            break label0;

                        case 24: // '\030'
                            tr = LT(1);
                            match(24);
                            if (la_1 == 35)
                            {
                                aa2 = LT(1);
                                match(35);
                                if (guessing == 0)
                                {
                                    args = aa2;
                                }
                            }
                            if (guessing == 0)
                            {
                                behavior.refToken(assignId, tr, label, args, false, autoGen, lastInRule());
                            }
                            break;

                        default:
                            throw new NoViableAltException(LT(1));
                    }
                    break;
                }
                if (_tokenSet_2.member(la_1) && _tokenSet_3.member(la_2))
                {
                    if ((la_1 == 24 || la_1 == 28) && la_2 == 12)
                    {
                        label = id();
                        match(12);
                    }
                    switch (la_1)
                    {
                        case 28: // '\034'
                            r2 = LT(1);
                            match(28);
                            if (la_1 == 35)
                            {
                                aa3 = LT(1);
                                match(35);
                                if (guessing == 0)
                                {
                                    args = aa3;
                                }
                            }
                            if (la_1 == 34)
                            {
                                match(34);
                                if (guessing == 0)
                                {
                                    autoGen = 3;
                                }
                            }
                            if (guessing == 0)
                            {
                                behavior.refRule(assignId, r2, label, args, autoGen);
                            }
                            break label0;

                        case 39: // '\''
                            match(39);
                            switch (la_1)
                            {
                                case 19: // '\023'
                                case 24: // '\030'
                                    notTerminal(label);
                                    break;

                                case 27: // '\033'
                                    ebnf(label, true);
                                    break;

                                default:
                                    throw new NoViableAltException(LT(1));
                            }
                            break label0;

                        case 27: // '\033'
                            ebnf(label, false);
                            break label0;
                    }
                    if ((la_1 == 18 || la_1 == 19 || la_1 == 24) && la_2 == 22)
                    {
                        range(label);
                        break;
                    }
                    if (_tokenSet_4.member(la_1) && _tokenSet_5.member(la_2))
                    {
                        terminal(label);
                    }
                    else
                    {
                        throw new NoViableAltException(LT(1));
                    }
                }
                else
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
        }
    }

    public final void exceptionGroup() throws ParserException
    {
        if (guessing == 0)
        {
            behavior.beginExceptionGroup();
        }
        int _cnt = 0;
        do
        {
            if (la_1 == 37)
            {
                exceptionSpec();
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (guessing == 0)
        {
            behavior.endExceptionGroup();
        }
    }

    public final void exceptionHandler() throws ParserException
    {
        Token a1 = null;
        Token a2 = null;
        match(38);
        a1 = LT(1);
        match(35);
        a2 = LT(1);
        match(5);
        if (guessing == 0)
        {
            behavior.refExceptionHandler(a1, a2.getText());
        }
    }

    public final void exceptionSpec() throws ParserException
    {
        Token aa = null;
        Token labelAction = null;
        match(37);
        if (la_1 == 35)
        {
            aa = LT(1);
            match(35);
            if (guessing == 0)
            {
                labelAction = aa;
            }
        }
        if (guessing == 0)
        {
            behavior.beginExceptionSpec(labelAction);
        }
        while (la_1 == 38)
        {
            exceptionHandler();
        }
        if (guessing == 0)
        {
            behavior.endExceptionSpec();
        }
    }

    public final void exceptionSpecNoLabel() throws ParserException
    {
        match(37);
        if (guessing == 0)
        {
            behavior.beginExceptionSpec(null);
        }
        while (la_1 == 38)
        {
            exceptionHandler();
        }
        if (guessing == 0)
        {
            behavior.endExceptionSpec();
        }
    }

    public final void fileOptionsSpec() throws ParserException
    {
        Token o = null;
        switch (la_1)
        {
            case 11: // '\013'
                o = LT(1);
                match(11);
                match(12);
                if (guessing == 0)
                {
                    Tool.warning("please use 'options {...}'", o.getLine());
                }
                break;

            case 13: // '\r'
                match(13);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        int _cnt = 0;
        do
        {
            if (la_1 == 24 || la_1 == 28)
            {
                Token idTok = id();
                match(14);
                Token value = optionValue();
                if (guessing == 0)
                {
                    behavior.setFileOption(idTok, value);
                }
                match(15);
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (la_1 == 16)
        {
            match(16);
        }
    }

    public final void grammar() throws ParserException
    {
        Token h = null;
        try
        {
            if (la_1 == 4)
            {
                match(4);
                h = LT(1);
                match(5);
                if (guessing == 0)
                {
                    behavior.refHeaderAction(h);
                }
            }
            if (la_1 == 11 || la_1 == 13)
            {
                fileOptionsSpec();
            }
            while (la_1 >= 5 && la_1 <= 7)
            {
                classDef();
            }
            match(1);
        }
        catch (ParserException ex)
        {
            if (guessing == 0)
            {
                reportError("rule grammar trapped: " + ex.toString());
                consumeUntil(1);
            }
            else
            {
                throw ex;
            }
        }
    }

    public final Token id() throws ParserException
    {
        Token a = null;
        Token b = null;
        Token idTok = null;
        switch (la_1)
        {
            case 24: // '\030'
                a = LT(1);
                match(24);
                if (guessing == 0)
                {
                    idTok = a;
                }
                break;

            case 28: // '\034'
                b = LT(1);
                match(28);
                if (guessing == 0)
                {
                    idTok = b;
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        return idTok;
    }

    private boolean lastInRule()
    {
        return blockNesting == 0 && (LA(1) == 15 || LA(1) == 37 || LA(1) == 21);
    }

    public final void lexerOptionsSpec() throws ParserException
    {
        Token o = null;
        switch (la_1)
        {
            case 11: // '\013'
                o = LT(1);
                match(11);
                match(12);
                if (guessing == 0)
                {
                    System.out.println("warning: line " + o.getLine() + ": please use 'options {...}'");
                }
                break;

            case 13: // '\r'
                match(13);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        int _cnt = 0;
        do
        {
            if (la_1 == 17)
            {
                match(17);
                match(14);
                BitSet b = charSet();
                match(15);
                if (guessing == 0)
                {
                    behavior.setCharVocabulary(b);
                }
            }
            else if ((la_1 == 24 || la_1 == 28) && la_2 == 14)
            {
                Token idTok = id();
                match(14);
                Token value = optionValue();
                if (guessing == 0)
                {
                    behavior.setGrammarOption(idTok, value);
                }
                match(15);
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (la_1 == 16)
        {
            match(16);
        }
    }

    public final void lexerSpec() throws ParserException
    {
        Token lc = null;
        Token a = null;
        String sup = null;
        Token idTok;
        switch (la_1)
        {
            case 6: // '\006'
                lc = LT(1);
                match(6);
                idTok = id();
                if (guessing == 0)
                {
                    System.out.println("warning: line " + lc.getLine()
                            + ": 'lexclass' is deprecated; use 'class X extends Lexer'");
                }
                break;

            case 7: // '\007'
                match(7);
                idTok = id();
                match(8);
                match(9);
                if (la_1 == 27)
                {
                    sup = superClass();
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        if (guessing == 0)
        {
            behavior.startLexer(idTok, sup);
        }
        match(15);
        if (la_1 == 11 || la_1 == 13)
        {
            lexerOptionsSpec();
        }
        if (la_1 == 23)
        {
            tokensSpec();
        }
        if (guessing == 0)
        {
            behavior.endOptions();
        }
        if (la_1 == 5)
        {
            a = LT(1);
            match(5);
            if (guessing == 0)
            {
                behavior.refMemberAction(a);
            }
        }
    }

    public final void notTerminal(Token label) throws ParserException
    {
        Token cl = null;
        Token tr = null;
        int autoGen = 1;
        switch (la_1)
        {
            case 19: // '\023'
                cl = LT(1);
                match(19);
                if (la_1 == 34)
                {
                    match(34);
                    if (guessing == 0)
                    {
                        autoGen = 3;
                    }
                }
                if (guessing == 0)
                {
                    behavior.refCharLiteral(cl, label, true, autoGen, lastInRule());
                }
                break;

            case 24: // '\030'
                tr = LT(1);
                match(24);
                autoGen = ast_type_spec();
                if (guessing == 0)
                {
                    behavior.refToken(null, tr, label, null, true, autoGen, lastInRule());
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
    }

    public final Token optionValue() throws ParserException
    {
        Token sl = null;
        Token cl = null;
        Token il = null;
        Token retval = null;
        switch (la_1)
        {
            case 15: // '\017'
                break;

            case 24: // '\030'
            case 28: // '\034'
                retval = id();
                break;

            case 18: // '\022'
                sl = LT(1);
                match(18);
                if (guessing == 0)
                {
                    retval = sl;
                }
                break;

            case 19: // '\023'
                cl = LT(1);
                match(19);
                if (guessing == 0)
                {
                    retval = cl;
                }
                break;

            case 20: // '\024'
                il = LT(1);
                match(20);
                if (guessing == 0)
                {
                    retval = il;
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        return retval;
    }

    public final void parserOptionsSpec() throws ParserException
    {
        Token o = null;
        switch (la_1)
        {
            case 11: // '\013'
                o = LT(1);
                match(11);
                match(12);
                if (guessing == 0)
                {
                    Tool.warning("please use 'options {...}'", o.getLine());
                }
                break;

            case 13: // '\r'
                match(13);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        int _cnt = 0;
        do
        {
            if ((la_1 == 24 || la_1 == 28) && la_2 == 14)
            {
                Token idTok = id();
                match(14);
                Token value = optionValue();
                if (guessing == 0)
                {
                    behavior.setGrammarOption(idTok, value);
                }
                match(15);
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (la_1 == 16)
        {
            match(16);
        }
    }

    public final void parserSpec() throws ParserException
    {
        Token a = null;
        String sup = null;
        match(7);
        Token idTok = id();
        switch (la_1)
        {
            case 8: // '\b'
                match(8);
                match(30);
                if (la_1 == 27)
                {
                    sup = superClass();
                }
                break;

            case 15: // '\017'
                if (guessing == 0)
                {
                    System.out.println("warning: line " + idTok.getLine() + ": use 'class X extends Parser'");
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        if (guessing == 0)
        {
            behavior.startParser(idTok, sup);
        }
        match(15);
        if (la_1 == 11 || la_1 == 13)
        {
            parserOptionsSpec();
        }
        if (la_1 == 23)
        {
            tokensSpec();
        }
        if (guessing == 0)
        {
            behavior.endOptions();
        }
        if (la_1 == 5)
        {
            a = LT(1);
            match(5);
            if (guessing == 0)
            {
                behavior.refMemberAction(a);
            }
        }
    }

    public final void range(Token label) throws ParserException
    {
        Token crLeft = null;
        Token crRight = null;
        Token t = null;
        Token u = null;
        Token v = null;
        Token w = null;
        Token trLeft = null;
        Token trRight = null;
        int autoGen = 1;
        switch (la_1)
        {
            case 19: // '\023'
                crLeft = LT(1);
                match(19);
                match(22);
                crRight = LT(1);
                match(19);
                if (la_1 == 34)
                {
                    match(34);
                    if (guessing == 0)
                    {
                        autoGen = 3;
                    }
                }
                if (guessing == 0)
                {
                    behavior.refCharRange(crLeft, crRight, label, autoGen, lastInRule());
                }
                break;

            case 18: // '\022'
            case 24: // '\030'
                switch (la_1)
                {
                    case 24: // '\030'
                        t = LT(1);
                        match(24);
                        if (guessing == 0)
                        {
                            trLeft = t;
                        }
                        break;

                    case 18: // '\022'
                        u = LT(1);
                        match(18);
                        if (guessing == 0)
                        {
                            trLeft = u;
                        }
                        break;

                    default:
                        throw new NoViableAltException(LT(1));
                }
                match(22);
                switch (la_1)
                {
                    case 24: // '\030'
                        v = LT(1);
                        match(24);
                        if (guessing == 0)
                        {
                            trRight = v;
                        }
                        break;

                    case 18: // '\022'
                        w = LT(1);
                        match(18);
                        if (guessing == 0)
                        {
                            trRight = w;
                        }
                        break;

                    default:
                        throw new NoViableAltException(LT(1));
                }
                autoGen = ast_type_spec();
                if (guessing == 0)
                {
                    behavior.refTokenRange(trLeft, trRight, label, autoGen, lastInRule());
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
    }

    public final void rootNode() throws ParserException
    {
        Token label = null;
        if ((la_1 == 24 || la_1 == 28) && la_2 == 12)
        {
            label = id();
            match(12);
        }
        terminal(label);
    }

    public final void rule() throws ParserException
    {
        Token p1 = null;
        Token p2 = null;
        Token p3 = null;
        Token aa = null;
        Token rt = null;
        Token a = null;
        String access = "public";
        boolean ruleAutoGen = true;
        blockNesting = -1;
        switch (la_1)
        {
            default:
                break;

            case 31: // '\037'
                p1 = LT(1);
                match(31);
                if (guessing == 0)
                {
                    access = p1.getText();
                }
                break;

            case 32: // ' '
                p2 = LT(1);
                match(32);
                if (guessing == 0)
                {
                    access = p2.getText();
                }
                break;

            case 33: // '!'
                p3 = LT(1);
                match(33);
                if (guessing == 0)
                {
                    access = p3.getText();
                }
                break;
        }
        Token idTok = id();
        if (la_1 == 34)
        {
            match(34);
            if (guessing == 0)
            {
                ruleAutoGen = false;
            }
        }
        if (guessing == 0)
        {
            behavior.defineRuleName(idTok, access, ruleAutoGen);
        }
        if (la_1 == 35)
        {
            aa = LT(1);
            match(35);
            if (guessing == 0)
            {
                behavior.refArgAction(aa);
            }
        }
        if (la_1 == 36)
        {
            match(36);
            rt = LT(1);
            match(35);
            if (guessing == 0)
            {
                behavior.refReturnAction(rt);
            }
        }
        if (la_1 == 11 || la_1 == 13)
        {
            ruleOptionsSpec();
        }
        if (la_1 == 5)
        {
            a = LT(1);
            match(5);
            if (guessing == 0)
            {
                behavior.refInitAction(a);
            }
        }
        match(12);
        block();
        match(15);
        if (la_1 == 37)
        {
            exceptionGroup();
        }
        if (guessing == 0)
        {
            behavior.endRule(idTok.getText());
        }
    }

    public final void ruleOptionsSpec() throws ParserException
    {
        Token o = null;
        switch (la_1)
        {
            case 11: // '\013'
                o = LT(1);
                match(11);
                match(12);
                if (guessing == 0)
                {
                    System.out.println("warning: line " + o.getLine() + ": please use 'options {...}'");
                }
                break;

            case 13: // '\r'
                match(13);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        int _cnt = 0;
        do
        {
            if (la_1 == 24 || la_1 == 28)
            {
                Token idTok = id();
                match(14);
                Token value = optionValue();
                if (guessing == 0)
                {
                    behavior.setRuleOption(idTok, value);
                }
                match(15);
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (la_1 == 16)
        {
            match(16);
        }
    }

    public final void rules() throws ParserException
    {
        int _cnt = 0;
        do
        {
            if (_tokenSet_0.member(la_1))
            {
                rule();
            }
            else if (_cnt < 1)
            {
                throw new NoViableAltException(LT(1));
            }
            else
            {
                return;
            }
            _cnt++;
        }
        while (true);
    }

    public final BitSet setBlockElement() throws ParserException
    {
        Token c1 = null;
        Token c2 = null;
        BitSet b = null;
        int rangeMin = 0;
        c1 = LT(1);
        match(19);
        if (guessing == 0)
        {
            rangeMin = ANTLRLexer.escapeCharValue(c1.getText());
            b = BitSet.of(rangeMin);
        }
        if (la_1 == 22)
        {
            match(22);
            c2 = LT(1);
            match(19);
            if (guessing == 0)
            {
                int rangeMax = ANTLRLexer.escapeCharValue(c2.getText());
                if (rangeMax < rangeMin)
                {
                    tool.error("Malformed range", c1.getLine());
                }
                for (int i = rangeMin + 1; i <= rangeMax; i++)
                {
                    b.add(i);
                }

            }
        }
        return b;
    }

    public final String superClass() throws ParserException
    {
        String sup = null;
        match(27);
        if (guessing == 0)
        {
            sup = LT(1).getText();
        }
        switch (la_1)
        {
            case 24: // '\030'
                match(24);
                break;

            case 28: // '\034'
                match(28);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        match(29);
        return sup;
    }

    public final void terminal(Token label) throws ParserException
    {
        Token cl = null;
        Token tr = null;
        Token aa = null;
        Token sl = null;
        Token wi = null;
        int autoGen = 1;
        Token args = null;
        switch (la_1)
        {
            case 19: // '\023'
                cl = LT(1);
                match(19);
                if (la_1 == 34)
                {
                    match(34);
                    if (guessing == 0)
                    {
                        autoGen = 3;
                    }
                }
                if (guessing == 0)
                {
                    behavior.refCharLiteral(cl, label, false, autoGen, lastInRule());
                }
                break;

            case 24: // '\030'
                tr = LT(1);
                match(24);
                autoGen = ast_type_spec();
                if (la_1 == 35)
                {
                    aa = LT(1);
                    match(35);
                    if (guessing == 0)
                    {
                        args = aa;
                    }
                }
                if (guessing == 0)
                {
                    behavior.refToken(null, tr, label, args, false, autoGen, lastInRule());
                }
                break;

            case 18: // '\022'
                sl = LT(1);
                match(18);
                autoGen = ast_type_spec();
                if (guessing == 0)
                {
                    behavior.refStringLiteral(sl, label, autoGen, lastInRule());
                }
                break;

            case 47: // '/'
                wi = LT(1);
                match(47);
                autoGen = ast_type_spec();
                if (guessing == 0)
                {
                    behavior.refWildcard(wi, label, autoGen);
                }
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
    }

    public final void tokensSpec() throws ParserException
    {
        match(23);
        match(24);
        if (la_1 == 14)
        {
            match(14);
            match(18);
        }
        do
        {
            if (la_1 != 25)
            {
                break;
            }
            match(25);
            match(24);
            if (la_1 == 14)
            {
                match(14);
                match(18);
            }
        }
        while (true);
        match(16);
    }

    public final void tree() throws ParserException
    {
        Token lp = null;
        lp = LT(1);
        match(41);
        if (guessing == 0)
        {
            behavior.beginTree(lp.getLine());
        }
        rootNode();
        if (guessing == 0)
        {
            behavior.beginChildList();
        }
        int _cnt = 0;
        do
        {
            if (_tokenSet_1.member(la_1))
            {
                element();
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (guessing == 0)
        {
            behavior.endChildList();
        }
        match(29);
        if (guessing == 0)
        {
            behavior.endTree();
        }
    }

    public final void treeParserOptionsSpec() throws ParserException
    {
        Token o = null;
        switch (la_1)
        {
            case 11: // '\013'
                o = LT(1);
                match(11);
                match(12);
                if (guessing == 0)
                {
                    Tool.warning("please use 'options {...}'", o.getLine());
                }
                break;

            case 13: // '\r'
                match(13);
                break;

            default:
                throw new NoViableAltException(LT(1));
        }
        int _cnt = 0;
        do
        {
            if ((la_1 == 24 || la_1 == 28) && la_2 == 14)
            {
                Token idTok = id();
                match(14);
                Token value = optionValue();
                if (guessing == 0)
                {
                    behavior.setGrammarOption(idTok, value);
                }
                match(15);
            }
            else
            {
                if (_cnt < 1)
                {
                    throw new NoViableAltException(LT(1));
                }
                break;
            }
            _cnt++;
        }
        while (true);
        if (la_1 == 16)
        {
            match(16);
        }
    }

    public final void treeParserSpec() throws ParserException
    {
        Token a = null;
        String sup = null;
        match(7);
        Token idTok = id();
        match(8);
        match(10);
        if (la_1 == 27)
        {
            sup = superClass();
        }
        if (guessing == 0)
        {
            behavior.startTreeWalker(idTok, sup);
        }
        match(15);
        if (la_1 == 11 || la_1 == 13)
        {
            treeParserOptionsSpec();
        }
        if (la_1 == 23)
        {
            tokensSpec();
        }
        if (guessing == 0)
        {
            behavior.endOptions();
        }
        if (la_1 == 5)
        {
            a = LT(1);
            match(5);
            if (guessing == 0)
            {
                behavior.refMemberAction(a);
            }
        }
    }

    public static final String version = "2.20b7";

    ANTLRGrammarParseBehavior behavior;

    Tool tool;

    protected int blockNesting;

    public static final String TOKEN_NAMES[] =
    {
        "<0>", "EOF", "<epsilon>", "NULL_TREE_LOOKAHEAD", "\"header\"", "ACTION", "\"lexclass\"", "\"class\"",
        "\"extends\"", "\"Lexer\"", "\"TreeParser\"", "\"options\"", "COLON", "OPTIONS", "ASSIGN", "SEMI", "RCURLY",
        "\"charVocabulary\"", "STRING_LITERAL", "CHAR_LITERAL", "INT", "OR", "RANGE", "TOKENS", "TOKEN_REF", "COMMA",
        "\"tokens\"", "LPAREN", "RULE_REF", "RPAREN", "\"Parser\"", "\"protected\"", "\"public\"", "\"private\"",
        "BANG", "ARG_ACTION", "\"returns\"", "\"exception\"", "\"catch\"", "NOT_OP", "SEMPRED", "TREE_BEGIN",
        "QUESTION", "STAR", "PLUS", "IMPLIES", "CARET", "WILDCARD", "WS", "COMMENT", "SL_COMMENT", "ML_COMMENT", "ESC",
        "DIGIT", "XDIGIT", "VOCAB", "NESTED_ARG_ACTION", "NESTED_ACTION", "INTERNAL_RULE_REF", "TREE_SPECIFIER",
        "POINTER", "TREE_SPECIFIER_TERM", "TREE_SPECIFIER_BLOCK", "WS_OPT"
    };

    private static final long _tokenSet_0_data_[] =
    {
        0x391000000L, 0L
    };

    public static final BitSet _tokenSet_0 = new BitSet(_tokenSet_0_data_);

    private static final long _tokenSet_1_data_[] =
    {
        0x8380190c0020L, 0L
    };

    public static final BitSet _tokenSet_1 = new BitSet(_tokenSet_1_data_);

    private static final long _tokenSet_2_data_[] =
    {
        0x8080190c0000L, 0L
    };

    public static final BitSet _tokenSet_2 = new BitSet(_tokenSet_2_data_);

    private static final long _tokenSet_3_data_[] =
    {
        0xc3ac396c9020L, 0L
    };

    public static final BitSet _tokenSet_3 = new BitSet(_tokenSet_3_data_);

    private static final long _tokenSet_4_data_[] =
    {
        0x8000010c0000L, 0L
    };

    public static final BitSet _tokenSet_4 = new BitSet(_tokenSet_4_data_);

    private static final long _tokenSet_5_data_[] =
    {
        0xc3ac392c8020L, 0L
    };

    public static final BitSet _tokenSet_5 = new BitSet(_tokenSet_5_data_);

    private static final long _tokenSet_6_data_[] =
    {
        0x83a4392c0020L, 0L
    };

    public static final BitSet _tokenSet_6 = new BitSet(_tokenSet_6_data_);

    private static final long _tokenSet_7_data_[] =
    {
        0xffec396cd020L, 0L
    };

    public static final BitSet _tokenSet_7 = new BitSet(_tokenSet_7_data_);

}
TOP

Related Classes of net.sf.jcontracts.antlr.ANTLRParser

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.