# HG changeset patch # User Paul Boddie # Date 1483985775 -3600 # Node ID bf30cee569ab2a0541242749192b86cd351452c1 # Parent 0982751b90e31b1cc7956f881d42b010853526db Removed if expression support from the grammar. diff -r 0982751b90e3 -r bf30cee569ab compiler/transformer.py --- a/compiler/transformer.py Mon Jan 09 19:11:44 2017 +0100 +++ b/compiler/transformer.py Mon Jan 09 19:16:15 2017 +0100 @@ -503,17 +503,10 @@ return self.testlist(nodelist) def test(self, nodelist): - # or_test ['if' or_test 'else' test] | lambdef + # or_test | lambdef if len(nodelist) == 1 and nodelist[0][0] == symbol["lambdef"]: return self.lambdef(nodelist[0]) then = self.com_node(nodelist[0]) - if len(nodelist) > 1: - assert len(nodelist) == 5 - assert nodelist[1][1] == 'if' - assert nodelist[3][1] == 'else' - test = self.com_node(nodelist[2]) - else_ = self.com_node(nodelist[4]) - return IfExp(test, then, else_, lineno=nodelist[1][2]) return then def or_test(self, nodelist): diff -r 0982751b90e3 -r bf30cee569ab pyparser/data/Grammar-Lichen --- a/pyparser/data/Grammar-Lichen Mon Jan 09 19:11:44 2017 +0100 +++ b/pyparser/data/Grammar-Lichen Mon Jan 09 19:16:15 2017 +0100 @@ -72,7 +72,7 @@ old_test: or_test | old_lambdef old_lambdef: 'lambda' [varargslist] ':' old_test -test: or_test ['if' or_test 'else' test] | lambdef +test: or_test | lambdef or_test: and_test ('or' and_test)* and_test: not_test ('and' not_test)* not_test: 'not' not_test | comparison