Skip to content

Commit

Permalink
Fix parsing of test statement
Browse files Browse the repository at this point in the history
  • Loading branch information
dlorch committed May 5, 2016
1 parent f5169bd commit 732b95f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 10 additions & 2 deletions pycep/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,9 +1070,17 @@ def _test(tokens):
test: or_test ['if' or_test 'else' test] | lambdef
"""
result = [symbol.test]
result.append(_or_test(tokens))

# TODO if/lambdef
if tokens.check(token.NAME, "lambda"):
result.append(_lambdef(tokens))
else:
result.append(_or_test(tokens))

if tokens.check(token.NAME, "if"):
result.append(tokens.accept(token.NAME, "if"))
result.append(_or_test(tokens))
result.append(tokens.accept(token.NAME, "else"))
result.append(_test(tokens))

return result

Expand Down
6 changes: 5 additions & 1 deletion pycep/tests/snippets/pos/astrein.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,8 @@ def divide(x, y):
-4
~foo

4 ** 16
4 ** 16

#g = lambda x: x**2

5 if foo == 30 else 19

0 comments on commit 732b95f

Please sign in to comment.