Commit 4f3552b4 authored by Taddeus Kroes's avatar Taddeus Kroes

Added check that prevents that multiplication sign is not printed before a negated scope node.

parent e4a17ba8
...@@ -283,11 +283,13 @@ def generate_line(root): ...@@ -283,11 +283,13 @@ def generate_line(root):
right_paren = e[1][0] == '(' right_paren = e[1][0] == '('
if (is_id(left) or left_paren or is_int(left)) \ if (is_id(left) or left_paren or is_int(left)) \
and (is_id(right) or right_paren): and ((not right.negated and is_id(right)) or right_paren):
sep = '' sep = ''
exp = sep.join(e) exp = sep.join(e)
#if node.negated:
# FIXME: Keep it this way?
if node.negated and op != '*': if node.negated and op != '*':
exp = '(' + exp + ')' exp = '(' + exp + ')'
......
...@@ -50,8 +50,8 @@ class TestLine(unittest.TestCase): ...@@ -50,8 +50,8 @@ class TestLine(unittest.TestCase):
def test_multiplication_identifiers(self): def test_multiplication_identifiers(self):
a, b = L('a'), L('b') a, b = L('a'), L('b')
mul = N('*', a, b) self.assertEquals(generate_line(N('*', a, b)), 'ab')
self.assertEquals(generate_line(mul), 'ab') self.assertEquals(generate_line(N('*', a, -b)), 'a * -b')
def test_multiplication_constant_identifier(self): def test_multiplication_constant_identifier(self):
l0, a = L(2), L('a') l0, a = L(2), L('a')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment