diff options
author | David Beazley <dave@dabeaz.com> | 2008-11-04 15:45:34 +0000 |
---|---|---|
committer | David Beazley <dave@dabeaz.com> | 2008-11-04 15:45:34 +0000 |
commit | c66982f8e7dc7de7bbb73c1e40699fd22aef5eac (patch) | |
tree | 40648cfefdb76a4ba9914378c6ff5c177cc3ecf5 /test | |
parent | 3d91085e98cd5d2ddd3822793ab33bbad8287f5c (diff) | |
download | ply-c66982f8e7dc7de7bbb73c1e40699fd22aef5eac.tar.gz |
Fixed a bug with negative stack indices
Diffstat (limited to 'test')
-rw-r--r-- | test/testyacc.py | 9 | ||||
-rw-r--r-- | test/yacc_nested.py | 33 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/testyacc.py b/test/testyacc.py index 4793986..08fb007 100644 --- a/test/testyacc.py +++ b/test/testyacc.py @@ -160,6 +160,15 @@ class YaccErrorWarningTests(unittest.TestCase): "yacc_missing1.py:24: Symbol 'location' used, but not defined as a token or a rule.\n" )) + def test_yacc_nested(self): + run_import("yacc_nested") + result = sys.stdout.getvalue() + self.assert_(check_expected(result, + "A\n" + "A\n" + "A\n", + )) + def test_yacc_nodoc(self): run_import("yacc_nodoc") result = sys.stderr.getvalue() diff --git a/test/yacc_nested.py b/test/yacc_nested.py new file mode 100644 index 0000000..4c85013 --- /dev/null +++ b/test/yacc_nested.py @@ -0,0 +1,33 @@ +import sys + +if ".." not in sys.path: sys.path.insert(0,"..") + +from ply import lex, yacc + +t_A = 'A' +t_B = 'B' +t_C = 'C' + +tokens = ('A', 'B', 'C') + +the_lexer = lex.lex() + +def t_error(t): + pass + +def p_error(p): + pass + +def p_start(t): + '''start : A nest C''' + pass + +def p_nest(t): + '''nest : B''' + print t[-1] + +the_parser = yacc.yacc(debug = False, write_tables = False) + +the_parser.parse('ABC', the_lexer) +the_parser.parse('ABC', the_lexer, tracking=True) +the_parser.parse('ABC', the_lexer, tracking=True, debug=1) |