[pypy-svn] r13103 - pypy/branch/pycompiler/module/recparser

adim at codespeak.net adim at codespeak.net
Mon Jun 6 15:25:13 CEST 2005


Author: adim
Date: Mon Jun  6 15:25:12 2005
New Revision: 13103

Modified:
   pypy/branch/pycompiler/module/recparser/ebnfparse.py
   pypy/branch/pycompiler/module/recparser/grammar.py
Log:
Don't use *varargs construction where not needed


Modified: pypy/branch/pycompiler/module/recparser/ebnfparse.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/ebnfparse.py	(original)
+++ pypy/branch/pycompiler/module/recparser/ebnfparse.py	Mon Jun  6 15:25:12 2005
@@ -125,7 +125,7 @@
         items+= node.nodes[1].visit(self)        
         if len(items)==1 and items[0].name.startswith(':'):
             return items[0]
-        alt = Alternative( self.new_name(), *items )
+        alt = Alternative( self.new_name(), items )
         return self.new_item( alt )
 
     def visit_sequence( self, node ):
@@ -136,7 +136,7 @@
         if len(items)==1:
             return items[0]
         elif len(items)>1:
-            return self.new_item( Sequence( self.new_name(), *items) )
+            return self.new_item( Sequence( self.new_name(), items) )
         raise SyntaxError("Found empty sequence")
 
     def visit_sequence_cont( self, node ):
@@ -217,34 +217,34 @@
     """
     global rules
     # star: '*' | '+'
-    star          = Alternative( "star", Token('*'), Token('+') )
+    star          = Alternative( "star", [Token('*'), Token('+')] )
     star_opt      = KleenStar  ( "star_opt", 0, 1, rule=star )
 
     # rule: SYMBOL ':' alternative
-    symbol        = Sequence(    "symbol", Token('SYMBOL'), star_opt )
+    symbol        = Sequence(    "symbol", [Token('SYMBOL'), star_opt] )
     symboldef     = Token(       "SYMDEF" )
-    alternative   = Sequence(    "alternative" )
-    rule          = Sequence(    "rule", symboldef, alternative )
+    alternative   = Sequence(    "alternative", [])
+    rule          = Sequence(    "rule", [symboldef, alternative] )
 
     # grammar: rule+
     grammar       = KleenStar(   "grammar", _min=1, rule=rule )
 
     # alternative: sequence ( '|' sequence )*
     sequence      = KleenStar(   "sequence", 1 )
-    seq_cont_list = Sequence(    "seq_cont_list", Token('|'), sequence )
+    seq_cont_list = Sequence(    "seq_cont_list", [Token('|'), sequence] )
     sequence_cont = KleenStar(   "sequence_cont",0, rule=seq_cont_list )
     
     alternative.args = [ sequence, sequence_cont ]
 
     # option: '[' alternative ']'
-    option        = Sequence(    "option", Token('['), alternative, Token(']') )
+    option        = Sequence(    "option", [Token('['), alternative, Token(']')] )
 
     # group: '(' alternative ')'
-    group         = Sequence(    "group",  Token('('), alternative, Token(')'), star_opt )
+    group         = Sequence(    "group",  [Token('('), alternative, Token(')'), star_opt] )
 
     # sequence: (SYMBOL | STRING | option | group )+
     string = Token('STRING')
-    alt           = Alternative( "sequence_alt", symbol, string, option, group ) 
+    alt           = Alternative( "sequence_alt", [symbol, string, option, group] ) 
     sequence.args = [ alt ]
 
 

Modified: pypy/branch/pycompiler/module/recparser/grammar.py
==============================================================================
--- pypy/branch/pycompiler/module/recparser/grammar.py	(original)
+++ pypy/branch/pycompiler/module/recparser/grammar.py	Mon Jun  6 15:25:12 2005
@@ -269,9 +269,9 @@
 
 class Alternative(GrammarElement):
     """Represents an alternative in a grammar rule (as in S -> A | B | C)"""
-    def __init__(self, name, *args):
+    def __init__(self, name, args):
         GrammarElement.__init__(self, name )
-        self.args = list(args)
+        self.args = args
         self._reordered = False
         for i in self.args:
             assert isinstance( i, GrammarElement )
@@ -352,9 +352,9 @@
     
 class Sequence(GrammarElement):
     """Reprensents a Sequence in a grammar rule (as in S -> A B C)"""
-    def __init__(self, name, *args):
+    def __init__(self, name, args):
         GrammarElement.__init__(self, name )
-        self.args = list(args)
+        self.args = args
         for i in self.args:
             assert isinstance( i, GrammarElement )
 



More information about the Pypy-commit mailing list