// Generated from /Users/bore/Projects/SoftwareConstruction/many-ql/bg-nv/ql/src/ql/syntax/QL.g4 by ANTLR 4.5
package ql.gen;
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 QLParser extends Parser {
static { RuntimeMetaData.checkVersion("4.5", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
T__17=18, T__18=19, QuestionType=20, Boolean=21, Identifier=22, Integer=23,
Decimal=24, String=25, Comment=26, LineComment=27, WS=28;
public static final int
RULE_form = 0, RULE_statement = 1, RULE_question = 2, RULE_ifCondition = 3,
RULE_expression = 4;
public static final String[] ruleNames = {
"form", "statement", "question", "ifCondition", "expression"
};
private static final String[] _LITERAL_NAMES = {
null, "'form'", "'{'", "'}'", "'if'", "'('", "')'", "'-'", "'+'", "'!'",
"'*'", "'/'", "'<'", "'>'", "'<='", "'>='", "'=='", "'!='", "'&&'", "'||'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, "QuestionType", "Boolean",
"Identifier", "Integer", "Decimal", "String", "Comment", "LineComment",
"WS"
};
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] = "<INVALID>";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
@NotNull
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "QL.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public QLParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class FormContext extends ParserRuleContext {
public TerminalNode Identifier() { return getToken(QLParser.Identifier, 0); }
public List<StatementContext> statement() {
return getRuleContexts(StatementContext.class);
}
public StatementContext statement(int i) {
return getRuleContext(StatementContext.class,i);
}
public FormContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_form; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof QLVisitor ) return ((QLVisitor<? extends T>)visitor).visitForm(this);
else return visitor.visitChildren(this);
}
}
public final FormContext form() throws RecognitionException {
FormContext _localctx = new FormContext(_ctx, getState());
enterRule(_localctx, 0, RULE_form);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(10);
match(T__0);
setState(11);
match(Identifier);
setState(12);
match(T__1);
setState(14);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(13);
statement();
}
}
setState(16);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==T__3 || _la==QuestionType );
setState(18);
match(T__2);
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class StatementContext extends ParserRuleContext {
public QuestionContext question() {
return getRuleContext(QuestionContext.class,0);
}
public IfConditionContext ifCondition() {
return getRuleContext(IfConditionContext.class,0);
}
public StatementContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_statement; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof QLVisitor ) return ((QLVisitor<? extends T>)visitor).visitStatement(this);
else return visitor.visitChildren(this);
}
}
public final StatementContext statement() throws RecognitionException {
StatementContext _localctx = new StatementContext(_ctx, getState());
enterRule(_localctx, 2, RULE_statement);
try {
setState(22);
switch (_input.LA(1)) {
case QuestionType:
enterOuterAlt(_localctx, 1);
{
setState(20);
question();
}
break;
case T__3:
enterOuterAlt(_localctx, 2);
{
setState(21);
ifCondition();
}
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 static class QuestionContext extends ParserRuleContext {
public TerminalNode QuestionType() { return getToken(QLParser.QuestionType, 0); }
public TerminalNode Identifier() { return getToken(QLParser.Identifier, 0); }
public TerminalNode String() { return getToken(QLParser.String, 0); }
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public QuestionContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_question; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof QLVisitor ) return ((QLVisitor<? extends T>)visitor).visitQuestion(this);
else return visitor.visitChildren(this);
}
}
public final QuestionContext question() throws RecognitionException {
QuestionContext _localctx = new QuestionContext(_ctx, getState());
enterRule(_localctx, 4, RULE_question);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(24);
match(QuestionType);
setState(25);
match(Identifier);
setState(26);
match(String);
setState(28);
_la = _input.LA(1);
if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__4) | (1L << T__6) | (1L << T__7) | (1L << T__8) | (1L << Boolean) | (1L << Identifier) | (1L << Integer) | (1L << Decimal) | (1L << String))) != 0)) {
{
setState(27);
expression(0);
}
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class IfConditionContext extends ParserRuleContext {
public ExpressionContext expression() {
return getRuleContext(ExpressionContext.class,0);
}
public List<StatementContext> statement() {
return getRuleContexts(StatementContext.class);
}
public StatementContext statement(int i) {
return getRuleContext(StatementContext.class,i);
}
public IfConditionContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_ifCondition; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof QLVisitor ) return ((QLVisitor<? extends T>)visitor).visitIfCondition(this);
else return visitor.visitChildren(this);
}
}
public final IfConditionContext ifCondition() throws RecognitionException {
IfConditionContext _localctx = new IfConditionContext(_ctx, getState());
enterRule(_localctx, 6, RULE_ifCondition);
int _la;
try {
setState(48);
switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) {
case 1:
enterOuterAlt(_localctx, 1);
{
setState(30);
match(T__3);
setState(31);
match(T__4);
setState(32);
expression(0);
setState(33);
match(T__5);
setState(34);
match(T__1);
setState(36);
_errHandler.sync(this);
_la = _input.LA(1);
do {
{
{
setState(35);
statement();
}
}
setState(38);
_errHandler.sync(this);
_la = _input.LA(1);
} while ( _la==T__3 || _la==QuestionType );
setState(40);
match(T__2);
}
break;
case 2:
enterOuterAlt(_localctx, 2);
{
setState(42);
match(T__3);
setState(43);
match(T__4);
setState(44);
expression(0);
setState(45);
match(T__5);
setState(46);
statement();
}
break;
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
exitRule();
}
return _localctx;
}
public static class ExpressionContext extends ParserRuleContext {
public ExpressionContext left;
public Token operator;
public ExpressionContext operand;
public ExpressionContext parenthesis;
public Token primary;
public ExpressionContext right;
public List<ExpressionContext> expression() {
return getRuleContexts(ExpressionContext.class);
}
public ExpressionContext expression(int i) {
return getRuleContext(ExpressionContext.class,i);
}
public TerminalNode Boolean() { return getToken(QLParser.Boolean, 0); }
public TerminalNode Decimal() { return getToken(QLParser.Decimal, 0); }
public TerminalNode String() { return getToken(QLParser.String, 0); }
public TerminalNode Identifier() { return getToken(QLParser.Identifier, 0); }
public TerminalNode Integer() { return getToken(QLParser.Integer, 0); }
public ExpressionContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_expression; }
@Override
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
if ( visitor instanceof QLVisitor ) return ((QLVisitor<? extends T>)visitor).visitExpression(this);
else return visitor.visitChildren(this);
}
}
public final ExpressionContext expression() throws RecognitionException {
return expression(0);
}
private ExpressionContext expression(int _p) throws RecognitionException {
ParserRuleContext _parentctx = _ctx;
int _parentState = getState();
ExpressionContext _localctx = new ExpressionContext(_ctx, _parentState);
ExpressionContext _prevctx = _localctx;
int _startState = 8;
enterRecursionRule(_localctx, 8, RULE_expression, _p);
int _la;
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(62);
switch (_input.LA(1)) {
case T__6:
case T__7:
case T__8:
{
setState(51);
((ExpressionContext)_localctx).operator = _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__6) | (1L << T__7) | (1L << T__8))) != 0)) ) {
((ExpressionContext)_localctx).operator = (Token)_errHandler.recoverInline(this);
}
consume();
setState(52);
((ExpressionContext)_localctx).operand = expression(10);
}
break;
case T__4:
{
setState(53);
match(T__4);
setState(54);
((ExpressionContext)_localctx).parenthesis = expression(0);
setState(55);
match(T__5);
}
break;
case Boolean:
{
setState(57);
((ExpressionContext)_localctx).primary = match(Boolean);
}
break;
case Decimal:
{
setState(58);
((ExpressionContext)_localctx).primary = match(Decimal);
}
break;
case String:
{
setState(59);
((ExpressionContext)_localctx).primary = match(String);
}
break;
case Identifier:
{
setState(60);
((ExpressionContext)_localctx).primary = match(Identifier);
}
break;
case Integer:
{
setState(61);
((ExpressionContext)_localctx).primary = match(Integer);
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(78);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,7,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( _parseListeners!=null ) triggerExitRuleEvent();
_prevctx = _localctx;
{
setState(76);
switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) {
case 1:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
_localctx.left = _prevctx;
_localctx.left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(64);
if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)");
setState(65);
((ExpressionContext)_localctx).operator = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==T__9 || _la==T__10) ) {
((ExpressionContext)_localctx).operator = (Token)_errHandler.recoverInline(this);
}
consume();
setState(66);
((ExpressionContext)_localctx).right = expression(10);
}
break;
case 2:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
_localctx.left = _prevctx;
_localctx.left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(67);
if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)");
setState(68);
((ExpressionContext)_localctx).operator = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==T__6 || _la==T__7) ) {
((ExpressionContext)_localctx).operator = (Token)_errHandler.recoverInline(this);
}
consume();
setState(69);
((ExpressionContext)_localctx).right = expression(9);
}
break;
case 3:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
_localctx.left = _prevctx;
_localctx.left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(70);
if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)");
setState(71);
((ExpressionContext)_localctx).operator = _input.LT(1);
_la = _input.LA(1);
if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__11) | (1L << T__12) | (1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16))) != 0)) ) {
((ExpressionContext)_localctx).operator = (Token)_errHandler.recoverInline(this);
}
consume();
setState(72);
((ExpressionContext)_localctx).right = expression(8);
}
break;
case 4:
{
_localctx = new ExpressionContext(_parentctx, _parentState);
_localctx.left = _prevctx;
_localctx.left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expression);
setState(73);
if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)");
setState(74);
((ExpressionContext)_localctx).operator = _input.LT(1);
_la = _input.LA(1);
if ( !(_la==T__17 || _la==T__18) ) {
((ExpressionContext)_localctx).operator = (Token)_errHandler.recoverInline(this);
}
consume();
setState(75);
((ExpressionContext)_localctx).right = expression(7);
}
break;
}
}
}
setState(80);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,7,_ctx);
}
}
}
catch (RecognitionException re) {
_localctx.exception = re;
_errHandler.reportError(this, re);
_errHandler.recover(this, re);
}
finally {
unrollRecursionContexts(_parentctx);
}
return _localctx;
}
public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
switch (ruleIndex) {
case 4:
return expression_sempred((ExpressionContext)_localctx, predIndex);
}
return true;
}
private boolean expression_sempred(ExpressionContext _localctx, int predIndex) {
switch (predIndex) {
case 0:
return precpred(_ctx, 9);
case 1:
return precpred(_ctx, 8);
case 2:
return precpred(_ctx, 7);
case 3:
return precpred(_ctx, 6);
}
return true;
}
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\36T\4\2\t\2\4\3\t"+
"\3\4\4\t\4\4\5\t\5\4\6\t\6\3\2\3\2\3\2\3\2\6\2\21\n\2\r\2\16\2\22\3\2"+
"\3\2\3\3\3\3\5\3\31\n\3\3\4\3\4\3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>A\7\30\2\2?A\7\31\2\2@\64\3\2\2\2"+
"@\67\3\2\2\2@;\3\2\2\2@<\3\2\2\2@=\3\2\2\2@>\3\2\2\2@?\3\2\2\2AP\3\2\2"+
"\2BC\f\13\2\2CD\t\3\2\2DO\5\n\6\fEF\f\n\2\2FG\t\4\2\2GO\5\n\6\13HI\f\t"+
"\2\2IJ\t\5\2\2JO\5\n\6\nKL\f\b\2\2LM\t\6\2\2MO\5\n\6\tNB\3\2\2\2NE\3\2"+
"\2\2NH\3\2\2\2NK\3\2\2\2OR\3\2\2\2PN\3\2\2\2PQ\3\2\2\2Q\13\3\2\2\2RP\3"+
"\2\2\2\n\22\30\36(\62@NP";
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);
}
}
}