Commit 69c3cd5d authored by Taddeus Kroes's avatar Taddeus Kroes Committed by Taddeüs Kroes

Fixed pi notation.

parent 903dfc6f
...@@ -181,7 +181,7 @@ class Parser(BisonParser): ...@@ -181,7 +181,7 @@ class Parser(BisonParser):
return data return data
# Replace known keywords with escape sequences. # Replace known keywords with escape sequences.
words = list(self.__class__.words) words = list(self.words)
words.insert(10, '\n') words.insert(10, '\n')
words.insert(13, '\r') words.insert(13, '\r')
...@@ -211,8 +211,8 @@ class Parser(BisonParser): ...@@ -211,8 +211,8 @@ class Parser(BisonParser):
# inserted between a function and its argument(s): "sin x" should # inserted between a function and its argument(s): "sin x" should
# not be written as "sin*x", because that is bogus. # not be written as "sin*x", because that is bogus.
# Bugfix: omit 0x0e (pi) to prevent "pi a" (should be "pi*a") # Bugfix: omit 0x0e (pi) to prevent "pi a" (should be "pi*a")
if ord(left) <= 0x9 or 0x0b <= ord(left) <= 0x0d \ o = ord(left)
or 0x0f <= ord(left) <= 0x19: if o <= 0x9 or 0x0b <= o <= 0x0d or 0x0f <= o <= 0x19:
return left + ' ' + right return left + ' ' + right
# If all characters on the right are numbers. e.g. "a4", the # If all characters on the right are numbers. e.g. "a4", the
......
...@@ -83,6 +83,8 @@ class TestParser(RulesTestCase): ...@@ -83,6 +83,8 @@ class TestParser(RulesTestCase):
# FIXME: self.assertEqual(tree('|a|b'), tree('|a| * b')) # FIXME: self.assertEqual(tree('|a|b'), tree('|a| * b'))
self.assertEqual(tree('|a||b|'), tree('|a| * |b|')) self.assertEqual(tree('|a||b|'), tree('|a| * |b|'))
self.assertEqual(tree('pi2'), tree('pi * 2'))
def test_functions(self): def test_functions(self):
x = tree('x') x = tree('x')
......
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