Commits

Anonymous committed e8c4cf0 Draft

simplify parse trees for ometa grammars
---
pymeta/builder.py | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)

Comments (0)

Files changed (1)

pymeta/builder.py

         return ["Optional", expr]
 
     def _or(self, exprs):
-        return ["Or", exprs]
+        return ["Or"] + exprs
 
     def _not(self, expr):
         return ["Not", expr]
 
     def _xor(self, exprs):
-        return ["Xor", exprs]
+        return ["Xor"] + exprs
 
     def lookahead(self, expr):
         return ["Lookahead", expr]
 
     def sequence(self, exprs):
-        return ["And", exprs]
+        return ["And"] + exprs
 
     def bind(self, expr, name):
         return ["Bind", name, expr]
         return ["Range", c1, c2]
 
     def interleave(self, exprs):
-        return ["Interleave", exprs]
+        return ["Interleave"]+exprs
 
 class PythonWriter(object):
     """
         return self._expr('or', 'self._or([%s])' % (', '.join([realf, passf])))
 
 
-    def generate_Or(self, exprs):
+    def generate_Or(self, *exprs):
         """
         Create a call to
         self._or([lambda: expr1, lambda: expr2, ... , lambda: exprN]).
         else:
             return self._generateNode(exprs[0])
 
-    def generate_Xor(self, exprs):
+    def generate_Xor(self, *exprs):
         """
         Create a call to
         self._xor([lambda: expr1, lambda: expr2, ... , lambda: exprN]).
         fname = self._newThunkFor("lookahead", expr)
         return self._expr("lookahead", "self.lookahead(%s)" %(fname,))
 
-    def generate_And(self, exprs):
+    def generate_And(self, *exprs):
         """
         Generate code for each statement in order.
         """
         """
         return self._expr('range', 'self.range(%r, %r)' % (c1, c2))
 
-    def generate_Interleave(self, exprs):
+    def generate_Interleave(self, *exprs):
         """
         Create a call to
         self._interleave([lambda: expr1, lambda: expr2, ... , lambda: exprN]).