本文整理汇总了Python中antlr4.error.Errors.FailedPredicateException方法的典型用法代码示例。如果您正苦于以下问题:Python Errors.FailedPredicateException方法的具体用法?Python Errors.FailedPredicateException怎么用?Python Errors.FailedPredicateException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类antlr4.error.Errors
的用法示例。
在下文中一共展示了Errors.FailedPredicateException方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: observationExpressions
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def observationExpressions(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = STIXPatternParser.ObservationExpressionsContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 2
self.enterRecursionRule(localctx, 2, self.RULE_observationExpressions, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 40
self.observationExpressionOr(0)
self._ctx.stop = self._input.LT(-1)
self.state = 47
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,0,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = STIXPatternParser.ObservationExpressionsContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_observationExpressions)
self.state = 42
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 43
self.match(STIXPatternParser.FOLLOWEDBY)
self.state = 44
self.observationExpressions(3)
self.state = 49
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,0,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
示例2: observationExpressionOr
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def observationExpressionOr(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = STIXPatternParser.ObservationExpressionOrContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 4
self.enterRecursionRule(localctx, 4, self.RULE_observationExpressionOr, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 51
self.observationExpressionAnd(0)
self._ctx.stop = self._input.LT(-1)
self.state = 58
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,1,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = STIXPatternParser.ObservationExpressionOrContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_observationExpressionOr)
self.state = 53
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 54
self.match(STIXPatternParser.OR)
self.state = 55
self.observationExpressionOr(3)
self.state = 60
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,1,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
示例3: observationExpressionAnd
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def observationExpressionAnd(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = STIXPatternParser.ObservationExpressionAndContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 6
self.enterRecursionRule(localctx, 6, self.RULE_observationExpressionAnd, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 62
self.observationExpression(0)
self._ctx.stop = self._input.LT(-1)
self.state = 69
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,2,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = STIXPatternParser.ObservationExpressionAndContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_observationExpressionAnd)
self.state = 64
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 65
self.match(STIXPatternParser.AND)
self.state = 66
self.observationExpressionAnd(3)
self.state = 71
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,2,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
示例4: comparisonExpression
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def comparisonExpression(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = STIXPatternParser.ComparisonExpressionContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 10
self.enterRecursionRule(localctx, 10, self.RULE_comparisonExpression, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 95
self.comparisonExpressionAnd(0)
self._ctx.stop = self._input.LT(-1)
self.state = 102
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,6,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = STIXPatternParser.ComparisonExpressionContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonExpression)
self.state = 97
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 98
self.match(STIXPatternParser.OR)
self.state = 99
self.comparisonExpression(3)
self.state = 104
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,6,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
示例5: comparisonExpressionAnd
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def comparisonExpressionAnd(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = STIXPatternParser.ComparisonExpressionAndContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 12
self.enterRecursionRule(localctx, 12, self.RULE_comparisonExpressionAnd, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 106
self.propTest()
self._ctx.stop = self._input.LT(-1)
self.state = 113
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,7,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = STIXPatternParser.ComparisonExpressionAndContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_comparisonExpressionAnd)
self.state = 108
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 109
self.match(STIXPatternParser.AND)
self.state = 110
self.comparisonExpressionAnd(3)
self.state = 115
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,7,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
示例6: visitState
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def visitState(self, p:ATNState):
edge = 0
if len(p.transitions) > 1:
self._errHandler.sync(self)
edge = self._interp.adaptivePredict(self._input, p.decision, self._ctx)
else:
edge = 1
transition = p.transitions[edge - 1]
tt = transition.serializationType
if tt==Transition.EPSILON:
if self.pushRecursionContextStates[p.stateNumber] and not isinstance(transition.target, LoopEndState):
t = self._parentContextStack[-1]
ctx = InterpreterRuleContext(t[0], t[1], self._ctx.ruleIndex)
self.pushNewRecursionContext(ctx, self.atn.ruleToStartState[p.ruleIndex].stateNumber, self._ctx.ruleIndex)
elif tt==Transition.ATOM:
self.match(transition.label)
elif tt in [ Transition.RANGE, Transition.SET, Transition.NOT_SET]:
if not transition.matches(self._input.LA(1), Token.MIN_USER_TOKEN_TYPE, Lexer.MAX_CHAR_VALUE):
self._errHandler.recoverInline(self)
self.matchWildcard()
elif tt==Transition.WILDCARD:
self.matchWildcard()
elif tt==Transition.RULE:
ruleStartState = transition.target
ruleIndex = ruleStartState.ruleIndex
ctx = InterpreterRuleContext(self._ctx, p.stateNumber, ruleIndex)
if ruleStartState.isPrecedenceRule:
self.enterRecursionRule(ctx, ruleStartState.stateNumber, ruleIndex, transition.precedence)
else:
self.enterRule(ctx, transition.target.stateNumber, ruleIndex)
elif tt==Transition.PREDICATE:
if not self.sempred(self._ctx, transition.ruleIndex, transition.predIndex):
raise FailedPredicateException(self)
elif tt==Transition.ACTION:
self.action(self._ctx, transition.ruleIndex, transition.actionIndex)
elif tt==Transition.PRECEDENCE:
if not self.precpred(self._ctx, transition.precedence):
msg = "precpred(_ctx, " + str(transition.precedence) + ")"
raise FailedPredicateException(self, msg)
else:
raise UnsupportedOperationException("Unrecognized ATN transition type.")
self.state = transition.target.stateNumber
示例7: sliceable
# 需要导入模块: from antlr4.error import Errors [as 别名]
# 或者: from antlr4.error.Errors import FailedPredicateException [as 别名]
def sliceable(self):
localctx = JSONPathParser.SliceableContext(self, self._ctx, self.state)
self.enterRule(localctx, 16, self.RULE_sliceable)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 118
self.match(JSONPathParser.COLON)
self.state = 121
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==JSONPathParser.NUMBER:
self.state = 119
self.match(JSONPathParser.NUMBER)
self.state = 120
if not self.tryCast(int):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.tryCast(int)")
self.state = 128
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==JSONPathParser.COLON:
self.state = 123
self.match(JSONPathParser.COLON)
self.state = 126
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==JSONPathParser.NUMBER:
self.state = 124
self.match(JSONPathParser.NUMBER)
self.state = 125
if not self.tryCast(int):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.tryCast(int)")
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx