[pypy-svn] r38796 - in pypy/branch/ast-experiments/pypy: interpreter/pyparser module/recparser

adim at codespeak.net adim at codespeak.net
Wed Feb 14 11:53:29 CET 2007


Author: adim
Date: Wed Feb 14 11:53:28 2007
New Revision: 38796

Modified:
   pypy/branch/ast-experiments/pypy/interpreter/pyparser/astbuilder.py
   pypy/branch/ast-experiments/pypy/interpreter/pyparser/pythonparse.py
   pypy/branch/ast-experiments/pypy/module/recparser/__init__.py
   pypy/branch/ast-experiments/pypy/module/recparser/pyparser.py
Log:
small rpython fixes

Modified: pypy/branch/ast-experiments/pypy/interpreter/pyparser/astbuilder.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/interpreter/pyparser/astbuilder.py	(original)
+++ pypy/branch/ast-experiments/pypy/interpreter/pyparser/astbuilder.py	Wed Feb 14 11:53:28 2007
@@ -579,8 +579,10 @@
     nodes = []
     # remove '@', '(' and ')' from atoms and use parse_attraccess
     for token in atoms[1:]:
-        if isinstance(token, TokenObject) and \
-               token.name in (builder.parser.tokens['LPAR'], builder.parser.tokens['RPAR'], builder.parser.tokens['NEWLINE']):
+        if isinstance(token, TokenObject) and (
+               token.name == builder.parser.tokens['LPAR']
+               or token.name == builder.parser.tokens['RPAR']
+               or token.name == builder.parser.tokens['NEWLINE']):
             # skip those ones
             continue
         else:
@@ -1179,7 +1181,6 @@
     def is_string_const(self, expr):
         if not isinstance(expr,ast.Const):
             return False
-        print 'IS STRING CONST', repr(expr.value)
         space = self.space
         return space.is_true(space.isinstance(expr.value,space.w_str))
 

Modified: pypy/branch/ast-experiments/pypy/interpreter/pyparser/pythonparse.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/interpreter/pyparser/pythonparse.py	(original)
+++ pypy/branch/ast-experiments/pypy/interpreter/pyparser/pythonparse.py	Wed Feb 14 11:53:28 2007
@@ -196,13 +196,6 @@
 # PYTHON_PARSER = make_pyparser()
 
 ## XXX BROKEN
-## def grammar_rules( space ):
-##     w_rules = space.newdict()
-##     for key, value in PYTHON_PARSER.rules.iteritems():
-##         space.setitem(w_rules, space.wrap(key), space.wrap(value))
-##     return w_rules
-## 
-## 
 ## def parse_grammar(space, w_src):
 ##     """Loads the grammar using the 'dynamic' rpython parser"""
 ##     src = space.str_w( w_src )
@@ -210,3 +203,10 @@
 ##     ebnfbuilder.resolve_rules()
 ##     grammar.build_first_sets(ebnfbuilder.all_rules)
 ##     return space.wrap( ebnfbuilder.root_rules )
+
+def grammar_rules( space ):
+    w_rules = space.newdict()
+    parser = make_pyparser()
+    for key, value in parser.rules.iteritems():
+        space.setitem(w_rules, space.wrap(key), space.wrap(value))
+    return w_rules

Modified: pypy/branch/ast-experiments/pypy/module/recparser/__init__.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/module/recparser/__init__.py	(original)
+++ pypy/branch/ast-experiments/pypy/module/recparser/__init__.py	Wed Feb 14 11:53:28 2007
@@ -48,7 +48,6 @@
          'decode_string_literal': 'pyparser.decode_string_literal',
          'install_compiler_hook' : 'pypy.interpreter.pycompiler.install_compiler_hook',
          'insert_grammar_rule' : 'pypy.interpreter.pycompiler.insert_grammar_rule',
-         #'rules' : 'pypy.interpreter.pyparser.pythonparse.grammar_rules',
          #'parse_grammar' : 'pypy.interpreter.pyparser.pythonparse.parse_grammar',
          }
 

Modified: pypy/branch/ast-experiments/pypy/module/recparser/pyparser.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/module/recparser/pyparser.py	(original)
+++ pypy/branch/ast-experiments/pypy/module/recparser/pyparser.py	Wed Feb 14 11:53:28 2007
@@ -51,8 +51,10 @@
         if node.value is not None:
             val = node.value
         else:
-            if num not in ( tokens['NEWLINE'], tokens['INDENT'],
-                            tokens['DEDENT'], tokens['ENDMARKER'] ):
+            if num != tokens['NEWLINE'] and \
+               num != tokens['INDENT'] and \
+               num != tokens['DEDENT'] and \
+               num != tokens['ENDMARKER']:
                 val = space.default_compiler.parser.tok_rvalues[num]
             else:
                 val = node.value or ''


More information about the pypy-svn mailing list