step.core.ql.OQLParser Maven / Gradle / Ivy
The newest version!
/*******************************************************************************
* Copyright (C) 2020, exense GmbH
*
* This file is part of STEP
*
* STEP is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* STEP is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with STEP. If not, see .
******************************************************************************/
// Generated from OQL.g4 by ANTLR 4.5.3
package step.core.ql;
import org.antlr.v4.runtime.atn.*;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.misc.*;
import org.antlr.v4.runtime.tree.*;
import java.util.List;
import java.util.Iterator;
import java.util.ArrayList;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class OQLParser extends Parser {
static { RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
EQ=1, NEQ=2, REGEX=3, OR=4, AND=5, IN=6, NOT=7, LT=8, LTE=9, GT=10, GTE=11,
OPAR=12, CPAR=13, COMMA=14, NONQUOTEDSTRING=15, STRING=16, SPACE=17;
public static final int
RULE_parse = 0, RULE_expr = 1, RULE_atom = 2;
public static final String[] ruleNames = {
"parse", "expr", "atom"
};
private static final String[] _LITERAL_NAMES = {
null, "'='", "'!='", "'~'", "'or'", "'and'", "'in'", "'not'", "'<'", "'<='",
"'>'", "'>='", "'('", "')'", "','"
};
private static final String[] _SYMBOLIC_NAMES = {
null, "EQ", "NEQ", "REGEX", "OR", "AND", "IN", "NOT", "LT", "LTE", "GT",
"GTE", "OPAR", "CPAR", "COMMA", "NONQUOTEDSTRING", "STRING", "SPACE"
};
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**
* @deprecated Use {@link #VOCABULARY} instead.
*/
@Deprecated
public static final String[] tokenNames;
static {
tokenNames = new String[_SYMBOLIC_NAMES.length];
for (int i = 0; i < tokenNames.length; i++) {
tokenNames[i] = VOCABULARY.getLiteralName(i);
if (tokenNames[i] == null) {
tokenNames[i] = VOCABULARY.getSymbolicName(i);
}
if (tokenNames[i] == null) {
tokenNames[i] = "";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "OQL.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public OQLParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class ParseContext extends ParserRuleContext {
public TerminalNode EOF() { return getToken(OQLParser.EOF, 0); }
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public ParseContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_parse; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterParse(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitParse(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitParse(this);
else return visitor.visitChildren(this);
}
}
public final ParseContext parse() throws RecognitionException {
ParseContext _localctx = new ParseContext(_ctx, getState());
enterRule(_localctx, 0, RULE_parse);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(7);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NOT) | (1L << OPAR) | (1L << NONQUOTEDSTRING) | (1L << STRING))) != 0)) {
{
setState(6);
expr(0);
}
}
setState(9);
match(EOF);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ExprContext extends ParserRuleContext {
public ExprContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_expr; }
public ExprContext() { }
public void copyFrom(ExprContext ctx) {
super.copyFrom(ctx);
}
}
public static class NotExprContext extends ExprContext {
public TerminalNode NOT() { return getToken(OQLParser.NOT, 0); }
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public NotExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterNotExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitNotExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitNotExpr(this);
else return visitor.visitChildren(this);
}
}
public static class InExprContext extends ExprContext {
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public TerminalNode IN() { return getToken(OQLParser.IN, 0); }
public TerminalNode OPAR() { return getToken(OQLParser.OPAR, 0); }
public TerminalNode CPAR() { return getToken(OQLParser.CPAR, 0); }
public List STRING() { return getTokens(OQLParser.STRING); }
public TerminalNode STRING(int i) {
return getToken(OQLParser.STRING, i);
}
public List COMMA() { return getTokens(OQLParser.COMMA); }
public TerminalNode COMMA(int i) {
return getToken(OQLParser.COMMA, i);
}
public InExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterInExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitInExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitInExpr(this);
else return visitor.visitChildren(this);
}
}
public static class AtomExprContext extends ExprContext {
public AtomContext atom() {
return getRuleContext(AtomContext.class,0);
}
public AtomExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterAtomExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitAtomExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitAtomExpr(this);
else return visitor.visitChildren(this);
}
}
public static class OrExprContext extends ExprContext {
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public TerminalNode OR() { return getToken(OQLParser.OR, 0); }
public OrExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterOrExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitOrExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitOrExpr(this);
else return visitor.visitChildren(this);
}
}
public static class ComparisonExprContext extends ExprContext {
public Token op;
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public TerminalNode LT() { return getToken(OQLParser.LT, 0); }
public TerminalNode LTE() { return getToken(OQLParser.LTE, 0); }
public TerminalNode GT() { return getToken(OQLParser.GT, 0); }
public TerminalNode GTE() { return getToken(OQLParser.GTE, 0); }
public ComparisonExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterComparisonExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitComparisonExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitComparisonExpr(this);
else return visitor.visitChildren(this);
}
}
public static class EqualityExprContext extends ExprContext {
public Token op;
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public TerminalNode EQ() { return getToken(OQLParser.EQ, 0); }
public TerminalNode NEQ() { return getToken(OQLParser.NEQ, 0); }
public TerminalNode REGEX() { return getToken(OQLParser.REGEX, 0); }
public EqualityExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterEqualityExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitEqualityExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitEqualityExpr(this);
else return visitor.visitChildren(this);
}
}
public static class AndExprContext extends ExprContext {
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public TerminalNode AND() { return getToken(OQLParser.AND, 0); }
public AndExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterAndExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitAndExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitAndExpr(this);
else return visitor.visitChildren(this);
}
}
public final ExprContext expr() throws RecognitionException {
return expr(0);
}
private ExprContext expr(int _p) throws RecognitionException {
ParserRuleContext _parentctx = _ctx;
int _parentState = getState();
ExprContext _localctx = new ExprContext(_ctx, _parentState);
ExprContext _prevctx = _localctx;
int _startState = 2;
enterRecursionRule(_localctx, 2, RULE_expr, _p);
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(15);
switch (_input.LA(1)) {
case NOT:
{
_localctx = new NotExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(12);
match(NOT);
setState(13);
expr(7);
}
break;
case OPAR:
case NONQUOTEDSTRING:
case STRING:
{
_localctx = new AtomExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(14);
atom();
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(45);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( _parseListeners!=null ) triggerExitRuleEvent();
_prevctx = _localctx;
{
setState(43);
_errHandler.sync(this);
switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
case 1:
{
_localctx = new EqualityExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(17);
if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
setState(18);
((EqualityExprContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << EQ) | (1L << NEQ) | (1L << REGEX))) != 0)) ) {
((EqualityExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
} else {
consume();
}
setState(19);
expr(7);
}
break;
case 2:
{
_localctx = new ComparisonExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(20);
if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)");
setState(21);
((ComparisonExprContext)_localctx).op = _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << LT) | (1L << LTE) | (1L << GT) | (1L << GTE))) != 0)) ) {
((ComparisonExprContext)_localctx).op = (Token)_errHandler.recoverInline(this);
} else {
consume();
}
setState(22);
expr(6);
}
break;
case 3:
{
_localctx = new AndExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(23);
if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
setState(24);
match(AND);
setState(25);
expr(5);
}
break;
case 4:
{
_localctx = new OrExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(26);
if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
setState(27);
match(OR);
setState(28);
expr(4);
}
break;
case 5:
{
_localctx = new InExprContext(new ExprContext(_parentctx, _parentState));
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(29);
if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
setState(30);
match(IN);
setState(31);
match(OPAR);
setState(40);
_la = _input.LA(1);
if (_la==STRING) {
{
setState(32);
match(STRING);
setState(37);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==COMMA) {
{
{
setState(33);
match(COMMA);
setState(34);
match(STRING);
}
}
setState(39);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
setState(42);
match(CPAR);
}
break;
}
}
}
setState(47);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,5,_ctx);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
unrollRecursionContexts(_parentctx);
}
return _localctx;
}
public static class AtomContext extends ParserRuleContext {
public AtomContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_atom; }
public AtomContext() { }
public void copyFrom(AtomContext ctx) {
super.copyFrom(ctx);
}
}
public static class ParExprContext extends AtomContext {
public TerminalNode OPAR() { return getToken(OQLParser.OPAR, 0); }
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public TerminalNode CPAR() { return getToken(OQLParser.CPAR, 0); }
public ParExprContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterParExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitParExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitParExpr(this);
else return visitor.visitChildren(this);
}
}
public static class StringAtomContext extends AtomContext {
public TerminalNode STRING() { return getToken(OQLParser.STRING, 0); }
public StringAtomContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterStringAtom(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitStringAtom(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitStringAtom(this);
else return visitor.visitChildren(this);
}
}
public static class NonQuotedStringAtomContext extends AtomContext {
public TerminalNode NONQUOTEDSTRING() { return getToken(OQLParser.NONQUOTEDSTRING, 0); }
public NonQuotedStringAtomContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).enterNonQuotedStringAtom(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof OQLListener ) ((OQLListener)listener).exitNonQuotedStringAtom(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof OQLVisitor ) return ((OQLVisitor extends T>)visitor).visitNonQuotedStringAtom(this);
else return visitor.visitChildren(this);
}
}
public final AtomContext atom() throws RecognitionException {
AtomContext _localctx = new AtomContext(_ctx, getState());
enterRule(_localctx, 4, RULE_atom);
try {
setState(54);
switch (_input.LA(1)) {
case OPAR:
_localctx = new ParExprContext(_localctx);
enterOuterAlt(_localctx, 1);
{
setState(48);
match(OPAR);
setState(49);
expr(0);
setState(50);
match(CPAR);
}
break;
case NONQUOTEDSTRING:
_localctx = new NonQuotedStringAtomContext(_localctx);
enterOuterAlt(_localctx, 2);
{
setState(52);
match(NONQUOTEDSTRING);
}
break;
case STRING:
_localctx = new StringAtomContext(_localctx);
enterOuterAlt(_localctx, 3);
{
setState(53);
match(STRING);
}
break;
default:
throw new NoViableAltException(this);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 1:
return expr_sempred((ExprContext)_localctx, predIndex);
}
return true;
}
private boolean expr_sempred(ExprContext _localctx, int predIndex) {
switch (predIndex) {
case 0:
return precpred(_ctx, 6);
case 1:
return precpred(_ctx, 5);
case 2:
return precpred(_ctx, 4);
case 3:
return precpred(_ctx, 3);
case 4:
return precpred(_ctx, 2);
}
return true;
}
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\23;\4\2\t\2\4\3\t"+
"\3\4\4\t\4\3\2\5\2\n\n\2\3\2\3\2\3\3\3\3\3\3\3\3\5\3\22\n\3\3\3\3\3\3"+
"\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\7\3&\n"+
"\3\f\3\16\3)\13\3\5\3+\n\3\3\3\7\3.\n\3\f\3\16\3\61\13\3\3\4\3\4\3\4\3"+
"\4\3\4\3\4\5\49\n\4\3\4\2\3\4\5\2\4\6\2\4\3\2\3\5\3\2\n\rB\2\t\3\2\2\2"+
"\4\21\3\2\2\2\68\3\2\2\2\b\n\5\4\3\2\t\b\3\2\2\2\t\n\3\2\2\2\n\13\3\2"+
"\2\2\13\f\7\2\2\3\f\3\3\2\2\2\r\16\b\3\1\2\16\17\7\t\2\2\17\22\5\4\3\t"+
"\20\22\5\6\4\2\21\r\3\2\2\2\21\20\3\2\2\2\22/\3\2\2\2\23\24\f\b\2\2\24"+
"\25\t\2\2\2\25.\5\4\3\t\26\27\f\7\2\2\27\30\t\3\2\2\30.\5\4\3\b\31\32"+
"\f\6\2\2\32\33\7\7\2\2\33.\5\4\3\7\34\35\f\5\2\2\35\36\7\6\2\2\36.\5\4"+
"\3\6\37 \f\4\2\2 !\7\b\2\2!*\7\16\2\2\"\'\7\22\2\2#$\7\20\2\2$&\7\22\2"+
"\2%#\3\2\2\2&)\3\2\2\2\'%\3\2\2\2\'(\3\2\2\2(+\3\2\2\2)\'\3\2\2\2*\"\3"+
"\2\2\2*+\3\2\2\2+,\3\2\2\2,.\7\17\2\2-\23\3\2\2\2-\26\3\2\2\2-\31\3\2"+
"\2\2-\34\3\2\2\2-\37\3\2\2\2.\61\3\2\2\2/-\3\2\2\2/\60\3\2\2\2\60\5\3"+
"\2\2\2\61/\3\2\2\2\62\63\7\16\2\2\63\64\5\4\3\2\64\65\7\17\2\2\659\3\2"+
"\2\2\669\7\21\2\2\679\7\22\2\28\62\3\2\2\28\66\3\2\2\28\67\3\2\2\29\7"+
"\3\2\2\2\t\t\21\'*-/8";
public static final ATN _ATN =
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
static {
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
}
}
}