807 lines
26 KiB
Python
807 lines
26 KiB
Python
|
# Generated from HMKNF.g4 by ANTLR 4.10.1
|
||
|
# encoding: utf-8
|
||
|
from antlr4 import *
|
||
|
from io import StringIO
|
||
|
import sys
|
||
|
if sys.version_info[1] > 5:
|
||
|
from typing import TextIO
|
||
|
else:
|
||
|
from typing.io import TextIO
|
||
|
|
||
|
def serializedATN():
|
||
|
return [
|
||
|
4,1,13,91,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,
|
||
|
6,2,7,7,7,2,8,7,8,2,9,7,9,1,0,1,0,5,0,23,8,0,10,0,12,0,26,9,0,1,
|
||
|
1,1,1,1,1,1,1,1,1,3,1,33,8,1,1,1,1,1,1,2,1,2,1,2,5,2,40,8,2,10,2,
|
||
|
12,2,43,9,2,1,3,1,3,1,3,1,3,5,3,49,8,3,10,3,12,3,52,9,3,3,3,54,8,
|
||
|
3,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,3,5,67,8,5,1,5,1,5,
|
||
|
1,5,1,5,1,5,1,5,5,5,75,8,5,10,5,12,5,78,9,5,1,6,1,6,3,6,82,8,6,1,
|
||
|
7,1,7,1,8,1,8,1,9,1,9,1,9,1,9,0,1,10,10,0,2,4,6,8,10,12,14,16,18,
|
||
|
0,1,1,0,7,8,92,0,24,1,0,0,0,2,32,1,0,0,0,4,36,1,0,0,0,6,44,1,0,0,
|
||
|
0,8,55,1,0,0,0,10,66,1,0,0,0,12,81,1,0,0,0,14,83,1,0,0,0,16,85,1,
|
||
|
0,0,0,18,87,1,0,0,0,20,23,3,2,1,0,21,23,3,8,4,0,22,20,1,0,0,0,22,
|
||
|
21,1,0,0,0,23,26,1,0,0,0,24,22,1,0,0,0,24,25,1,0,0,0,25,1,1,0,0,
|
||
|
0,26,24,1,0,0,0,27,28,3,4,2,0,28,29,3,6,3,0,29,33,1,0,0,0,30,33,
|
||
|
3,4,2,0,31,33,3,6,3,0,32,27,1,0,0,0,32,30,1,0,0,0,32,31,1,0,0,0,
|
||
|
33,34,1,0,0,0,34,35,5,1,0,0,35,3,1,0,0,0,36,41,5,13,0,0,37,38,5,
|
||
|
2,0,0,38,40,5,13,0,0,39,37,1,0,0,0,40,43,1,0,0,0,41,39,1,0,0,0,41,
|
||
|
42,1,0,0,0,42,5,1,0,0,0,43,41,1,0,0,0,44,53,5,3,0,0,45,50,3,12,6,
|
||
|
0,46,47,5,2,0,0,47,49,3,12,6,0,48,46,1,0,0,0,49,52,1,0,0,0,50,48,
|
||
|
1,0,0,0,50,51,1,0,0,0,51,54,1,0,0,0,52,50,1,0,0,0,53,45,1,0,0,0,
|
||
|
53,54,1,0,0,0,54,7,1,0,0,0,55,56,3,10,5,0,56,57,5,1,0,0,57,9,1,0,
|
||
|
0,0,58,59,6,5,-1,0,59,60,5,4,0,0,60,61,3,10,5,0,61,62,5,5,0,0,62,
|
||
|
67,1,0,0,0,63,67,3,14,7,0,64,65,5,6,0,0,65,67,3,10,5,3,66,58,1,0,
|
||
|
0,0,66,63,1,0,0,0,66,64,1,0,0,0,67,76,1,0,0,0,68,69,10,2,0,0,69,
|
||
|
70,7,0,0,0,70,75,3,10,5,3,71,72,10,1,0,0,72,73,5,9,0,0,73,75,3,10,
|
||
|
5,1,74,68,1,0,0,0,74,71,1,0,0,0,75,78,1,0,0,0,76,74,1,0,0,0,76,77,
|
||
|
1,0,0,0,77,11,1,0,0,0,78,76,1,0,0,0,79,82,3,16,8,0,80,82,3,18,9,
|
||
|
0,81,79,1,0,0,0,81,80,1,0,0,0,82,13,1,0,0,0,83,84,5,13,0,0,84,15,
|
||
|
1,0,0,0,85,86,5,13,0,0,86,17,1,0,0,0,87,88,5,10,0,0,88,89,5,13,0,
|
||
|
0,89,19,1,0,0,0,10,22,24,32,41,50,53,66,74,76,81
|
||
|
]
|
||
|
|
||
|
class HMKNFParser ( Parser ):
|
||
|
|
||
|
grammarFileName = "HMKNF.g4"
|
||
|
|
||
|
atn = ATNDeserializer().deserialize(serializedATN())
|
||
|
|
||
|
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
|
||
|
|
||
|
sharedContextCache = PredictionContextCache()
|
||
|
|
||
|
literalNames = [ "<INVALID>", "'.'", "','", "':-'", "'('", "')'", "'-'",
|
||
|
"'|'", "'&'", "'->'", "'not'" ]
|
||
|
|
||
|
symbolicNames = [ "<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||
|
"<INVALID>", "<INVALID>", "<INVALID>", "<INVALID>",
|
||
|
"<INVALID>", "<INVALID>", "<INVALID>", "COMMENT",
|
||
|
"WS", "IDENTIFIER" ]
|
||
|
|
||
|
RULE_kb = 0
|
||
|
RULE_lrule = 1
|
||
|
RULE_head = 2
|
||
|
RULE_body = 3
|
||
|
RULE_orule = 4
|
||
|
RULE_oformula = 5
|
||
|
RULE_katom = 6
|
||
|
RULE_oatom = 7
|
||
|
RULE_patom = 8
|
||
|
RULE_natom = 9
|
||
|
|
||
|
ruleNames = [ "kb", "lrule", "head", "body", "orule", "oformula", "katom",
|
||
|
"oatom", "patom", "natom" ]
|
||
|
|
||
|
EOF = Token.EOF
|
||
|
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
|
||
|
COMMENT=11
|
||
|
WS=12
|
||
|
IDENTIFIER=13
|
||
|
|
||
|
def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
|
||
|
super().__init__(input, output)
|
||
|
self.checkVersion("4.10.1")
|
||
|
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
|
||
|
self._predicates = None
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class KbContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def lrule(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTypedRuleContexts(HMKNFParser.LruleContext)
|
||
|
else:
|
||
|
return self.getTypedRuleContext(HMKNFParser.LruleContext,i)
|
||
|
|
||
|
|
||
|
def orule(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTypedRuleContexts(HMKNFParser.OruleContext)
|
||
|
else:
|
||
|
return self.getTypedRuleContext(HMKNFParser.OruleContext,i)
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_kb
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitKb" ):
|
||
|
return visitor.visitKb(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def kb(self):
|
||
|
|
||
|
localctx = HMKNFParser.KbContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 0, self.RULE_kb)
|
||
|
self._la = 0 # Token type
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 24
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
while (((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << HMKNFParser.T__2) | (1 << HMKNFParser.T__3) | (1 << HMKNFParser.T__5) | (1 << HMKNFParser.IDENTIFIER))) != 0):
|
||
|
self.state = 22
|
||
|
self._errHandler.sync(self)
|
||
|
la_ = self._interp.adaptivePredict(self._input,0,self._ctx)
|
||
|
if la_ == 1:
|
||
|
self.state = 20
|
||
|
self.lrule()
|
||
|
pass
|
||
|
|
||
|
elif la_ == 2:
|
||
|
self.state = 21
|
||
|
self.orule()
|
||
|
pass
|
||
|
|
||
|
|
||
|
self.state = 26
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class LruleContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def head(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.HeadContext,0)
|
||
|
|
||
|
|
||
|
def body(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.BodyContext,0)
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_lrule
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitLrule" ):
|
||
|
return visitor.visitLrule(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def lrule(self):
|
||
|
|
||
|
localctx = HMKNFParser.LruleContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 2, self.RULE_lrule)
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 32
|
||
|
self._errHandler.sync(self)
|
||
|
la_ = self._interp.adaptivePredict(self._input,2,self._ctx)
|
||
|
if la_ == 1:
|
||
|
self.state = 27
|
||
|
self.head()
|
||
|
self.state = 28
|
||
|
self.body()
|
||
|
pass
|
||
|
|
||
|
elif la_ == 2:
|
||
|
self.state = 30
|
||
|
self.head()
|
||
|
pass
|
||
|
|
||
|
elif la_ == 3:
|
||
|
self.state = 31
|
||
|
self.body()
|
||
|
pass
|
||
|
|
||
|
|
||
|
self.state = 34
|
||
|
self.match(HMKNFParser.T__0)
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class HeadContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def IDENTIFIER(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTokens(HMKNFParser.IDENTIFIER)
|
||
|
else:
|
||
|
return self.getToken(HMKNFParser.IDENTIFIER, i)
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_head
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitHead" ):
|
||
|
return visitor.visitHead(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def head(self):
|
||
|
|
||
|
localctx = HMKNFParser.HeadContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 4, self.RULE_head)
|
||
|
self._la = 0 # Token type
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 36
|
||
|
self.match(HMKNFParser.IDENTIFIER)
|
||
|
self.state = 41
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
while _la==HMKNFParser.T__1:
|
||
|
self.state = 37
|
||
|
self.match(HMKNFParser.T__1)
|
||
|
self.state = 38
|
||
|
self.match(HMKNFParser.IDENTIFIER)
|
||
|
self.state = 43
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class BodyContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def katom(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTypedRuleContexts(HMKNFParser.KatomContext)
|
||
|
else:
|
||
|
return self.getTypedRuleContext(HMKNFParser.KatomContext,i)
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_body
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitBody" ):
|
||
|
return visitor.visitBody(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def body(self):
|
||
|
|
||
|
localctx = HMKNFParser.BodyContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 6, self.RULE_body)
|
||
|
self._la = 0 # Token type
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 44
|
||
|
self.match(HMKNFParser.T__2)
|
||
|
self.state = 53
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
if _la==HMKNFParser.T__9 or _la==HMKNFParser.IDENTIFIER:
|
||
|
self.state = 45
|
||
|
self.katom()
|
||
|
self.state = 50
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
while _la==HMKNFParser.T__1:
|
||
|
self.state = 46
|
||
|
self.match(HMKNFParser.T__1)
|
||
|
self.state = 47
|
||
|
self.katom()
|
||
|
self.state = 52
|
||
|
self._errHandler.sync(self)
|
||
|
_la = self._input.LA(1)
|
||
|
|
||
|
|
||
|
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class OruleContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def oformula(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.OformulaContext,0)
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_orule
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitOrule" ):
|
||
|
return visitor.visitOrule(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def orule(self):
|
||
|
|
||
|
localctx = HMKNFParser.OruleContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 8, self.RULE_orule)
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 55
|
||
|
self.oformula(0)
|
||
|
self.state = 56
|
||
|
self.match(HMKNFParser.T__0)
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class OformulaContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_oformula
|
||
|
|
||
|
|
||
|
def copyFrom(self, ctx:ParserRuleContext):
|
||
|
super().copyFrom(ctx)
|
||
|
|
||
|
|
||
|
class NegationContext(OformulaContext):
|
||
|
|
||
|
def __init__(self, parser, ctx:ParserRuleContext): # actually a HMKNFParser.OformulaContext
|
||
|
super().__init__(parser)
|
||
|
self.copyFrom(ctx)
|
||
|
|
||
|
def oformula(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.OformulaContext,0)
|
||
|
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitNegation" ):
|
||
|
return visitor.visitNegation(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
class DisjOrConjContext(OformulaContext):
|
||
|
|
||
|
def __init__(self, parser, ctx:ParserRuleContext): # actually a HMKNFParser.OformulaContext
|
||
|
super().__init__(parser)
|
||
|
self.operator = None # Token
|
||
|
self.copyFrom(ctx)
|
||
|
|
||
|
def oformula(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTypedRuleContexts(HMKNFParser.OformulaContext)
|
||
|
else:
|
||
|
return self.getTypedRuleContext(HMKNFParser.OformulaContext,i)
|
||
|
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitDisjOrConj" ):
|
||
|
return visitor.visitDisjOrConj(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
class ParenthContext(OformulaContext):
|
||
|
|
||
|
def __init__(self, parser, ctx:ParserRuleContext): # actually a HMKNFParser.OformulaContext
|
||
|
super().__init__(parser)
|
||
|
self.copyFrom(ctx)
|
||
|
|
||
|
def oformula(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.OformulaContext,0)
|
||
|
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitParenth" ):
|
||
|
return visitor.visitParenth(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
class ImpContext(OformulaContext):
|
||
|
|
||
|
def __init__(self, parser, ctx:ParserRuleContext): # actually a HMKNFParser.OformulaContext
|
||
|
super().__init__(parser)
|
||
|
self.copyFrom(ctx)
|
||
|
|
||
|
def oformula(self, i:int=None):
|
||
|
if i is None:
|
||
|
return self.getTypedRuleContexts(HMKNFParser.OformulaContext)
|
||
|
else:
|
||
|
return self.getTypedRuleContext(HMKNFParser.OformulaContext,i)
|
||
|
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitImp" ):
|
||
|
return visitor.visitImp(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
class LiteralContext(OformulaContext):
|
||
|
|
||
|
def __init__(self, parser, ctx:ParserRuleContext): # actually a HMKNFParser.OformulaContext
|
||
|
super().__init__(parser)
|
||
|
self.copyFrom(ctx)
|
||
|
|
||
|
def oatom(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.OatomContext,0)
|
||
|
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitLiteral" ):
|
||
|
return visitor.visitLiteral(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
def oformula(self, _p:int=0):
|
||
|
_parentctx = self._ctx
|
||
|
_parentState = self.state
|
||
|
localctx = HMKNFParser.OformulaContext(self, self._ctx, _parentState)
|
||
|
_prevctx = localctx
|
||
|
_startState = 10
|
||
|
self.enterRecursionRule(localctx, 10, self.RULE_oformula, _p)
|
||
|
self._la = 0 # Token type
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 66
|
||
|
self._errHandler.sync(self)
|
||
|
token = self._input.LA(1)
|
||
|
if token in [HMKNFParser.T__3]:
|
||
|
localctx = HMKNFParser.ParenthContext(self, localctx)
|
||
|
self._ctx = localctx
|
||
|
_prevctx = localctx
|
||
|
|
||
|
self.state = 59
|
||
|
self.match(HMKNFParser.T__3)
|
||
|
self.state = 60
|
||
|
self.oformula(0)
|
||
|
self.state = 61
|
||
|
self.match(HMKNFParser.T__4)
|
||
|
pass
|
||
|
elif token in [HMKNFParser.IDENTIFIER]:
|
||
|
localctx = HMKNFParser.LiteralContext(self, localctx)
|
||
|
self._ctx = localctx
|
||
|
_prevctx = localctx
|
||
|
self.state = 63
|
||
|
self.oatom()
|
||
|
pass
|
||
|
elif token in [HMKNFParser.T__5]:
|
||
|
localctx = HMKNFParser.NegationContext(self, localctx)
|
||
|
self._ctx = localctx
|
||
|
_prevctx = localctx
|
||
|
self.state = 64
|
||
|
self.match(HMKNFParser.T__5)
|
||
|
self.state = 65
|
||
|
self.oformula(3)
|
||
|
pass
|
||
|
else:
|
||
|
raise NoViableAltException(self)
|
||
|
|
||
|
self._ctx.stop = self._input.LT(-1)
|
||
|
self.state = 76
|
||
|
self._errHandler.sync(self)
|
||
|
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
|
||
|
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
|
||
|
if _alt==1:
|
||
|
if self._parseListeners is not None:
|
||
|
self.triggerExitRuleEvent()
|
||
|
_prevctx = localctx
|
||
|
self.state = 74
|
||
|
self._errHandler.sync(self)
|
||
|
la_ = self._interp.adaptivePredict(self._input,7,self._ctx)
|
||
|
if la_ == 1:
|
||
|
localctx = HMKNFParser.DisjOrConjContext(self, HMKNFParser.OformulaContext(self, _parentctx, _parentState))
|
||
|
self.pushNewRecursionContext(localctx, _startState, self.RULE_oformula)
|
||
|
self.state = 68
|
||
|
if not self.precpred(self._ctx, 2):
|
||
|
from antlr4.error.Errors import FailedPredicateException
|
||
|
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
|
||
|
|
||
|
self.state = 69
|
||
|
localctx.operator = self._input.LT(1)
|
||
|
_la = self._input.LA(1)
|
||
|
if not(_la==HMKNFParser.T__6 or _la==HMKNFParser.T__7):
|
||
|
localctx.operator = self._errHandler.recoverInline(self)
|
||
|
else:
|
||
|
self._errHandler.reportMatch(self)
|
||
|
self.consume()
|
||
|
self.state = 70
|
||
|
self.oformula(3)
|
||
|
pass
|
||
|
|
||
|
elif la_ == 2:
|
||
|
localctx = HMKNFParser.ImpContext(self, HMKNFParser.OformulaContext(self, _parentctx, _parentState))
|
||
|
self.pushNewRecursionContext(localctx, _startState, self.RULE_oformula)
|
||
|
self.state = 71
|
||
|
if not self.precpred(self._ctx, 1):
|
||
|
from antlr4.error.Errors import FailedPredicateException
|
||
|
raise FailedPredicateException(self, "self.precpred(self._ctx, 1)")
|
||
|
self.state = 72
|
||
|
self.match(HMKNFParser.T__8)
|
||
|
self.state = 73
|
||
|
self.oformula(1)
|
||
|
pass
|
||
|
|
||
|
|
||
|
self.state = 78
|
||
|
self._errHandler.sync(self)
|
||
|
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
|
||
|
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.unrollRecursionContexts(_parentctx)
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class KatomContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def patom(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.PatomContext,0)
|
||
|
|
||
|
|
||
|
def natom(self):
|
||
|
return self.getTypedRuleContext(HMKNFParser.NatomContext,0)
|
||
|
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_katom
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitKatom" ):
|
||
|
return visitor.visitKatom(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def katom(self):
|
||
|
|
||
|
localctx = HMKNFParser.KatomContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 12, self.RULE_katom)
|
||
|
try:
|
||
|
self.state = 81
|
||
|
self._errHandler.sync(self)
|
||
|
token = self._input.LA(1)
|
||
|
if token in [HMKNFParser.IDENTIFIER]:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 79
|
||
|
self.patom()
|
||
|
pass
|
||
|
elif token in [HMKNFParser.T__9]:
|
||
|
self.enterOuterAlt(localctx, 2)
|
||
|
self.state = 80
|
||
|
self.natom()
|
||
|
pass
|
||
|
else:
|
||
|
raise NoViableAltException(self)
|
||
|
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class OatomContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def IDENTIFIER(self):
|
||
|
return self.getToken(HMKNFParser.IDENTIFIER, 0)
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_oatom
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitOatom" ):
|
||
|
return visitor.visitOatom(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def oatom(self):
|
||
|
|
||
|
localctx = HMKNFParser.OatomContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 14, self.RULE_oatom)
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 83
|
||
|
self.match(HMKNFParser.IDENTIFIER)
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class PatomContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def IDENTIFIER(self):
|
||
|
return self.getToken(HMKNFParser.IDENTIFIER, 0)
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_patom
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitPatom" ):
|
||
|
return visitor.visitPatom(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def patom(self):
|
||
|
|
||
|
localctx = HMKNFParser.PatomContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 16, self.RULE_patom)
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 85
|
||
|
self.match(HMKNFParser.IDENTIFIER)
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
class NatomContext(ParserRuleContext):
|
||
|
__slots__ = 'parser'
|
||
|
|
||
|
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
|
||
|
super().__init__(parent, invokingState)
|
||
|
self.parser = parser
|
||
|
|
||
|
def IDENTIFIER(self):
|
||
|
return self.getToken(HMKNFParser.IDENTIFIER, 0)
|
||
|
|
||
|
def getRuleIndex(self):
|
||
|
return HMKNFParser.RULE_natom
|
||
|
|
||
|
def accept(self, visitor:ParseTreeVisitor):
|
||
|
if hasattr( visitor, "visitNatom" ):
|
||
|
return visitor.visitNatom(self)
|
||
|
else:
|
||
|
return visitor.visitChildren(self)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
def natom(self):
|
||
|
|
||
|
localctx = HMKNFParser.NatomContext(self, self._ctx, self.state)
|
||
|
self.enterRule(localctx, 18, self.RULE_natom)
|
||
|
try:
|
||
|
self.enterOuterAlt(localctx, 1)
|
||
|
self.state = 87
|
||
|
self.match(HMKNFParser.T__9)
|
||
|
self.state = 88
|
||
|
self.match(HMKNFParser.IDENTIFIER)
|
||
|
except RecognitionException as re:
|
||
|
localctx.exception = re
|
||
|
self._errHandler.reportError(self, re)
|
||
|
self._errHandler.recover(self, re)
|
||
|
finally:
|
||
|
self.exitRule()
|
||
|
return localctx
|
||
|
|
||
|
|
||
|
|
||
|
def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int):
|
||
|
if self._predicates == None:
|
||
|
self._predicates = dict()
|
||
|
self._predicates[5] = self.oformula_sempred
|
||
|
pred = self._predicates.get(ruleIndex, None)
|
||
|
if pred is None:
|
||
|
raise Exception("No predicate with index:" + str(ruleIndex))
|
||
|
else:
|
||
|
return pred(localctx, predIndex)
|
||
|
|
||
|
def oformula_sempred(self, localctx:OformulaContext, predIndex:int):
|
||
|
if predIndex == 0:
|
||
|
return self.precpred(self._ctx, 2)
|
||
|
|
||
|
|
||
|
if predIndex == 1:
|
||
|
return self.precpred(self._ctx, 1)
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|