Commits

Ronny Pfannschmidt committed f0e5d44

some parser changes

Comments (0)

Files changed (2)

testing/test_parse_command.py

 from whenever import parse_command
 commands = [
     'defer (1) again (2) 3;',
-    'again (1) defer (3 || N(1)<=N(2) || N(7)>99) 2#N(1),3,7;'
+    'again (1) defer (3 || N(1)<=N(2) || N(7)>99) 2#N(1),3,7;',
+    'defer (3 || N(1)<=N(2))',
 ]
 
 
     try:
         parse_command(command)
     except Exception, e:
+        if not hasattr(e, 'nice_error_message'):
+            raise
         print e.nice_error_message()
         print command
         print ' '*e.args[0].i + '^'

whenever/__init__.py

 
 
 number: DECIMAL;
+
+
 math: number;
 
+function: "N" "(" expr ")";
+
+
+
+
+expr: function | math;
+
+
+chain: "||" | "&&";
 compare: ">" | ">=" | "<" | "<=";
-bool: math "||" math | math compare math;
-function: "N" "(" expr ")";
-expr: bool | math | function;
+bool: expr compare expr | expr;
+booleans: (bool chain)* bool;
+
 
 statement: expr "#" expr | expr;
 statements: (statement ",")* statement;
 
 action_name: "print" | "defer" | "again" | "forget";
-action: action_name "(" expr ")";
+action: action_name "(" booleans ")";
 
 """)