Can chain multiple logical operations in a row.

pull/15/head
Jussi Pakkanen 10 years ago
parent f662ef8483
commit 1a8d830e05
  1. 8
      mparser.py
  2. 12
      test cases/common/40 logic ops/meson.build

@ -318,14 +318,14 @@ class Parser:
def e2(self):
left = self.e3()
if self.accept('or'):
return OrNode(left.lineno, left.colno, left, self.e3())
while self.accept('or'):
left = OrNode(left.lineno, left.colno, left, self.e3())
return left
def e3(self):
left = self.e4()
if self.accept('and'):
return AndNode(left.lineno, left.colno, left, self.e4())
while self.accept('and'):
left = AndNode(left.lineno, left.colno, left, self.e4())
return left
def e4(self):

@ -75,3 +75,15 @@ else
error('Negation failed.')
endif
if f or f or f or f or f or f or f or f or t
message('Ok.')
else
error('Chain of ors failed.')
endif
if t and t and t and t and t and t and t and t and f
error('Chain of ands failed.')
else
message('Ok.')
endif

Loading…
Cancel
Save