[pypy-svn] r38416 - in pypy/dist/pypy/rlib/parsing: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Sat Feb 10 22:13:55 CET 2007
Author: cfbolz
Date: Sat Feb 10 22:13:55 2007
New Revision: 38416
Modified:
pypy/dist/pypy/rlib/parsing/ebnfparse.py
pypy/dist/pypy/rlib/parsing/test/test_pythonparse.py
pypy/dist/pypy/rlib/parsing/test/test_regex.py
Log:
try to fix failures / skip a work in progress one. also make --view on py.test
in this dir work properly.
Modified: pypy/dist/pypy/rlib/parsing/ebnfparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/ebnfparse.py (original)
+++ pypy/dist/pypy/rlib/parsing/ebnfparse.py Sat Feb 10 22:13:55 2007
@@ -6,6 +6,7 @@
from pypy.rlib.parsing.regex import *
from pypy.rlib.parsing.deterministic import DFA
from pypy.rlib.parsing.lexer import Lexer, DummyLexer
+from pypy.rlib.objectmodel import we_are_translated
def make_ebnf_parser():
NONTERMINALNAME = parse_regex("([a-z]|_)[a-z0-9_]*")
@@ -83,6 +84,9 @@
def parse(s):
tokens = lexer.tokenize(s, eof=eof)
s = parser.parse(tokens)
+ if not we_are_translated():
+ if py.test.config.option.view:
+ s.view()
return s
return parse
@@ -287,6 +291,11 @@
self.emit("assert tree.symbol == %r" % (startsymbol, ))
self.emit("r = self.visit_%s(tree)" % (startsymbol, ))
self.emit("assert len(r) == 1")
+ self.start_block("if not we_are_translated():")
+ self.start_block("if py.test.config.option.view:")
+ self.emit("r[0].view()")
+ self.end_block("option.view")
+ self.end_block("we_are_translated")
self.emit("return r[0]")
self.end_block("transform")
self.end_block("ToAST")
@@ -294,7 +303,8 @@
code = "\n".join(self.code)
if print_code:
print code
- ns = {"RPythonVisitor": RPythonVisitor, "Nonterminal": Nonterminal}
+ ns = {"RPythonVisitor": RPythonVisitor, "Nonterminal": Nonterminal,
+ "we_are_translated": we_are_translated, "py": py}
exec py.code.Source(code).compile() in ns
ToAST = ns["ToAST"]
ToAST.__module__ = "pypy.rlib.parsing.ebnfparse"
Modified: pypy/dist/pypy/rlib/parsing/test/test_pythonparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/test/test_pythonparse.py (original)
+++ pypy/dist/pypy/rlib/parsing/test/test_pythonparse.py Sat Feb 10 22:13:55 2007
@@ -212,6 +212,7 @@
t = self.ToAST.transform(t)
def test_trailers(self):
+ py.test.skip("in progress")
t = self.parse("""
(a + b).foo[1 + i - j:](32, *args)
""")
@@ -237,7 +238,6 @@
"""
t = self.parse(source)
t = self.ToAST.transform(t)
- t.view()
def test_parse_this(self):
s = py.magic.autopath().read()
Modified: pypy/dist/pypy/rlib/parsing/test/test_regex.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/test/test_regex.py (original)
+++ pypy/dist/pypy/rlib/parsing/test/test_regex.py Sat Feb 10 22:13:55 2007
@@ -1,6 +1,7 @@
+import py
from pypy.rlib.parsing.regex import *
-def compile_rex(rex, view=False):
+def compile_rex(rex):
try:
from pypy.translator.interactive import Translation
except ImportError:
@@ -10,7 +11,7 @@
fn = fda.make_code()
t = Translation(fn)
t.backendopt([str], backend="c")
- if view:
+ if py.test.config.option.view:
t.view()
return t.compile_c()
@@ -98,7 +99,7 @@
assert recognize("101010")
assert recognize("101100")
assert recognize("110000")
- fn = compile_rex(rex, view=False)
+ fn = compile_rex(rex)
assert fn("1000000")
assert fn("101010")
assert fn("101100")
@@ -132,7 +133,7 @@
r = dfa.get_runner()
assert r.recognize("aASsdFAASaSFasdfaSFD")
assert not r.recognize("ASsdFAASaSFasdfaSFD")
- fn = compile_rex(atoms, view=False)
+ fn = compile_rex(atoms)
assert fn("a")
assert fn("aaaaaAAAAaAAzAzaslwer")
@@ -162,4 +163,4 @@
dfa = nfa.make_deterministic()
r = dfa.get_runner()
dfa.optimize()
- fn = compile_rex(all, view=False)
+ fn = compile_rex(all)
More information about the Pypy-commit
mailing list