info.scce.addlib.parser.ZDDLanguageParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of addlib Show documentation
Show all versions of addlib Show documentation
The Java Library for Algebraic Decision Diagrams, Code Generation, and Layouting
// Generated from info/scce/addlib/parser/ZDDLanguage.g4 by ANTLR 4.5
package info.scce.addlib.parser;
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 ZDDLanguageParser 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, CHANGE=2, DIFF=3, INTERSECT=4, UNION=5, LPAREN=6, RPAREN=7, TRUE=8,
FALSE=9, NUMBER=10, ID=11, WS=12;
public static final int
RULE_start = 0, RULE_expr = 1, RULE_atom = 2;
public static final String[] ruleNames = {
"start", "expr", "atom"
};
private static final String[] _LITERAL_NAMES = {
null, "'zTrue'", "'CHANGE'", null, null, null, "'('", "')'", "'true'",
"'false'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, null, "CHANGE", "DIFF", "INTERSECT", "UNION", "LPAREN", "RPAREN",
"TRUE", "FALSE", "NUMBER", "ID", "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] = "";
}
}
}
@Override
@Deprecated
public String[] getTokenNames() {
return tokenNames;
}
@Override
public Vocabulary getVocabulary() {
return VOCABULARY;
}
@Override
public String getGrammarFileName() { return "ZDDLanguage.g4"; }
@Override
public String[] getRuleNames() { return ruleNames; }
@Override
public String getSerializedATN() { return _serializedATN; }
@Override
public ATN getATN() { return _ATN; }
public ZDDLanguageParser(TokenStream input) {
super(input);
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
}
public static class StartContext extends ParserRuleContext {
public ExprContext ex;
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public TerminalNode EOF() { return getToken(ZDDLanguageParser.EOF, 0); }
public StartContext(ParserRuleContext parent, int invokingState) {
super(parent, invokingState);
}
@Override public int getRuleIndex() { return RULE_start; }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterStart(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitStart(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitStart(this);
else return visitor.visitChildren(this);
}
}
public final StartContext start() throws RecognitionException {
StartContext _localctx = new StartContext(_ctx, getState());
enterRule(_localctx, 0, RULE_start);
try {
enterOuterAlt(_localctx, 1);
{
setState(6);
((StartContext)_localctx).ex = expr(0);
setState(8);
switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) {
case 1:
{
setState(7);
match(EOF);
}
break;
}
}
}
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 VarExprContext extends ExprContext {
public Token var;
public TerminalNode ID() { return getToken(ZDDLanguageParser.ID, 0); }
public VarExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterVarExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitVarExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitVarExpr(this);
else return visitor.visitChildren(this);
}
}
public static class ChangeExprContext extends ExprContext {
public ExprContext ex;
public Token v;
public TerminalNode CHANGE() { return getToken(ZDDLanguageParser.CHANGE, 0); }
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public TerminalNode NUMBER() { return getToken(ZDDLanguageParser.NUMBER, 0); }
public ChangeExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterChangeExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitChangeExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitChangeExpr(this);
else return visitor.visitChildren(this);
}
}
public static class NotExprContext extends ExprContext {
public ExprContext left;
public ExprContext right;
public TerminalNode DIFF() { return getToken(ZDDLanguageParser.DIFF, 0); }
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public NotExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterNotExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitNotExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitNotExpr(this);
else return visitor.visitChildren(this);
}
}
public static class AtomExprContext extends ExprContext {
public AtomContext ap;
public AtomContext atom() {
return getRuleContext(AtomContext.class,0);
}
public AtomExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterAtomExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitAtomExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitAtomExpr(this);
else return visitor.visitChildren(this);
}
}
public static class OrExprContext extends ExprContext {
public ExprContext left;
public ExprContext right;
public TerminalNode UNION() { return getToken(ZDDLanguageParser.UNION, 0); }
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public OrExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterOrExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitOrExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitOrExpr(this);
else return visitor.visitChildren(this);
}
}
public static class ParenExprContext extends ExprContext {
public ExprContext ex;
public TerminalNode LPAREN() { return getToken(ZDDLanguageParser.LPAREN, 0); }
public TerminalNode RPAREN() { return getToken(ZDDLanguageParser.RPAREN, 0); }
public ExprContext expr() {
return getRuleContext(ExprContext.class,0);
}
public ParenExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterParenExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitParenExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitParenExpr(this);
else return visitor.visitChildren(this);
}
}
public static class AndExprContext extends ExprContext {
public ExprContext left;
public ExprContext right;
public TerminalNode INTERSECT() { return getToken(ZDDLanguageParser.INTERSECT, 0); }
public List expr() {
return getRuleContexts(ExprContext.class);
}
public ExprContext expr(int i) {
return getRuleContext(ExprContext.class,i);
}
public AndExprContext(ExprContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterAndExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitAndExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor 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);
try {
int _alt;
enterOuterAlt(_localctx, 1);
{
setState(21);
switch (_input.LA(1)) {
case LPAREN:
{
_localctx = new ParenExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(11);
match(LPAREN);
setState(12);
((ParenExprContext)_localctx).ex = expr(0);
setState(13);
match(RPAREN);
}
break;
case CHANGE:
{
_localctx = new ChangeExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(15);
match(CHANGE);
setState(16);
((ChangeExprContext)_localctx).ex = expr(0);
setState(17);
((ChangeExprContext)_localctx).v = match(NUMBER);
}
break;
case ID:
{
_localctx = new VarExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(19);
((VarExprContext)_localctx).var = match(ID);
}
break;
case T__0:
case TRUE:
case FALSE:
{
_localctx = new AtomExprContext(_localctx);
_ctx = _localctx;
_prevctx = _localctx;
setState(20);
((AtomExprContext)_localctx).ap = atom();
}
break;
default:
throw new NoViableAltException(this);
}
_ctx.stop = _input.LT(-1);
setState(34);
_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(32);
switch ( getInterpreter().adaptivePredict(_input,2,_ctx) ) {
case 1:
{
_localctx = new NotExprContext(new ExprContext(_parentctx, _parentState));
((NotExprContext)_localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(23);
if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)");
setState(24);
match(DIFF);
setState(25);
((NotExprContext)_localctx).right = expr(6);
}
break;
case 2:
{
_localctx = new AndExprContext(new ExprContext(_parentctx, _parentState));
((AndExprContext)_localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(26);
if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)");
setState(27);
match(INTERSECT);
setState(28);
((AndExprContext)_localctx).right = expr(5);
}
break;
case 3:
{
_localctx = new OrExprContext(new ExprContext(_parentctx, _parentState));
((OrExprContext)_localctx).left = _prevctx;
pushNewRecursionContext(_localctx, _startState, RULE_expr);
setState(29);
if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
setState(30);
match(UNION);
setState(31);
((OrExprContext)_localctx).right = expr(4);
}
break;
}
}
}
setState(36);
_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 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 ZddOneExprContext extends AtomContext {
public Token i;
public TerminalNode NUMBER() { return getToken(ZDDLanguageParser.NUMBER, 0); }
public ZddOneExprContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterZddOneExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitZddOneExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitZddOneExpr(this);
else return visitor.visitChildren(this);
}
}
public static class TrueExprContext extends AtomContext {
public TerminalNode TRUE() { return getToken(ZDDLanguageParser.TRUE, 0); }
public TrueExprContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterTrueExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitTrueExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitTrueExpr(this);
else return visitor.visitChildren(this);
}
}
public static class FalseExprContext extends AtomContext {
public TerminalNode FALSE() { return getToken(ZDDLanguageParser.FALSE, 0); }
public FalseExprContext(AtomContext ctx) { copyFrom(ctx); }
@Override
public void enterRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).enterFalseExpr(this);
}
@Override
public void exitRule(ParseTreeListener listener) {
if ( listener instanceof ZDDLanguageListener ) ((ZDDLanguageListener)listener).exitFalseExpr(this);
}
@Override
public T accept(ParseTreeVisitor extends T> visitor) {
if ( visitor instanceof ZDDLanguageVisitor ) return ((ZDDLanguageVisitor extends T>)visitor).visitFalseExpr(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(41);
switch (_input.LA(1)) {
case TRUE:
_localctx = new TrueExprContext(_localctx);
enterOuterAlt(_localctx, 1);
{
setState(37);
match(TRUE);
}
break;
case T__0:
_localctx = new ZddOneExprContext(_localctx);
enterOuterAlt(_localctx, 2);
{
setState(38);
match(T__0);
setState(39);
((ZddOneExprContext)_localctx).i = match(NUMBER);
}
break;
case FALSE:
_localctx = new FalseExprContext(_localctx);
enterOuterAlt(_localctx, 3);
{
setState(40);
match(FALSE);
}
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, 5);
case 1:
return precpred(_ctx, 4);
case 2:
return precpred(_ctx, 3);
}
return true;
}
public static final String _serializedATN =
"\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3\16.\4\2\t\2\4\3\t"+
"\3\4\4\t\4\3\2\3\2\5\2\13\n\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3\3"+
"\3\3\5\3\30\n\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\3\4\3\4\3\4\3\4\5\4,\n\4\3\4\2\3\4\5\2\4\6\2\2\63\2\b\3\2\2\2\4"+
"\27\3\2\2\2\6+\3\2\2\2\b\n\5\4\3\2\t\13\7\2\2\3\n\t\3\2\2\2\n\13\3\2\2"+
"\2\13\3\3\2\2\2\f\r\b\3\1\2\r\16\7\b\2\2\16\17\5\4\3\2\17\20\7\t\2\2\20"+
"\30\3\2\2\2\21\22\7\4\2\2\22\23\5\4\3\2\23\24\7\f\2\2\24\30\3\2\2\2\25"+
"\30\7\r\2\2\26\30\5\6\4\2\27\f\3\2\2\2\27\21\3\2\2\2\27\25\3\2\2\2\27"+
"\26\3\2\2\2\30$\3\2\2\2\31\32\f\7\2\2\32\33\7\5\2\2\33#\5\4\3\b\34\35"+
"\f\6\2\2\35\36\7\6\2\2\36#\5\4\3\7\37 \f\5\2\2 !\7\7\2\2!#\5\4\3\6\"\31"+
"\3\2\2\2\"\34\3\2\2\2\"\37\3\2\2\2#&\3\2\2\2$\"\3\2\2\2$%\3\2\2\2%\5\3"+
"\2\2\2&$\3\2\2\2\',\7\n\2\2()\7\3\2\2),\7\f\2\2*,\7\13\2\2+\'\3\2\2\2"+
"+(\3\2\2\2+*\3\2\2\2,\7\3\2\2\2\7\n\27\"$+";
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);
}
}
}