(self, tok, context)
| 330 | return NegatedExpression(expression) |
| 331 | |
| 332 | def handle_variable(self, tok, context): |
| 333 | # It's either: 1) a predicate expression: sees(x,y) |
| 334 | # 2) an application expression: P(x) |
| 335 | # 3) a solo variable: john OR x |
| 336 | accum = self.make_VariableExpression(tok) |
| 337 | if self.inRange(0) and self.token(0) == Tokens.OPEN: |
| 338 | # The predicate has arguments |
| 339 | if not isinstance(accum, FunctionVariableExpression) and not isinstance( |
| 340 | accum, ConstantExpression |
| 341 | ): |
| 342 | raise LogicalExpressionException( |
| 343 | self._currentIndex, |
| 344 | "'%s' is an illegal predicate name. " |
| 345 | "Individual variables may not be used as " |
| 346 | "predicates." % tok, |
| 347 | ) |
| 348 | self.token() # swallow the Open Paren |
| 349 | |
| 350 | # curry the arguments |
| 351 | accum = self.make_ApplicationExpression( |
| 352 | accum, self.process_next_expression(APP) |
| 353 | ) |
| 354 | while self.inRange(0) and self.token(0) == Tokens.COMMA: |
| 355 | self.token() # swallow the comma |
| 356 | accum = self.make_ApplicationExpression( |
| 357 | accum, self.process_next_expression(APP) |
| 358 | ) |
| 359 | self.assertNextToken(Tokens.CLOSE) |
| 360 | return accum |
| 361 | |
| 362 | def get_next_token_variable(self, description): |
| 363 | try: |
no test coverage detected