Example usage for org.antlr.v4.runtime Token EOF

List of usage examples for org.antlr.v4.runtime Token EOF

Introduction

In this page you can find the example usage for org.antlr.v4.runtime Token EOF.

Prototype

int EOF

To view the source code for org.antlr.v4.runtime Token EOF.

Click Source Link

Usage

From source file:org.hawkular.alerts.engine.tags.parser.TagQueryParser.java

License:Apache License

public final Logical_operatorContext logical_operator() throws RecognitionException {
    Logical_operatorContext _localctx = new Logical_operatorContext(_ctx, getState());
    enterRule(_localctx, 6, RULE_logical_operator);
    int _la;// ww w  .j av a2 s . com
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(51);
            _la = _input.LA(1);
            if (!(_la == OR || _la == AND)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.alerts.engine.tags.parser.TagQueryParser.java

License:Apache License

public final Boolean_operatorContext boolean_operator() throws RecognitionException {
    Boolean_operatorContext _localctx = new Boolean_operatorContext(_ctx, getState());
    enterRule(_localctx, 8, RULE_boolean_operator);
    int _la;//from w  ww.j  a  va 2 s  .  co  m
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(53);
            _la = _input.LA(1);
            if (!(_la == EQUAL || _la == NOTEQUAL)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.alerts.engine.tags.parser.TagQueryParser.java

License:Apache License

public final ValueContext value() throws RecognitionException {
    ValueContext _localctx = new ValueContext(_ctx, getState());
    enterRule(_localctx, 14, RULE_value);
    int _la;/* w  w  w  . j ava  2s  .  c om*/
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(75);
            _la = _input.LA(1);
            if (!(_la == SIMPLETEXT || _la == COMPLEXTEXT)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.metrics.core.service.tags.parser.TagQueryParser.java

License:Apache License

public final Logical_operatorContext logical_operator() throws RecognitionException {
    Logical_operatorContext _localctx = new Logical_operatorContext(_ctx, getState());
    enterRule(_localctx, 6, RULE_logical_operator);
    int _la;// w ww .  ja  v a  2s .  c  om
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(59);
            _la = _input.LA(1);
            if (!(_la == OR || _la == AND)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.metrics.core.service.tags.parser.TagQueryParser.java

License:Apache License

public final Boolean_operatorContext boolean_operator() throws RecognitionException {
    Boolean_operatorContext _localctx = new Boolean_operatorContext(_ctx, getState());
    enterRule(_localctx, 8, RULE_boolean_operator);
    int _la;/*  www.  ja  v a2  s  .com*/
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(61);
            _la = _input.LA(1);
            if (!(_la == EQUAL || _la == NOTEQUAL)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.metrics.core.service.tags.parser.TagQueryParser.java

License:Apache License

public final Regex_operatorContext regex_operator() throws RecognitionException {
    Regex_operatorContext _localctx = new Regex_operatorContext(_ctx, getState());
    enterRule(_localctx, 10, RULE_regex_operator);
    int _la;//w ww . j  av  a 2  s  . c om
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(63);
            _la = _input.LA(1);
            if (!(_la == REGEXMATCH || _la == NOTREGEXMATCH)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.hawkular.metrics.core.service.tags.parser.TagQueryParser.java

License:Apache License

public final ValueContext value() throws RecognitionException {
    ValueContext _localctx = new ValueContext(_ctx, getState());
    enterRule(_localctx, 18, RULE_value);
    int _la;/*from ww  w. ja v  a2 s  .  c  om*/
    try {
        enterOuterAlt(_localctx, 1);
        {
            setState(87);
            _la = _input.LA(1);
            if (!(_la == SIMPLETEXT || _la == COMPLEXTEXT)) {
                _errHandler.recoverInline(this);
            } else {
                if (_input.LA(1) == Token.EOF)
                    matchedEOF = true;
                _errHandler.reportMatch(this);
                consume();
            }
        }
    } catch (RecognitionException re) {
        _localctx.exception = re;
        _errHandler.reportError(this, re);
        _errHandler.recover(this, re);
    } finally {
        exitRule();
    }
    return _localctx;
}

From source file:org.kaazing.k3po.lang.internal.parser.ScriptParseStrategy.java

License:Open Source License

private static int startIndex(Token token) {
    return (token != null && token.getType() != Token.EOF) ? token.getStartIndex() : 0;
}

From source file:org.kie.dmn.feel.lang.types.ScopeImpl.java

License:Apache License

private List<String> tokenize(String symbol) {
    CharStream input = CharStreams.fromString(symbol);
    FEEL_1_1Lexer lexer = new FEEL_1_1Lexer(input);
    List<String> tokens = new ArrayList<>();

    for (Token token = lexer.nextToken(); token.getType() != Token.EOF; token = lexer.nextToken()) {
        tokens.add(token.getText());//from www  .ja  va  2s. c o m
    }
    return tokens;
}

From source file:org.ng200.tslk.ide.editors.TSLKRepairer.java

License:Open Source License

@Override
public void createPresentation(TextPresentation presentation, ITypedRegion region) {
    // Use tokens provided by the lexer to highlight keywords, etc...
    // Seems fast enough to skip Eclipse partitioning. Infact, the Eclipse
    // partitioner seems to slow everything down...
    TSLKGrammarLexer lexer = new TSLKGrammarLexer(new ANTLRInputStream(document.get()));
    Token t = null;//from  w w w . j  a va 2 s . c  om
    while ((t = lexer.nextToken()).getType() != Token.EOF) {
        if (t.getStartIndex() > region.getOffset() + region.getLength())
            break;
        int start = t.getStartIndex();
        int end = t.getStopIndex();
        RGB foreground = null;
        RGB background = null;
        int style = SWT.NORMAL;
        switch (t.getType()) { // TODO: Make keywords customisable
        case TSLKGrammarLexer.WHILE:
        case TSLKGrammarLexer.FOR:
        case TSLKGrammarLexer.FUNC:
        case TSLKGrammarLexer.IF:
        case TSLKGrammarLexer.THEN:
        case TSLKGrammarLexer.DO:
        case TSLKGrammarLexer.END:
            foreground = ColorManager.KEYWORD;
            style = SWT.BOLD;
            break;
        case TSLKGrammarLexer.STRING:
            foreground = ColorManager.STRING;
            break;
        case TSLKGrammarLexer.SLCOMMENT:
            foreground = ColorManager.SINGLE_LINE_COMMENT;
            break;
        case TSLKGrammarLexer.MLCOMMENT:
            foreground = ColorManager.MULTI_LINE_COMMENT;
            break;
        default:
            foreground = ColorManager.DEFAULT;
            break;
        }
        presentation.addStyleRange(new StyleRange(start, end - start + 1, colorManager.getColor(foreground),
                colorManager.getColor(background), style));
    }
}