[pypy-svn] r38877 - in pypy/branch/ast-experiments/pypy: config interpreter interpreter/pyparser module/dyngram module/recparser

adim at codespeak.net adim at codespeak.net
Thu Feb 15 14:13:50 CET 2007


Author: adim
Date: Thu Feb 15 14:13:49 2007
New Revision: 38877

Added:
   pypy/branch/ast-experiments/pypy/module/dyngram/   (props changed)
   pypy/branch/ast-experiments/pypy/module/dyngram/__init__.py   (contents, props changed)
Modified:
   pypy/branch/ast-experiments/pypy/config/pypyoption.py
   pypy/branch/ast-experiments/pypy/interpreter/pycompiler.py
   pypy/branch/ast-experiments/pypy/interpreter/pyparser/pythonparse.py
   pypy/branch/ast-experiments/pypy/module/recparser/__init__.py
Log:
- made a special "dyngram" module that exports the runtime grammar
  modifications ability



Modified: pypy/branch/ast-experiments/pypy/config/pypyoption.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/config/pypyoption.py	(original)
+++ pypy/branch/ast-experiments/pypy/config/pypyoption.py	Thu Feb 15 14:13:49 2007
@@ -24,7 +24,7 @@
 working_modules = default_modules.copy()
 working_modules.update(dict.fromkeys(
     ["rsocket", "unicodedata", "mmap", "fcntl", "rctime", "select", "bz2",
-     "crypt", "signal",
+     "crypt", "signal", "dyngram",
     ]
 ))
 

Modified: pypy/branch/ast-experiments/pypy/interpreter/pycompiler.py
==============================================================================
--- pypy/branch/ast-experiments/pypy/interpreter/pycompiler.py	(original)
+++ pypy/branch/ast-experiments/pypy/interpreter/pycompiler.py	Thu Feb 15 14:13:49 2007
@@ -200,11 +200,10 @@
          the whole source after having only added a new '\n')
     """
     def __init__(self, space):
-        from pyparser.pythonparse import make_pyparser
+        from pyparser.pythonparse import PYTHON_PARSER
         PyCodeCompiler.__init__(self, space)
-        self.parser = make_pyparser()
+        self.parser = PYTHON_PARSER
         self.additional_rules = {}
-
     
 
     def compile(self, source, filename, mode, flags):

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	Thu Feb 15 14:13:49 2007
@@ -168,12 +168,12 @@
         # recompute first sets
         self.build_first_sets()
 
-
-
 def make_pyparser(version="2.4"):
     parser = PythonParser()
     return build_parser_for_version(version, parser=parser)
 
+PYTHON_PARSER = make_pyparser()
+
 def translation_target(grammardef):
     parser = PythonParser() # predefined_symbols=symbol.sym_name)
     source = GrammarSource(GRAMMAR_GRAMMAR, grammardef)
@@ -185,7 +185,6 @@
     return 0
 
 
-
 ## XXX BROKEN
 ## def parse_grammar(space, w_src):
 ##     """Loads the grammar using the 'dynamic' rpython parser"""

Added: pypy/branch/ast-experiments/pypy/module/dyngram/__init__.py
==============================================================================
--- (empty file)
+++ pypy/branch/ast-experiments/pypy/module/dyngram/__init__.py	Thu Feb 15 14:13:49 2007
@@ -0,0 +1,12 @@
+"""Mixed module for dynamic grammar modification"""
+
+from pypy.interpreter.mixedmodule import MixedModule 
+
+class Module(MixedModule):
+    """dyngram module definition"""
+    
+    name = 'dyngram'
+    appleveldefs = {}
+    interpleveldefs = {
+        'insert_grammar_rule' : 'pypy.interpreter.pycompiler.insert_grammar_rule',
+        }

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	Thu Feb 15 14:13:49 2007
@@ -47,8 +47,6 @@
          'source2ast' : "pyparser.source2ast",
          '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',
-         #'parse_grammar' : 'pypy.interpreter.pyparser.pythonparse.parse_grammar',
          }
 
 # Automatically exports each AST class



More information about the Pypy-commit mailing list