[pypy-svn] r65589 - pypy/branch/parser-compiler/pypy/interpreter/pyparser
benjamin at codespeak.net
benjamin at codespeak.net
Thu Jun 4 21:33:32 CEST 2009
Author: benjamin
Date: Thu Jun 4 21:33:26 2009
New Revision: 65589
Modified:
pypy/branch/parser-compiler/pypy/interpreter/pyparser/pythonutil.py
Log:
don't try to support creating parsers at runtime
Modified: pypy/branch/parser-compiler/pypy/interpreter/pyparser/pythonutil.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/interpreter/pyparser/pythonutil.py (original)
+++ pypy/branch/parser-compiler/pypy/interpreter/pyparser/pythonutil.py Thu Jun 4 21:33:26 2009
@@ -48,16 +48,17 @@
def build_parser(gramfile, parser=None):
- """reads a (EBNF) grammar definition and builds a parser for it"""
+ """NOT_RPYTHON
+ reads a (EBNF) grammar definition and builds a parser for it
+ """
if parser is None:
parser = Parser()
setup_tokens(parser)
- # XXX: clean up object dependencies
- from pypy.rlib.streamio import open_file_as_stream
- stream = open_file_as_stream(gramfile)
- grammardef = stream.readall()
- stream.close()
- assert isinstance(grammardef, str)
+ stream = open(gramfile, "r")
+ try:
+ grammardef = stream.read()
+ finally:
+ stream.close()
source = GrammarSource(GRAMMAR_GRAMMAR, grammardef)
builder = EBNFBuilder(GRAMMAR_GRAMMAR, dest_parser=parser)
GRAMMAR_GRAMMAR.root_rules['grammar'].match(source, builder)
More information about the Pypy-commit
mailing list