EvaluatorParser.java

// Generated from /home/gsinai/git/microspace/src/main/resources/Evaluator.g4 by ANTLR 4.7
package org.microspace.evaluator;
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 EvaluatorParser extends Parser {
	static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }

	protected static final DFA[] _decisionToDFA;
	protected static final PredictionContextCache _sharedContextCache =
		new PredictionContextCache();
	public static final int
		WHITE_SPACE=1, RPAREN=2, LPAREN=3, TIMES=4, SLASH=5, PLUS=6, MINUS=7, 
		DOT=8, TIMES_SLASH=9, PLUS_MINUS=10, INTEGER_NUM=11, REAL_NUMBER=12, VARIABLE=13;
	public static final int
		RULE_number_literal = 0, RULE_times_slash = 1, RULE_plus_minus = 2, RULE_expression = 3, 
		RULE_expression_plus_minus = 4, RULE_expression_times_slash = 5, RULE_expression_atom = 6, 
		RULE_expression_list = 7;
	public static final String[] ruleNames = {
		"number_literal", "times_slash", "plus_minus", "expression", "expression_plus_minus", 
		"expression_times_slash", "expression_atom", "expression_list"
	};

	private static final String[] _LITERAL_NAMES = {
		null, null, "')'", "'('", "'*'", "'/'", "'+'", "'-'", "'.'"
	};
	private static final String[] _SYMBOLIC_NAMES = {
		null, "WHITE_SPACE", "RPAREN", "LPAREN", "TIMES", "SLASH", "PLUS", "MINUS", 
		"DOT", "TIMES_SLASH", "PLUS_MINUS", "INTEGER_NUM", "REAL_NUMBER", "VARIABLE"
	};
	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

	public Vocabulary getVocabulary() {
		return VOCABULARY;
	}

	@Override
	public String getGrammarFileName() { return "Evaluator.g4"; }

	@Override
	public String[] getRuleNames() { return ruleNames; }

	@Override
	public String getSerializedATN() { return _serializedATN; }

	@Override
	public ATN getATN() { return _ATN; }

	  
	  @Override
	  public void notifyErrorListeners(Token offendingToken, String msg, RecognitionException ex)
	  {
	    throw new IllegalArgumentException(msg); 
	  }

	public EvaluatorParser(TokenStream input) {
		super(input);
		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
	}
	public static class Number_literalContext extends ParserRuleContext {
		public TerminalNode INTEGER_NUM() { return getToken(EvaluatorParser.INTEGER_NUM, 0); }
		public TerminalNode REAL_NUMBER() { return getToken(EvaluatorParser.REAL_NUMBER, 0); }
		public TerminalNode PLUS() { return getToken(EvaluatorParser.PLUS, 0); }
		public TerminalNode MINUS() { return getToken(EvaluatorParser.MINUS, 0); }
		public Number_literalContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_number_literal; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterNumber_literal(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitNumber_literal(this);
		}
	}

	public final Number_literalContext number_literal() throws RecognitionException {
		Number_literalContext _localctx = new Number_literalContext(_ctx, getState());
		enterRule(_localctx, 0, RULE_number_literal);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(17);
			_errHandler.sync(this);
			_la = _input.LA(1);
			if (_la==PLUS || _la==MINUS) {
				{
				setState(16);
				_la = _input.LA(1);
				if ( !(_la==PLUS || _la==MINUS) ) {
				_errHandler.recoverInline(this);
				}
				else {
					if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
					_errHandler.reportMatch(this);
					consume();
				}
				}
			}

			setState(19);
			_la = _input.LA(1);
			if ( !(_la==INTEGER_NUM || _la==REAL_NUMBER) ) {
			_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;
	}

	public static class Times_slashContext extends ParserRuleContext {
		public TerminalNode TIMES() { return getToken(EvaluatorParser.TIMES, 0); }
		public TerminalNode SLASH() { return getToken(EvaluatorParser.SLASH, 0); }
		public Times_slashContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_times_slash; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterTimes_slash(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitTimes_slash(this);
		}
	}

	public final Times_slashContext times_slash() throws RecognitionException {
		Times_slashContext _localctx = new Times_slashContext(_ctx, getState());
		enterRule(_localctx, 2, RULE_times_slash);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(21);
			_la = _input.LA(1);
			if ( !(_la==TIMES || _la==SLASH) ) {
			_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;
	}

	public static class Plus_minusContext extends ParserRuleContext {
		public TerminalNode PLUS() { return getToken(EvaluatorParser.PLUS, 0); }
		public TerminalNode MINUS() { return getToken(EvaluatorParser.MINUS, 0); }
		public Plus_minusContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_plus_minus; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterPlus_minus(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitPlus_minus(this);
		}
	}

	public final Plus_minusContext plus_minus() throws RecognitionException {
		Plus_minusContext _localctx = new Plus_minusContext(_ctx, getState());
		enterRule(_localctx, 4, RULE_plus_minus);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(23);
			_la = _input.LA(1);
			if ( !(_la==PLUS || _la==MINUS) ) {
			_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;
	}

	public static class ExpressionContext extends ParserRuleContext {
		public Expression_plus_minusContext expression_plus_minus() {
			return getRuleContext(Expression_plus_minusContext.class,0);
		}
		public TerminalNode EOF() { return getToken(EvaluatorParser.EOF, 0); }
		public ExpressionContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expression; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterExpression(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitExpression(this);
		}
	}

	public final ExpressionContext expression() throws RecognitionException {
		ExpressionContext _localctx = new ExpressionContext(_ctx, getState());
		enterRule(_localctx, 6, RULE_expression);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(25);
			expression_plus_minus();
			setState(26);
			match(EOF);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static class Expression_plus_minusContext extends ParserRuleContext {
		public List<Expression_times_slashContext> expression_times_slash() {
			return getRuleContexts(Expression_times_slashContext.class);
		}
		public Expression_times_slashContext expression_times_slash(int i) {
			return getRuleContext(Expression_times_slashContext.class,i);
		}
		public List<Plus_minusContext> plus_minus() {
			return getRuleContexts(Plus_minusContext.class);
		}
		public Plus_minusContext plus_minus(int i) {
			return getRuleContext(Plus_minusContext.class,i);
		}
		public Expression_plus_minusContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expression_plus_minus; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterExpression_plus_minus(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitExpression_plus_minus(this);
		}
	}

	public final Expression_plus_minusContext expression_plus_minus() throws RecognitionException {
		Expression_plus_minusContext _localctx = new Expression_plus_minusContext(_ctx, getState());
		enterRule(_localctx, 8, RULE_expression_plus_minus);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(28);
			expression_times_slash();
			setState(34);
			_errHandler.sync(this);
			_la = _input.LA(1);
			while (_la==PLUS || _la==MINUS) {
				{
				{
				setState(29);
				plus_minus();
				setState(30);
				expression_times_slash();
				}
				}
				setState(36);
				_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 Expression_times_slashContext extends ParserRuleContext {
		public List<Expression_atomContext> expression_atom() {
			return getRuleContexts(Expression_atomContext.class);
		}
		public Expression_atomContext expression_atom(int i) {
			return getRuleContext(Expression_atomContext.class,i);
		}
		public List<Times_slashContext> times_slash() {
			return getRuleContexts(Times_slashContext.class);
		}
		public Times_slashContext times_slash(int i) {
			return getRuleContext(Times_slashContext.class,i);
		}
		public Expression_times_slashContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expression_times_slash; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterExpression_times_slash(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitExpression_times_slash(this);
		}
	}

	public final Expression_times_slashContext expression_times_slash() throws RecognitionException {
		Expression_times_slashContext _localctx = new Expression_times_slashContext(_ctx, getState());
		enterRule(_localctx, 10, RULE_expression_times_slash);
		int _la;
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(37);
			expression_atom();
			setState(43);
			_errHandler.sync(this);
			_la = _input.LA(1);
			while (_la==TIMES || _la==SLASH) {
				{
				{
				setState(38);
				times_slash();
				setState(39);
				expression_atom();
				}
				}
				setState(45);
				_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 Expression_atomContext extends ParserRuleContext {
		public Expression_listContext expression_list() {
			return getRuleContext(Expression_listContext.class,0);
		}
		public TerminalNode VARIABLE() { return getToken(EvaluatorParser.VARIABLE, 0); }
		public Number_literalContext number_literal() {
			return getRuleContext(Number_literalContext.class,0);
		}
		public Expression_atomContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expression_atom; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterExpression_atom(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitExpression_atom(this);
		}
	}

	public final Expression_atomContext expression_atom() throws RecognitionException {
		Expression_atomContext _localctx = new Expression_atomContext(_ctx, getState());
		enterRule(_localctx, 12, RULE_expression_atom);
		try {
			setState(49);
			_errHandler.sync(this);
			switch (_input.LA(1)) {
			case LPAREN:
				enterOuterAlt(_localctx, 1);
				{
				setState(46);
				expression_list();
				}
				break;
			case VARIABLE:
				enterOuterAlt(_localctx, 2);
				{
				setState(47);
				match(VARIABLE);
				}
				break;
			case PLUS:
			case MINUS:
			case INTEGER_NUM:
			case REAL_NUMBER:
				enterOuterAlt(_localctx, 3);
				{
				setState(48);
				number_literal();
				}
				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 Expression_listContext extends ParserRuleContext {
		public TerminalNode LPAREN() { return getToken(EvaluatorParser.LPAREN, 0); }
		public Expression_plus_minusContext expression_plus_minus() {
			return getRuleContext(Expression_plus_minusContext.class,0);
		}
		public TerminalNode RPAREN() { return getToken(EvaluatorParser.RPAREN, 0); }
		public Expression_listContext(ParserRuleContext parent, int invokingState) {
			super(parent, invokingState);
		}
		@Override public int getRuleIndex() { return RULE_expression_list; }
		@Override
		public void enterRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).enterExpression_list(this);
		}
		@Override
		public void exitRule(ParseTreeListener listener) {
			if ( listener instanceof EvaluatorListener ) ((EvaluatorListener)listener).exitExpression_list(this);
		}
	}

	public final Expression_listContext expression_list() throws RecognitionException {
		Expression_listContext _localctx = new Expression_listContext(_ctx, getState());
		enterRule(_localctx, 14, RULE_expression_list);
		try {
			enterOuterAlt(_localctx, 1);
			{
			setState(51);
			match(LPAREN);
			setState(52);
			expression_plus_minus();
			setState(53);
			match(RPAREN);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			_errHandler.reportError(this, re);
			_errHandler.recover(this, re);
		}
		finally {
			exitRule();
		}
		return _localctx;
	}

	public static final String _serializedATN =
		"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3\17:\4\2\t\2\4\3\t"+
		"\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\3\2\5\2\24\n\2\3\2"+
		"\3\2\3\3\3\3\3\4\3\4\3\5\3\5\3\5\3\6\3\6\3\6\3\6\7\6#\n\6\f\6\16\6&\13"+
		"\6\3\7\3\7\3\7\3\7\7\7,\n\7\f\7\16\7/\13\7\3\b\3\b\3\b\5\b\64\n\b\3\t"+
		"\3\t\3\t\3\t\3\t\2\2\n\2\4\6\b\n\f\16\20\2\5\3\2\b\t\3\2\r\16\3\2\6\7"+
		"\2\66\2\23\3\2\2\2\4\27\3\2\2\2\6\31\3\2\2\2\b\33\3\2\2\2\n\36\3\2\2\2"+
		"\f\'\3\2\2\2\16\63\3\2\2\2\20\65\3\2\2\2\22\24\t\2\2\2\23\22\3\2\2\2\23"+
		"\24\3\2\2\2\24\25\3\2\2\2\25\26\t\3\2\2\26\3\3\2\2\2\27\30\t\4\2\2\30"+
		"\5\3\2\2\2\31\32\t\2\2\2\32\7\3\2\2\2\33\34\5\n\6\2\34\35\7\2\2\3\35\t"+
		"\3\2\2\2\36$\5\f\7\2\37 \5\6\4\2 !\5\f\7\2!#\3\2\2\2\"\37\3\2\2\2#&\3"+
		"\2\2\2$\"\3\2\2\2$%\3\2\2\2%\13\3\2\2\2&$\3\2\2\2\'-\5\16\b\2()\5\4\3"+
		"\2)*\5\16\b\2*,\3\2\2\2+(\3\2\2\2,/\3\2\2\2-+\3\2\2\2-.\3\2\2\2.\r\3\2"+
		"\2\2/-\3\2\2\2\60\64\5\20\t\2\61\64\7\17\2\2\62\64\5\2\2\2\63\60\3\2\2"+
		"\2\63\61\3\2\2\2\63\62\3\2\2\2\64\17\3\2\2\2\65\66\7\5\2\2\66\67\5\n\6"+
		"\2\678\7\4\2\28\21\3\2\2\2\6\23$-\63";
	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);
		}
	}
}