Package net.sf.jcontracts.antlr

Examples of net.sf.jcontracts.antlr.Token


        tokenNames_ = TOKEN_NAMES;
    }

    public final Grammar class_def(Hierarchy hier) throws ParserException
    {
        Token preamble = null;
        Token sub = null;
        Token sup = null;
        Token memberA = null;
        Grammar gr = null;
        IndexedVector rules = new IndexedVector(100);
        IndexedVector classOptions = null;
        try
        {
            if (la_1 == 5)
            {
                preamble = LT(1);
                match(5);
            }
            match(6);
            sub = LT(1);
            match(7);
            match(8);
            sup = LT(1);
            match(7);
            match(9);
            gr = hier.getGrammar(sub.getText());
            if (gr != null)
            {
                net.sf.jcontracts.antlr.Tool.toolError("redefinition of grammar " + gr.getName() + " ignored");
                gr = null;
            }
            else
            {
                gr = new Grammar(sub.getText(), sup.getText(), rules);
                if (preamble != null)
                {
                    gr.setPreambleAction(preamble.getText());
                }
            }
            if (la_1 == 17)
            {
                classOptions = optionSpec(gr);
            }
            if (gr != null)
            {
                gr.setOptions(classOptions);
            }
            if (la_1 == 10)
            {
                tokensSpec();
            }
            if (la_1 == 5)
            {
                memberA = LT(1);
                match(5);
                gr.setMemberAction(memberA.getText());
            }
            int _cnt = 0;
            do
            {
                if (_tokenSet_2.member(la_1))
View Full Code Here


        }
    }

    public final void grammarFile(Hierarchy hier, String file) throws ParserException
    {
        Token hdr = null;
        IndexedVector opt = null;
        try
        {
            if (la_1 == 4)
            {
                hdr = LT(1);
                match(4);
            }
            if (la_1 == 17)
            {
                opt = optionSpec(null);
            }
            do
            {
                if (la_1 != 5 && la_1 != 6)
                {
                    break;
                }
                Grammar gr = class_def(hier);
                if (hdr != null)
                {
                    hier.getFile(file).setHeaderAction(hdr.getText());
                }
                if (opt != null)
                {
                    hier.getFile(file).setOptions(opt);
                }
View Full Code Here

        }
    }

    public final IndexedVector optionSpec(Grammar gr) throws ParserException
    {
        Token op = null;
        Token rhs = null;
        IndexedVector options = new IndexedVector();
        try
        {
            match(17);
            int _cnt = 0;
            do
            {
                if (la_1 == 7)
                {
                    op = LT(1);
                    match(7);
                    rhs = LT(1);
                    match(18);
                    Option newOp = new Option(op.getText(), rhs.getText(), gr);
                    options.appendElement(newOp.getName(), newOp);
                    if (rhs.getText().equals("tokdef"))
                    {
                        gr.specifiedVocabulary = true;
                    }
                }
                else
View Full Code Here

        return options;
    }

    public final void rule(Grammar gr) throws ParserException
    {
        Token r = null;
        Token arg = null;
        Token ret = null;
        Token init = null;
        Token blk = null;
        IndexedVector o = null;
        String vis = null;
        boolean bang = false;
        try
        {
            switch (la_1)
            {
                case 19: // '\023'
                    match(19);
                    vis = "protected";
                    break;

                case 20: // '\024'
                    match(20);
                    vis = "private";
                    break;

                case 21: // '\025'
                    match(21);
                    vis = "public";
                    break;
            }
            r = LT(1);
            match(7);
            if (la_1 == 22)
            {
                match(22);
                bang = true;
            }
            if (la_1 == 23)
            {
                arg = LT(1);
                match(23);
            }
            if (la_1 == 24)
            {
                match(24);
                ret = LT(1);
                match(23);
            }
            if (la_1 == 17)
            {
                o = optionSpec(null);
            }
            if (la_1 == 5)
            {
                init = LT(1);
                match(5);
            }
            blk = LT(1);
            match(25);
            match(9);
            if (la_1 == 26)
            {
                exceptionGroup();
            }
            Rule ppr = new Rule(r.getText(), blk.getText() + ";", o, gr);
            if (arg != null)
            {
                ppr.setArgs(arg.getText());
            }
            if (ret != null)
View Full Code Here

        this(new CharBufferNoBacktrackingNoInteractive(in));
    }

    public final void mACTION(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 5;
        match('{');
        do
        {
            switch (la_1)
            {
                case 10: // '\n'
                    match('\n');
                    newline();
                    continue;

                case 123: // '{'
                    mACTION(false);
                    continue;

                case 39: // '\''
                    mCHAR_LITERAL(false);
                    continue;

                case 34: // '"'
                    mSTRING_LITERAL(false);
                    continue;
            }
            if (la_1 == '/' && (la_2 == '*' || la_2 == '/') && (LA(2) == '/' || LA(2) == '*'))
            {
                mCOMMENT(false);
                continue;
            }
            if (la_1 == '/' && la_2 >= '\003' && la_2 <= '~')
            {
                match('/');
                continue;
            }
            if (!_tokenSet_4.member(la_1))
            {
                break;
            }
            matchNot('}');
        }
        while (true);
        match('}');
        if (_createToken)
        {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
        }
        returnToken_ = _token;
    }
View Full Code Here

        returnToken_ = _token;
    }

    protected final void mALT(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 29;
        while (_tokenSet_1.member(la_1))
        {
            mELEMENT(false);
        }
        if (_createToken)
        {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
        }
        returnToken_ = _token;
    }
View Full Code Here

        returnToken_ = _token;
    }

    public final void mARG_ACTION(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 23;
        match('[');
        label0: do
        {
            switch (la_1)
            {
                case 91: // '['
                    mARG_ACTION(false);
                    break;

                case 10: // '\n'
                    match('\n');
                    newline();
                    break;

                case 39: // '\''
                    mCHAR_LITERAL(false);
                    break;

                case 34: // '"'
                    mSTRING_LITERAL(false);
                    break;

                case 3: // '\003'
                case 4: // '\004'
                case 5: // '\005'
                case 6: // '\006'
                case 7: // '\007'
                case 8: // '\b'
                case 9: // '\t'
                case 11: // '\013'
                case 12: // '\f'
                case 13: // '\r'
                case 14: // '\016'
                case 15: // '\017'
                case 16: // '\020'
                case 17: // '\021'
                case 18: // '\022'
                case 19: // '\023'
                case 20: // '\024'
                case 21: // '\025'
                case 22: // '\026'
                case 23: // '\027'
                case 24: // '\030'
                case 25: // '\031'
                case 26: // '\032'
                case 27: // '\033'
                case 28: // '\034'
                case 29: // '\035'
                case 30: // '\036'
                case 31: // '\037'
                case 32: // ' '
                case 33: // '!'
                case 35: // '#'
                case 36: // '$'
                case 37: // '%'
                case 38: // '&'
                case 40: // '('
                case 41: // ')'
                case 42: // '*'
                case 43: // '+'
                case 44: // ','
                case 45: // '-'
                case 46: // '.'
                case 47: // '/'
                case 48: // '0'
                case 49: // '1'
                case 50: // '2'
                case 51: // '3'
                case 52: // '4'
                case 53: // '5'
                case 54: // '6'
                case 55: // '7'
                case 56: // '8'
                case 57: // '9'
                case 58: // ':'
                case 59: // ';'
                case 60: // '<'
                case 61: // '='
                case 62: // '>'
                case 63: // '?'
                case 64: // '@'
                case 65: // 'A'
                case 66: // 'B'
                case 67: // 'C'
                case 68: // 'D'
                case 69: // 'E'
                case 70: // 'F'
                case 71: // 'G'
                case 72: // 'H'
                case 73: // 'I'
                case 74: // 'J'
                case 75: // 'K'
                case 76: // 'L'
                case 77: // 'M'
                case 78: // 'N'
                case 79: // 'O'
                case 80: // 'P'
                case 81: // 'Q'
                case 82: // 'R'
                case 83: // 'S'
                case 84: // 'T'
                case 85: // 'U'
                case 86: // 'V'
                case 87: // 'W'
                case 88: // 'X'
                case 89: // 'Y'
                case 90: // 'Z'
                case 92: // '\\'
                case 94: // '^'
                case 95: // '_'
                case 96: // '`'
                case 97: // 'a'
                case 98: // 'b'
                case 99: // 'c'
                case 100: // 'd'
                case 101: // 'e'
                case 102: // 'f'
                case 103: // 'g'
                case 104: // 'h'
                case 105: // 'i'
                case 106: // 'j'
                case 107: // 'k'
                case 108: // 'l'
                case 109: // 'm'
                case 110: // 'n'
                case 111: // 'o'
                case 112: // 'p'
                case 113: // 'q'
                case 114: // 'r'
                case 115: // 's'
                case 116: // 't'
                case 117: // 'u'
                case 118: // 'v'
                case 119: // 'w'
                case 120: // 'x'
                case 121: // 'y'
                case 122: // 'z'
                case 123: // '{'
                case 124: // '|'
                case 125: // '}'
                case 126: // '~'
                    matchNot(']');
                    break;

                default:
                    match(']');
                    break label0;
            }
        }
        while (true);
        if (_createToken)
        {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
        }
        returnToken_ = _token;
    }
View Full Code Here

        returnToken_ = _token;
    }

    public final void mASSIGN_RHS(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 18;
        int _saveIndex = text.length();
        match('=');
        text.setLength(_saveIndex);
        if (_tokenSet_0.member(la_1) && la_2 >= '\003' && la_2 <= '~')
        {
            _saveIndex = text.length();
            mWS(false);
            text.setLength(_saveIndex);
        }
        do
        {
            switch (la_1)
            {
                case 34: // '"'
                    mSTRING_LITERAL(false);
                    break;

                case 39: // '\''
                    mCHAR_LITERAL(false);
                    break;

                case 3: // '\003'
                case 4: // '\004'
                case 5: // '\005'
                case 6: // '\006'
                case 7: // '\007'
                case 8: // '\b'
                case 9: // '\t'
                case 10: // '\n'
                case 11: // '\013'
                case 12: // '\f'
                case 13: // '\r'
                case 14: // '\016'
                case 15: // '\017'
                case 16: // '\020'
                case 17: // '\021'
                case 18: // '\022'
                case 19: // '\023'
                case 20: // '\024'
                case 21: // '\025'
                case 22: // '\026'
                case 23: // '\027'
                case 24: // '\030'
                case 25: // '\031'
                case 26: // '\032'
                case 27: // '\033'
                case 28: // '\034'
                case 29: // '\035'
                case 30: // '\036'
                case 31: // '\037'
                case 32: // ' '
                case 33: // '!'
                case 35: // '#'
                case 36: // '$'
                case 37: // '%'
                case 38: // '&'
                case 40: // '('
                case 41: // ')'
                case 42: // '*'
                case 43: // '+'
                case 44: // ','
                case 45: // '-'
                case 46: // '.'
                case 47: // '/'
                case 48: // '0'
                case 49: // '1'
                case 50: // '2'
                case 51: // '3'
                case 52: // '4'
                case 53: // '5'
                case 54: // '6'
                case 55: // '7'
                case 56: // '8'
                case 57: // '9'
                case 58: // ':'
                case 60: // '<'
                case 61: // '='
                case 62: // '>'
                case 63: // '?'
                case 64: // '@'
                case 65: // 'A'
                case 66: // 'B'
                case 67: // 'C'
                case 68: // 'D'
                case 69: // 'E'
                case 70: // 'F'
                case 71: // 'G'
                case 72: // 'H'
                case 73: // 'I'
                case 74: // 'J'
                case 75: // 'K'
                case 76: // 'L'
                case 77: // 'M'
                case 78: // 'N'
                case 79: // 'O'
                case 80: // 'P'
                case 81: // 'Q'
                case 82: // 'R'
                case 83: // 'S'
                case 84: // 'T'
                case 85: // 'U'
                case 86: // 'V'
                case 87: // 'W'
                case 88: // 'X'
                case 89: // 'Y'
                case 90: // 'Z'
                case 91: // '['
                case 92: // '\\'
                case 93: // ']'
                case 94: // '^'
                case 95: // '_'
                case 96: // '`'
                case 97: // 'a'
                case 98: // 'b'
                case 99: // 'c'
                case 100: // 'd'
                case 101: // 'e'
                case 102: // 'f'
                case 103: // 'g'
                case 104: // 'h'
                case 105: // 'i'
                case 106: // 'j'
                case 107: // 'k'
                case 108: // 'l'
                case 109: // 'm'
                case 110: // 'n'
                case 111: // 'o'
                case 112: // 'p'
                case 113: // 'q'
                case 114: // 'r'
                case 115: // 's'
                case 116: // 't'
                case 117: // 'u'
                case 118: // 'v'
                case 119: // 'w'
                case 120: // 'x'
                case 121: // 'y'
                case 122: // 'z'
                case 123: // '{'
                case 124: // '|'
                case 125: // '}'
                case 126: // '~'
                    int _cnt;
                    for (_cnt = 0; _tokenSet_6.member(la_1) && la_2 >= '\003' && la_2 <= '~'; _cnt++)
                    {
                        match(_tokenSet_6);
                    }

                    if (_cnt < 1)
                    {
                        throw new ScannerException("no viable alt for char: " + LA(1), getLine());
                    }
                    break;

                default:
                    match(';');
                    if (_createToken)
                    {
                        _token = makeToken(_ttype);
                        _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
                    }
                    returnToken_ = _token;
                    return;
            }
        }
View Full Code Here

        while (true);
    }

    public final void mBANG(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 22;
        match('!');
        if (_createToken)
        {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
        }
        returnToken_ = _token;
    }
View Full Code Here

        returnToken_ = _token;
    }

    public final void mCHAR_LITERAL(boolean _createToken) throws ScannerException
    {
        Token _token = null;
        int _begin = text.length();
        int _ttype = 36;
        match('\'');
        switch (la_1)
        {
            case 92: // '\\'
                mESC(false);
                break;

            case 3: // '\003'
            case 4: // '\004'
            case 5: // '\005'
            case 6: // '\006'
            case 7: // '\007'
            case 8: // '\b'
            case 9: // '\t'
            case 10: // '\n'
            case 11: // '\013'
            case 12: // '\f'
            case 13: // '\r'
            case 14: // '\016'
            case 15: // '\017'
            case 16: // '\020'
            case 17: // '\021'
            case 18: // '\022'
            case 19: // '\023'
            case 20: // '\024'
            case 21: // '\025'
            case 22: // '\026'
            case 23: // '\027'
            case 24: // '\030'
            case 25: // '\031'
            case 26: // '\032'
            case 27: // '\033'
            case 28: // '\034'
            case 29: // '\035'
            case 30: // '\036'
            case 31: // '\037'
            case 32: // ' '
            case 33: // '!'
            case 34: // '"'
            case 35: // '#'
            case 36: // '$'
            case 37: // '%'
            case 38: // '&'
            case 40: // '('
            case 41: // ')'
            case 42: // '*'
            case 43: // '+'
            case 44: // ','
            case 45: // '-'
            case 46: // '.'
            case 47: // '/'
            case 48: // '0'
            case 49: // '1'
            case 50: // '2'
            case 51: // '3'
            case 52: // '4'
            case 53: // '5'
            case 54: // '6'
            case 55: // '7'
            case 56: // '8'
            case 57: // '9'
            case 58: // ':'
            case 59: // ';'
            case 60: // '<'
            case 61: // '='
            case 62: // '>'
            case 63: // '?'
            case 64: // '@'
            case 65: // 'A'
            case 66: // 'B'
            case 67: // 'C'
            case 68: // 'D'
            case 69: // 'E'
            case 70: // 'F'
            case 71: // 'G'
            case 72: // 'H'
            case 73: // 'I'
            case 74: // 'J'
            case 75: // 'K'
            case 76: // 'L'
            case 77: // 'M'
            case 78: // 'N'
            case 79: // 'O'
            case 80: // 'P'
            case 81: // 'Q'
            case 82: // 'R'
            case 83: // 'S'
            case 84: // 'T'
            case 85: // 'U'
            case 86: // 'V'
            case 87: // 'W'
            case 88: // 'X'
            case 89: // 'Y'
            case 90: // 'Z'
            case 91: // '['
            case 93: // ']'
            case 94: // '^'
            case 95: // '_'
            case 96: // '`'
            case 97: // 'a'
            case 98: // 'b'
            case 99: // 'c'
            case 100: // 'd'
            case 101: // 'e'
            case 102: // 'f'
            case 103: // 'g'
            case 104: // 'h'
            case 105: // 'i'
            case 106: // 'j'
            case 107: // 'k'
            case 108: // 'l'
            case 109: // 'm'
            case 110: // 'n'
            case 111: // 'o'
            case 112: // 'p'
            case 113: // 'q'
            case 114: // 'r'
            case 115: // 's'
            case 116: // 't'
            case 117: // 'u'
            case 118: // 'v'
            case 119: // 'w'
            case 120: // 'x'
            case 121: // 'y'
            case 122: // 'z'
            case 123: // '{'
            case 124: // '|'
            case 125: // '}'
            case 126: // '~'
                matchNot('\'');
                break;

            default:
                throw new ScannerException("no viable alt for char: " + LA(1), getLine());
        }
        match('\'');
        if (_createToken)
        {
            _token = makeToken(_ttype);
            _token.setText(new String(text.getBuffer(), _begin, text.length() - _begin));
        }
        returnToken_ = _token;
    }
View Full Code Here

TOP

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

Copyright © 2018 www.massapicom. 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.