[pypy-svn] r10095 - pypy/dist/pypy/module/parser

hpk at codespeak.net hpk at codespeak.net
Tue Mar 22 23:21:57 CET 2005


Author: hpk
Date: Tue Mar 22 23:21:57 2005
New Revision: 10095

Modified:
   pypy/dist/pypy/module/parser/__init__.py
   pypy/dist/pypy/module/parser/pyparser.py
Log:
expose suite and expr 


Modified: pypy/dist/pypy/module/parser/__init__.py
==============================================================================
--- pypy/dist/pypy/module/parser/__init__.py	(original)
+++ pypy/dist/pypy/module/parser/__init__.py	Tue Mar 22 23:21:57 2005
@@ -7,21 +7,23 @@
     """ 
     appleveldefs = {
         'ParserError'  : 'classes.ParserError', 
-        'STType'       : 'classes.STType', 
-        'ASTType'      : 'classes.STType', 
     }
         
     interpleveldefs = {
         '__name__'     : '(space.wrap("parser"))', 
         '__doc__'      : '(space.wrap("parser module"))', 
 
+        'suite'        : 'pyparser.suite',
+        'STType'       : 'pyparser.STType', 
+        'ASTType'      : 'pyparser.STType', 
+        'eval_input'   : 'pyparser.eval_input', 
+        'file_input'   : 'pyparser.file_input', 
         'compileast'   : 'pyparser.compileast',
         'st2tuple'     : 'pyparser.st2tuple',
         'st2list'      : 'pyparser.st2list',
         'issuite'      : 'pyparser.issuite',
         'ast2tuple'    : 'pyparser.ast2tuple',
         'tuple2st'     : 'pyparser.tuple2st',
-        'suite'        : 'pyparser.suite',
         'isexpr'       : 'pyparser.isexpr',
         'expr'         : 'pyparser.expr',
         'ast2list'     : 'pyparser.ast2list',

Modified: pypy/dist/pypy/module/parser/pyparser.py
==============================================================================
--- pypy/dist/pypy/module/parser/pyparser.py	(original)
+++ pypy/dist/pypy/module/parser/pyparser.py	Tue Mar 22 23:21:57 2005
@@ -9,6 +9,9 @@
 # ______________________________________________________________________
 # Module imports
 
+from pypy.interpreter.baseobjspace import ObjSpace, Wrappable
+from pypy.interpreter.typedef import TypeDef, interp_attrproperty, GetSetProperty
+
 import token, compiler
 import PyTokenizer, PyGrammar, DFAParser
 
@@ -30,7 +33,7 @@
 
 # ______________________________________________________________________
 
-class STType (object):
+class STType (Wrappable):
     """Class STType
     """
     # ____________________________________________________________
@@ -89,6 +92,9 @@
             gen = compiler.pycodegen.ModuleCodeGenerator(compileAST)
         return gen.getCode()
 
+STType.typedef = TypeDef("parser.st", 
+) 
+
 # ______________________________________________________________________
 
 ASTType = STType
@@ -255,21 +261,25 @@
     return st.compile(file_name)
 
 # ______________________________________________________________________
-def expr (source):
+def expr (space, source):
     """expr
     Tries to mock the expr() function in the Python parser module, but returns
     one of those silly tuple/list encoded trees.
     """
-    return _doParse(source, eval_input)
+    st = _doParse(source, eval_input)
+    return space.wrap(st) 
+expr.unwrap_spec = [ObjSpace, str]
 
 # ______________________________________________________________________
 
-def suite (source):
+def suite (space, source):
     """suite
     Tries to mock the suite() function in the Python parser module, but returns
     one of those silly tuple/list encoded trees.
     """
-    return _doParse(source, file_input)
+    st = _doParse(source, file_input)
+    return space.wrap(st) 
+suite.unwrap_spec = [ObjSpace, str]
 
 # ______________________________________________________________________
 



More information about the Pypy-commit mailing list