blob: 0c4d5cba52b9349fa8da9778f44f85df2f605a84 [file] [log] [blame]
// Generated from Expr.g4 by ANTLR 4.3
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 ExprParser extends Parser {
static { RuntimeMetaData.checkVersion("4.3", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
new PredictionContextCache();
public static final int
T__5=1, T__4=2, T__3=3, T__2=4, T__1=5, T__0=6, NEWLINE=7, INT=8;
public static final String[] tokenNames = {
"<INVALID>", "'/'", "'('", "')'", "'*'", "'+'", "'-'", "NEWLINE", "INT"
};
public static final int
RULE_prog = 0, RULE_expr = 1;
public static final String[] ruleNames = {
"prog", "expr"
};
@Override
public String getGrammarFileName() { return "Expr.g4"; }
@Override
public String[] getTokenNames() { return tokenNames; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public ExprParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class ProgContext extends ParserRuleContext {
public List<ExprContext> expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public List<TerminalNode> NEWLINE() { return getTokens(ExprParser.NEWLINE); }
public TerminalNode NEWLINE(int i) {
return getToken(ExprParser.NEWLINE, i);
}
public ProgContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_prog; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ExprListener ) ((ExprListener)listener).enterProg(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ExprListener ) ((ExprListener)listener).exitProg(this);
}
}
public final ProgContext prog() throws RecognitionException {
ProgContext _localctx = new ProgContext(_ctx, getState());
enterRule(_localctx, 0, RULE_prog);
int _la;
try {
enterOuterAlt(_localctx, 1);
{
setState(9);
_errHandler.sync(this);
_la = _input.LA(1);
while (_la==T__4 || _la==INT) {
{
{
setState(4); expr(0);
setState(5); match(NEWLINE);
}
}
setState(11);
_errHandler.sync(this);
_la = _input.LA(1);
}
}
}
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 List<ExprContext> expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public TerminalNode INT() { return getToken(ExprParser.INT, 0); }
public ExprContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_expr; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ExprListener ) ((ExprListener)listener).enterExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ExprListener ) ((ExprListener)listener).exitExpr(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(18);
switch (_input.LA(1)) {
case INT:
{
setState(13); match(INT);
}
break;
case T__4:
{
setState(14); match(T__4);
setState(15); expr(0);
setState(16); match(T__3);
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(28);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
if ( _alt==1 ) {
if ( _parseListeners!=null ) triggerExitRuleEvent();
_prevctx = _localctx;
{
setState(26);
switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
case 1:
{
_localctx = new ExprContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(20);
if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
setState(21);
_la = _input.LA(1);
if ( !(_la==T__5 || _la==T__2) ) {
_errHandler.recoverInline(this);
}
consume();
setState(22); expr(5);
}
break;
case 2:
{
_localctx = new ExprContext(_parentctx, _parentState);
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(23);
if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
setState(24);
_la = _input.LA(1);
if ( !(_la==T__1 || _la==T__0) ) {
_errHandler.recoverInline(this);
}
consume();
setState(25); expr(4);
}
break;
}
}
}
setState(30);
_errHandler.sync(this);
_alt = getInterpreter().adaptivePredict(_input,3,_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 1: return expr_sempred((ExprContext)_localctx, predIndex);
}
return true;
}
private boolean expr_sempred(ExprContext _localctx, int predIndex) {
switch (predIndex) {
case 0: return precpred(_ctx, 4);
case 1: return precpred(_ctx, 3);
}
return true;
}
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\n\"\4\2\t\2\4\3\t"+
"\3\3\2\3\2\3\2\7\2\n\n\2\f\2\16\2\r\13\2\3\3\3\3\3\3\3\3\3\3\3\3\5\3\25"+
"\n\3\3\3\3\3\3\3\3\3\3\3\3\3\7\3\35\n\3\f\3\16\3 \13\3\3\3\2\3\4\4\2\4"+
"\2\4\4\2\3\3\6\6\3\2\7\b#\2\13\3\2\2\2\4\24\3\2\2\2\6\7\5\4\3\2\7\b\7"+
"\t\2\2\b\n\3\2\2\2\t\6\3\2\2\2\n\r\3\2\2\2\13\t\3\2\2\2\13\f\3\2\2\2\f"+
"\3\3\2\2\2\r\13\3\2\2\2\16\17\b\3\1\2\17\25\7\n\2\2\20\21\7\4\2\2\21\22"+
"\5\4\3\2\22\23\7\5\2\2\23\25\3\2\2\2\24\16\3\2\2\2\24\20\3\2\2\2\25\36"+
"\3\2\2\2\26\27\f\6\2\2\27\30\t\2\2\2\30\35\5\4\3\7\31\32\f\5\2\2\32\33"+
"\t\3\2\2\33\35\5\4\3\6\34\26\3\2\2\2\34\31\3\2\2\2\35 \3\2\2\2\36\34\3"+
"\2\2\2\36\37\3\2\2\2\37\5\3\2\2\2 \36\3\2\2\2\6\13\24\34\36";
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);
}
}
}