[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pypy-svn
Subject:    [pypy-svn] r35171 - pypy/dist/pypy/rlib/parsing/test
From:       cfbolz () codespeak ! net
Date:       2006-11-30 16:04:43
Message-ID: 20061130160443.781BD10088 () code0 ! codespeak ! net
[Download RAW message or body]

Author: cfbolz
Date: Thu Nov 30 17:04:42 2006
New Revision: 35171

Modified:
   pypy/dist/pypy/rlib/parsing/test/test_ebnfparse.py
Log:
check in two of the exmaples of the docs as tests


Modified: pypy/dist/pypy/rlib/parsing/test/test_ebnfparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/test/test_ebnfparse.py	(original)
+++ pypy/dist/pypy/rlib/parsing/test/test_ebnfparse.py	Thu Nov 30 17:04:42 2006
@@ -27,6 +27,7 @@
     assert r == 22 * 12 + 44
     tree = parse("2*(3+5*2*(2+61))")
     assert tree.visit(MyEvalVisitor()) == 2 * (3 + 5 * 2 * (2 + 61))
+    tree = parse("12 + 4 * 5)")
 
 def test_long_inline_quotes():
     regexs, rules, transformer = parse_ebnf("""
@@ -407,3 +408,24 @@
     parse = make_parse_function(regexs, rules)
     py.test.raises(ParseError, parse, "x END")
     parse("y END")
+
+def test_example1():
+    regexs, rules, ToAST = parse_ebnf("""
+IGNORE: " ";
+n: "a" "b" "c" m;
+m: "(" <n> ")" | "d";
+    """)
+    parse = make_parse_function(regexs, rules)
+    t = parse("a b c (a b c d)")
+    t = ToAST().transform(t)
+
+def test_example2():
+    regexs, rules, ToAST = parse_ebnf("""
+IGNORE: " ";
+DECIMAL: "0|[1-9][0-9]*";
+list: DECIMAL >list< | DECIMAL;
+    """)
+    parse = make_parse_function(regexs, rules)
+    t = parse("1 2 3 4 5")
+    t = ToAST().transform(t)
+

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic