MCPcopy
hub / github.com/nltk/nltk / handle_quant

Method handle_quant

nltk/sem/logic.py:402–430  ·  view source on GitHub ↗
(self, tok, context)

Source from the content-addressed store, hash-verified

400 return accum
401
402 def handle_quant(self, tok, context):
403 # Expression is a quantified expression: some x.M
404 factory = self.get_QuantifiedExpression_factory(tok)
405
406 if not self.inRange(0):
407 raise ExpectedMoreTokensException(
408 self._currentIndex + 2,
409 message="Variable and Expression expected following quantifier '%s'."
410 % tok,
411 )
412 vars = [self.get_next_token_variable("quantified")]
413 while True:
414 if not self.inRange(0) or (
415 self.token(0) == Tokens.DOT and not self.inRange(1)
416 ):
417 raise ExpectedMoreTokensException(
418 self._currentIndex + 2, message="Expression expected."
419 )
420 if not self.isvariable(self.token(0)):
421 break
422 # Support expressions like: some x y.M == some x.some y.M
423 vars.append(self.get_next_token_variable("quantified"))
424 if self.inRange(0) and self.token(0) == Tokens.DOT:
425 self.token() # swallow the dot
426
427 accum = self.process_next_expression(tok)
428 while vars:
429 accum = self.make_QuanifiedExpression(factory, vars.pop(), accum)
430 return accum
431
432 def get_QuantifiedExpression_factory(self, tok):
433 """This method serves as a hook for other logic parsers that

Callers 1

handleMethod · 0.95

Calls 10

inRangeMethod · 0.95
tokenMethod · 0.95
isvariableMethod · 0.95
appendMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected