Commits

Adrien Di Mascio  committed b7ffb01

renamed get_pyparser_for_version to make_pyparser

  • Participants
  • Parent commits fbe54d3
  • Branches ast-experiments

Comments (0)

Files changed (8)

File pypy/interpreter/pycompiler.py

          the whole source after having only added a new '\n')
     """
     def __init__(self, space):
-        from pyparser.pythonparse import get_pyparser_for_version
-        from pypy.tool.option import Options
+        from pyparser.pythonparse import make_pyparser
         PyCodeCompiler.__init__(self, space)
-        self.parser = get_pyparser_for_version(Options.version)
+        self.parser = make_pyparser()
         self.additional_rules = {}
 
     

File pypy/interpreter/pyparser/astbuilder.py

     """A builder that directly produce the AST"""
 
     def __init__(self, parser=None, debug=0, space=None):
+        # XXX: parser must become mandatory
         if parser is None:
             from pythonparse import PYTHON_PARSER
             parser = pythonparse.PYTHON_PARSER

File pypy/interpreter/pyparser/pythonparse.py

 
 
 
-def get_pyparser_for_version(version):
+def make_pyparser(version=Options.version):
     parser = PythonParser(predefined_symbols=symbol.sym_name)
     return build_parser_for_version(version, parser=parser)
 
 # unfortunately the command line options are not parsed yet
-debug_print( "Loading grammar %s" % Options.version )
+# debug_print( "Loading grammar %s" % Options.version )
 # XXX: remove PYTHON_PARSER
-PYTHON_PARSER = get_pyparser_for_version(Options.version)
+PYTHON_PARSER = make_pyparser()
 
 ## XXX BROKEN
 ## def grammar_rules( space ):

File pypy/interpreter/pyparser/pythonutil.py

 
 
 def pypy_parse(source, mode='exec', lineno=False):
-    from pypy.interpreter.pyparser.pythonparse import PythonParser, get_pyparser_for_version
+    from pypy.interpreter.pyparser.pythonparse import PythonParser, make_pyparser
     from pypy.interpreter.pyparser.astbuilder import AstBuilder
     # parser = build_parser_for_version("2.4", PythonParser())
-    parser = get_pyparser_for_version('2.4')
+    parser = make_pyparser('2.4')
     builder = TupleBuilder(parser)
     parser.parse_source(source, mode, builder)
     return builder.stack[-1].as_tuple(lineno)
 
 
 def source2ast(source, mode='exec', version='2.4', space=None):
-    from pypy.interpreter.pyparser.pythonparse import PythonParser, get_pyparser_for_version
+    from pypy.interpreter.pyparser.pythonparse import PythonParser, make_pyparser
     from pypy.interpreter.pyparser.astbuilder import AstBuilder
-    parser = get_pyparser_for_version(version)
+    parser = make_pyparser(version)
     builder = AstBuilder(parser, space=space)
     parser.parse_source(source, mode, builder)
     return builder

File pypy/interpreter/pyparser/test/test_astbuilder.py

 import os
-from pypy.tool.option import Options
 
 from pypy.interpreter.pyparser import pythonparse
 from pypy.interpreter.pyparser.astbuilder import AstBuilder
     builtin = dict(int=int, long=long, float=float, complex=complex)
 
 # Create parser from Grammar_stable, not current grammar.
-stable_parser = pythonparse.get_pyparser_for_version('stable')
-python_parser = pythonparse.get_pyparser_for_version(Options.version) # 'native') # 2.5a')
+stable_parser = pythonparse.make_pyparser('stable')
+python_parser = pythonparse.make_pyparser() # 'native') # 2.5a')
 
 def tuple_parse_expr(expr, target='single'):
     t = Transformer("dummyfile")

File pypy/interpreter/pyparser/test/test_astcompiler.py

     return rcode
 
 # Create parser from Grammar_stable, not current grammar.
-stable_parser = pythonparse.get_pyparser_for_version('stable')
+stable_parser = pythonparse.make_pyparser('stable')
 
 def compile_with_testcompiler(expr, mode='exec', space=FakeSpace()):
     mode2 = 'exec' # xxx exec: single not really tested

File pypy/interpreter/pyparser/test/test_pytokenizer.py

 from pypy.interpreter.pyparser.pythonlexer import Source, TokenError, \
      match_encoding_declaration
 from pypy.interpreter.pyparser.grammar import Token, GrammarElement
-from pypy.interpreter.pyparser.pythonparse import PYTHON_PARSER as P
+from pypy.interpreter.pyparser.pythonparse import make_pyparser
+
+P = make_pyparser()
 
 EQUAL = P.EQUAL
 ENDMARKER = P.ENDMARKER

File pypy/interpreter/stablecompiler/transformer.py

 # and replace OWNER, ORGANIZATION, and YEAR as appropriate.
 
 # make sure we import the parser with the correct grammar
-from pypy.interpreter.pyparser.pythonparse import get_pyparser_for_version
+from pypy.interpreter.pyparser.pythonparse import make_pyparser
 
 from pypy.interpreter.stablecompiler.ast import *
 import parser
 # stable_grammar, _ = pythonparse.get_grammar_file("stable")
 # stable_parser = pythonparse.python_grammar(stable_grammar)
 
-stable_parser = get_pyparser_for_version('stable')
+stable_parser = make_pyparser('stable')
 
 class symbol:
     pass