From 44ebb8d3e27329e9f0b501897585359b4ab696f2 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Thu, 24 May 2007 21:54:51 -0700 Subject: Update to ply 2.3 ext/ply/ply/lex.py: ext/ply/ply/yacc.py: ext/ply/CHANGES: ext/ply/README: ext/ply/TODO: ext/ply/doc/ply.html: ext/ply/example/ansic/clex.py: ext/ply/example/ansic/cparse.py: ext/ply/example/calc/calc.py: ext/ply/example/hedit/hedit.py: ext/ply/example/optcalc/calc.py: ext/ply/test/README: ext/ply/test/calclex.py: ext/ply/test/lex_doc1.exp: ext/ply/test/lex_doc1.py: ext/ply/test/lex_dup1.exp: ext/ply/test/lex_dup1.py: ext/ply/test/lex_dup2.exp: ext/ply/test/lex_dup2.py: ext/ply/test/lex_dup3.exp: ext/ply/test/lex_dup3.py: ext/ply/test/lex_empty.py: ext/ply/test/lex_error1.py: ext/ply/test/lex_error2.py: ext/ply/test/lex_error3.exp: ext/ply/test/lex_error3.py: ext/ply/test/lex_error4.exp: ext/ply/test/lex_error4.py: ext/ply/test/lex_hedit.exp: ext/ply/test/lex_hedit.py: ext/ply/test/lex_ignore.exp: ext/ply/test/lex_ignore.py: ext/ply/test/lex_re1.exp: ext/ply/test/lex_re1.py: ext/ply/test/lex_rule1.py: ext/ply/test/lex_token1.py: ext/ply/test/lex_token2.py: ext/ply/test/lex_token3.py: ext/ply/test/lex_token4.py: ext/ply/test/lex_token5.exp: ext/ply/test/lex_token5.py: ext/ply/test/yacc_badargs.exp: ext/ply/test/yacc_badargs.py: ext/ply/test/yacc_badprec.exp: ext/ply/test/yacc_badprec.py: ext/ply/test/yacc_badprec2.exp: ext/ply/test/yacc_badprec2.py: ext/ply/test/yacc_badrule.exp: ext/ply/test/yacc_badrule.py: ext/ply/test/yacc_badtok.exp: ext/ply/test/yacc_badtok.py: ext/ply/test/yacc_dup.exp: ext/ply/test/yacc_dup.py: ext/ply/test/yacc_error1.exp: ext/ply/test/yacc_error1.py: ext/ply/test/yacc_error2.exp: ext/ply/test/yacc_error2.py: ext/ply/test/yacc_error3.exp: ext/ply/test/yacc_error3.py: ext/ply/test/yacc_inf.exp: ext/ply/test/yacc_inf.py: ext/ply/test/yacc_missing1.exp: ext/ply/test/yacc_missing1.py: ext/ply/test/yacc_nodoc.exp: ext/ply/test/yacc_nodoc.py: ext/ply/test/yacc_noerror.exp: ext/ply/test/yacc_noerror.py: ext/ply/test/yacc_nop.exp: ext/ply/test/yacc_nop.py: ext/ply/test/yacc_notfunc.exp: ext/ply/test/yacc_notfunc.py: ext/ply/test/yacc_notok.exp: ext/ply/test/yacc_notok.py: ext/ply/test/yacc_rr.exp: ext/ply/test/yacc_rr.py: ext/ply/test/yacc_simple.exp: ext/ply/test/yacc_simple.py: ext/ply/test/yacc_sr.exp: ext/ply/test/yacc_sr.py: ext/ply/test/yacc_term1.exp: ext/ply/test/yacc_term1.py: ext/ply/test/yacc_unused.exp: ext/ply/test/yacc_unused.py: ext/ply/test/yacc_uprec.exp: ext/ply/test/yacc_uprec.py: Import patch ply.diff src/arch/isa_parser.py: everything is now within the ply package --HG-- rename : ext/ply/lex.py => ext/ply/ply/lex.py rename : ext/ply/yacc.py => ext/ply/ply/yacc.py extra : convert_revision : fca8deabd5c095bdeabd52a1f236ae1404ef106e --- ext/ply/test/README | 6 ++-- ext/ply/test/calclex.py | 7 +++-- ext/ply/test/cleanup.sh | 4 +++ ext/ply/test/lex_doc1.exp | 2 +- ext/ply/test/lex_doc1.py | 5 ++- ext/ply/test/lex_dup1.exp | 2 +- ext/ply/test/lex_dup1.py | 6 ++-- ext/ply/test/lex_dup2.exp | 2 +- ext/ply/test/lex_dup2.py | 6 ++-- ext/ply/test/lex_dup3.exp | 2 +- ext/ply/test/lex_dup3.py | 6 ++-- ext/ply/test/lex_empty.py | 6 ++-- ext/ply/test/lex_error1.py | 6 ++-- ext/ply/test/lex_error2.py | 6 ++-- ext/ply/test/lex_error3.exp | 2 +- ext/ply/test/lex_error3.py | 6 ++-- ext/ply/test/lex_error4.exp | 2 +- ext/ply/test/lex_error4.py | 6 ++-- ext/ply/test/lex_hedit.exp | 6 ++-- ext/ply/test/lex_hedit.py | 7 +++-- ext/ply/test/lex_ignore.exp | 7 ++++- ext/ply/test/lex_ignore.py | 6 ++-- ext/ply/test/lex_ignore2.exp | 1 + ext/ply/test/lex_ignore2.py | 29 ++++++++++++++++++ ext/ply/test/lex_nowarn.py | 30 ++++++++++++++++++ ext/ply/test/lex_re1.exp | 5 +++ ext/ply/test/lex_re1.py | 6 ++-- ext/ply/test/lex_re2.exp | 7 +++++ ext/ply/test/lex_re2.py | 27 +++++++++++++++++ ext/ply/test/lex_re3.exp | 8 +++++ ext/ply/test/lex_re3.py | 29 ++++++++++++++++++ ext/ply/test/lex_rule1.py | 6 ++-- ext/ply/test/lex_state1.exp | 7 +++++ ext/ply/test/lex_state1.py | 40 ++++++++++++++++++++++++ ext/ply/test/lex_state2.exp | 8 +++++ ext/ply/test/lex_state2.py | 40 ++++++++++++++++++++++++ ext/ply/test/lex_state3.exp | 8 +++++ ext/ply/test/lex_state3.py | 42 ++++++++++++++++++++++++++ ext/ply/test/lex_state4.exp | 7 +++++ ext/ply/test/lex_state4.py | 41 +++++++++++++++++++++++++ ext/ply/test/lex_state5.exp | 7 +++++ ext/ply/test/lex_state5.py | 42 ++++++++++++++++++++++++++ ext/ply/test/lex_state_noerror.exp | 1 + ext/ply/test/lex_state_noerror.py | 41 +++++++++++++++++++++++++ ext/ply/test/lex_state_norule.exp | 7 +++++ ext/ply/test/lex_state_norule.py | 42 ++++++++++++++++++++++++++ ext/ply/test/lex_state_try.exp | 7 +++++ ext/ply/test/lex_state_try.py | 48 +++++++++++++++++++++++++++++ ext/ply/test/lex_token1.py | 6 ++-- ext/ply/test/lex_token2.py | 6 ++-- ext/ply/test/lex_token3.py | 7 +++-- ext/ply/test/lex_token4.py | 6 ++-- ext/ply/test/lex_token5.exp | 2 +- ext/ply/test/lex_token5.py | 6 ++-- ext/ply/test/rununit.py | 62 ++++++++++++++++++++++++++++++++++++++ ext/ply/test/yacc_badargs.exp | 6 ++-- ext/ply/test/yacc_badargs.py | 3 +- ext/ply/test/yacc_badprec.exp | 2 +- ext/ply/test/yacc_badprec.py | 4 ++- ext/ply/test/yacc_badprec2.exp | 4 +-- ext/ply/test/yacc_badprec2.py | 4 ++- ext/ply/test/yacc_badrule.exp | 10 +++--- ext/ply/test/yacc_badrule.py | 4 ++- ext/ply/test/yacc_badtok.exp | 2 +- ext/ply/test/yacc_badtok.py | 4 ++- ext/ply/test/yacc_dup.exp | 4 +-- ext/ply/test/yacc_dup.py | 4 ++- ext/ply/test/yacc_error1.exp | 2 +- ext/ply/test/yacc_error1.py | 4 ++- ext/ply/test/yacc_error2.exp | 2 +- ext/ply/test/yacc_error2.py | 4 ++- ext/ply/test/yacc_error3.exp | 2 +- ext/ply/test/yacc_error3.py | 4 ++- ext/ply/test/yacc_inf.exp | 2 +- ext/ply/test/yacc_inf.py | 4 ++- ext/ply/test/yacc_missing1.exp | 4 +-- ext/ply/test/yacc_missing1.py | 4 ++- ext/ply/test/yacc_nodoc.exp | 4 +-- ext/ply/test/yacc_nodoc.py | 4 ++- ext/ply/test/yacc_noerror.exp | 2 +- ext/ply/test/yacc_noerror.py | 5 ++- ext/ply/test/yacc_nop.exp | 4 +-- ext/ply/test/yacc_nop.py | 4 ++- ext/ply/test/yacc_notfunc.exp | 2 +- ext/ply/test/yacc_notfunc.py | 4 ++- ext/ply/test/yacc_notok.exp | 2 +- ext/ply/test/yacc_notok.py | 4 ++- ext/ply/test/yacc_rr.exp | 2 +- ext/ply/test/yacc_rr.py | 4 ++- ext/ply/test/yacc_simple.exp | 2 +- ext/ply/test/yacc_simple.py | 4 ++- ext/ply/test/yacc_sr.exp | 2 +- ext/ply/test/yacc_sr.py | 4 ++- ext/ply/test/yacc_term1.exp | 4 +-- ext/ply/test/yacc_term1.py | 4 ++- ext/ply/test/yacc_unused.exp | 4 +-- ext/ply/test/yacc_unused.py | 4 ++- ext/ply/test/yacc_uprec.exp | 4 +-- ext/ply/test/yacc_uprec.py | 4 ++- 99 files changed, 791 insertions(+), 108 deletions(-) create mode 100644 ext/ply/test/cleanup.sh create mode 100644 ext/ply/test/lex_ignore2.exp create mode 100644 ext/ply/test/lex_ignore2.py create mode 100644 ext/ply/test/lex_nowarn.py create mode 100644 ext/ply/test/lex_re2.exp create mode 100644 ext/ply/test/lex_re2.py create mode 100644 ext/ply/test/lex_re3.exp create mode 100644 ext/ply/test/lex_re3.py create mode 100644 ext/ply/test/lex_state1.exp create mode 100644 ext/ply/test/lex_state1.py create mode 100644 ext/ply/test/lex_state2.exp create mode 100644 ext/ply/test/lex_state2.py create mode 100644 ext/ply/test/lex_state3.exp create mode 100644 ext/ply/test/lex_state3.py create mode 100644 ext/ply/test/lex_state4.exp create mode 100644 ext/ply/test/lex_state4.py create mode 100644 ext/ply/test/lex_state5.exp create mode 100644 ext/ply/test/lex_state5.py create mode 100644 ext/ply/test/lex_state_noerror.exp create mode 100644 ext/ply/test/lex_state_noerror.py create mode 100644 ext/ply/test/lex_state_norule.exp create mode 100644 ext/ply/test/lex_state_norule.py create mode 100644 ext/ply/test/lex_state_try.exp create mode 100644 ext/ply/test/lex_state_try.py create mode 100644 ext/ply/test/rununit.py (limited to 'ext/ply/test') diff --git a/ext/ply/test/README b/ext/ply/test/README index bca748497..aac12b058 100644 --- a/ext/ply/test/README +++ b/ext/ply/test/README @@ -4,6 +4,8 @@ conditions. To run: $ python testlex.py . $ python testyacc.py . -(make sure lex.py and yacc.py exist in this directory before -running the tests). +The tests can also be run using the Python unittest module. + $ python rununit.py + +The script 'cleanup.sh' cleans up this directory to its original state. diff --git a/ext/ply/test/calclex.py b/ext/ply/test/calclex.py index f8eb91a09..d3e873266 100644 --- a/ext/ply/test/calclex.py +++ b/ext/ply/test/calclex.py @@ -1,6 +1,10 @@ # ----------------------------------------------------------------------------- # calclex.py # ----------------------------------------------------------------------------- +import sys + +sys.path.append("..") +import ply.lex as lex tokens = ( 'NAME','NUMBER', @@ -36,10 +40,9 @@ def t_newline(t): def t_error(t): print "Illegal character '%s'" % t.value[0] - t.skip(1) + t.lexer.skip(1) # Build the lexer -import lex lex.lex() diff --git a/ext/ply/test/cleanup.sh b/ext/ply/test/cleanup.sh new file mode 100644 index 000000000..d7d99b65f --- /dev/null +++ b/ext/ply/test/cleanup.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +rm -f *~ *.pyc *.dif *.out + diff --git a/ext/ply/test/lex_doc1.exp b/ext/ply/test/lex_doc1.exp index 29381911d..5b63c1e91 100644 --- a/ext/ply/test/lex_doc1.exp +++ b/ext/ply/test/lex_doc1.exp @@ -1 +1 @@ -./lex_doc1.py:15: No regular expression defined for rule 't_NUMBER' +./lex_doc1.py:18: No regular expression defined for rule 't_NUMBER' diff --git a/ext/ply/test/lex_doc1.py b/ext/ply/test/lex_doc1.py index fb0fb885e..3951b5c5d 100644 --- a/ext/ply/test/lex_doc1.py +++ b/ext/ply/test/lex_doc1.py @@ -2,7 +2,10 @@ # # Missing documentation string -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", diff --git a/ext/ply/test/lex_dup1.exp b/ext/ply/test/lex_dup1.exp index 22bca3190..2098a40e5 100644 --- a/ext/ply/test/lex_dup1.exp +++ b/ext/ply/test/lex_dup1.exp @@ -1,2 +1,2 @@ -./lex_dup1.py:17: Rule t_NUMBER redefined. Previously defined on line 15 +./lex_dup1.py:20: Rule t_NUMBER redefined. Previously defined on line 18 SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_dup1.py b/ext/ply/test/lex_dup1.py index 88bbe00e9..68f80925b 100644 --- a/ext/ply/test/lex_dup1.py +++ b/ext/ply/test/lex_dup1.py @@ -2,7 +2,10 @@ # # Duplicated rule specifiers -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -19,7 +22,6 @@ t_NUMBER = r'\d+' def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_dup2.exp b/ext/ply/test/lex_dup2.exp index 883bdad46..d327cfe47 100644 --- a/ext/ply/test/lex_dup2.exp +++ b/ext/ply/test/lex_dup2.exp @@ -1,2 +1,2 @@ -./lex_dup2.py:19: Rule t_NUMBER redefined. Previously defined on line 15 +./lex_dup2.py:22: Rule t_NUMBER redefined. Previously defined on line 18 SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_dup2.py b/ext/ply/test/lex_dup2.py index 65e0b21a2..f4d346e75 100644 --- a/ext/ply/test/lex_dup2.py +++ b/ext/ply/test/lex_dup2.py @@ -2,7 +2,10 @@ # # Duplicated rule specifiers -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -23,7 +26,6 @@ def t_NUMBER(t): def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_dup3.exp b/ext/ply/test/lex_dup3.exp index 916612aa1..ec0680c6c 100644 --- a/ext/ply/test/lex_dup3.exp +++ b/ext/ply/test/lex_dup3.exp @@ -1,2 +1,2 @@ -./lex_dup3.py:17: Rule t_NUMBER redefined. Previously defined on line 15 +./lex_dup3.py:20: Rule t_NUMBER redefined. Previously defined on line 18 SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_dup3.py b/ext/ply/test/lex_dup3.py index 424101823..e17b52059 100644 --- a/ext/ply/test/lex_dup3.py +++ b/ext/ply/test/lex_dup3.py @@ -2,7 +2,10 @@ # # Duplicated rule specifiers -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -21,7 +24,6 @@ def t_NUMBER(t): def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_empty.py b/ext/ply/test/lex_empty.py index 6472832f1..96625f732 100644 --- a/ext/ply/test/lex_empty.py +++ b/ext/ply/test/lex_empty.py @@ -2,7 +2,10 @@ # # No rules defined -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -10,7 +13,6 @@ tokens = [ "NUMBER", ] -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_error1.py b/ext/ply/test/lex_error1.py index ed7980346..a99d9bedf 100644 --- a/ext/ply/test/lex_error1.py +++ b/ext/ply/test/lex_error1.py @@ -2,7 +2,10 @@ # # Missing t_error() rule -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -14,7 +17,6 @@ t_PLUS = r'\+' t_MINUS = r'-' t_NUMBER = r'\d+' -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_error2.py b/ext/ply/test/lex_error2.py index 80020f72b..a59c8d454 100644 --- a/ext/ply/test/lex_error2.py +++ b/ext/ply/test/lex_error2.py @@ -2,7 +2,10 @@ # # t_error defined, but not function -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -16,7 +19,6 @@ t_NUMBER = r'\d+' t_error = "foo" -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_error3.exp b/ext/ply/test/lex_error3.exp index 936828f93..1b482bf62 100644 --- a/ext/ply/test/lex_error3.exp +++ b/ext/ply/test/lex_error3.exp @@ -1,2 +1,2 @@ -./lex_error3.py:17: Rule 't_error' requires an argument. +./lex_error3.py:20: Rule 't_error' requires an argument. SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_error3.py b/ext/ply/test/lex_error3.py index 46facf589..584600f3b 100644 --- a/ext/ply/test/lex_error3.py +++ b/ext/ply/test/lex_error3.py @@ -2,7 +2,10 @@ # # t_error defined as function, but with wrong # args -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -17,7 +20,6 @@ t_NUMBER = r'\d+' def t_error(): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_error4.exp b/ext/ply/test/lex_error4.exp index 242516576..98505a232 100644 --- a/ext/ply/test/lex_error4.exp +++ b/ext/ply/test/lex_error4.exp @@ -1,2 +1,2 @@ -./lex_error4.py:17: Rule 't_error' has too many arguments. +./lex_error4.py:20: Rule 't_error' has too many arguments. SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_error4.py b/ext/ply/test/lex_error4.py index d777fee84..d05de7490 100644 --- a/ext/ply/test/lex_error4.py +++ b/ext/ply/test/lex_error4.py @@ -2,7 +2,10 @@ # # t_error defined as function, but too many args -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -17,7 +20,6 @@ t_NUMBER = r'\d+' def t_error(t,s): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_hedit.exp b/ext/ply/test/lex_hedit.exp index 0b09827c6..7b27dcb57 100644 --- a/ext/ply/test/lex_hedit.exp +++ b/ext/ply/test/lex_hedit.exp @@ -1,3 +1,3 @@ -(H_EDIT_DESCRIPTOR,'abc',1) -(H_EDIT_DESCRIPTOR,'abcdefghij',1) -(H_EDIT_DESCRIPTOR,'xy',1) +(H_EDIT_DESCRIPTOR,'abc',1,0) +(H_EDIT_DESCRIPTOR,'abcdefghij',1,6) +(H_EDIT_DESCRIPTOR,'xy',1,20) diff --git a/ext/ply/test/lex_hedit.py b/ext/ply/test/lex_hedit.py index 68f9fcbd1..9949549c4 100644 --- a/ext/ply/test/lex_hedit.py +++ b/ext/ply/test/lex_hedit.py @@ -13,6 +13,10 @@ # This example shows how to modify the state of the lexer to parse # such tokens # ----------------------------------------------------------------------------- +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = ( 'H_EDIT_DESCRIPTOR', @@ -33,10 +37,9 @@ def t_H_EDIT_DESCRIPTOR(t): def t_error(t): print "Illegal character '%s'" % t.value[0] - t.skip(1) + t.lexer.skip(1) # Build the lexer -import lex lex.lex() lex.runmain(data="3Habc 10Habcdefghij 2Hxy") diff --git a/ext/ply/test/lex_ignore.exp b/ext/ply/test/lex_ignore.exp index c3b04a154..6b6b67cdc 100644 --- a/ext/ply/test/lex_ignore.exp +++ b/ext/ply/test/lex_ignore.exp @@ -1,2 +1,7 @@ -./lex_ignore.py:17: Rule 't_ignore' must be defined as a string. +./lex_ignore.py:20: Rule 't_ignore' must be defined as a string. +Traceback (most recent call last): + File "./lex_ignore.py", line 29, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_ignore.py b/ext/ply/test/lex_ignore.py index 49c303f81..94b026693 100644 --- a/ext/ply/test/lex_ignore.py +++ b/ext/ply/test/lex_ignore.py @@ -2,7 +2,10 @@ # # Improperly specific ignore declaration -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -22,7 +25,6 @@ def t_error(t): pass import sys -sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_ignore2.exp b/ext/ply/test/lex_ignore2.exp new file mode 100644 index 000000000..0eb6bf266 --- /dev/null +++ b/ext/ply/test/lex_ignore2.exp @@ -0,0 +1 @@ +lex: Warning. t_ignore contains a literal backslash '\' diff --git a/ext/ply/test/lex_ignore2.py b/ext/ply/test/lex_ignore2.py new file mode 100644 index 000000000..fc95bd1e5 --- /dev/null +++ b/ext/ply/test/lex_ignore2.py @@ -0,0 +1,29 @@ +# lex_token.py +# +# ignore declaration as a raw string + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +t_ignore = r' \t' + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_nowarn.py b/ext/ply/test/lex_nowarn.py new file mode 100644 index 000000000..d60d31c53 --- /dev/null +++ b/ext/ply/test/lex_nowarn.py @@ -0,0 +1,30 @@ +# lex_token.py +# +# Missing t_error() rule + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + "NUMBER", + ] + +states = (('foo','exclusive'),) + +t_ignore = ' \t' +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +t_foo_NUMBER = r'\d+' + +sys.tracebacklimit = 0 + +lex.lex(nowarn=1) + + diff --git a/ext/ply/test/lex_re1.exp b/ext/ply/test/lex_re1.exp index 634eefefe..4d54f4b89 100644 --- a/ext/ply/test/lex_re1.exp +++ b/ext/ply/test/lex_re1.exp @@ -1,2 +1,7 @@ lex: Invalid regular expression for rule 't_NUMBER'. unbalanced parenthesis +Traceback (most recent call last): + File "./lex_re1.py", line 25, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_re1.py b/ext/ply/test/lex_re1.py index 4a055ad72..9e544fe0d 100644 --- a/ext/ply/test/lex_re1.py +++ b/ext/ply/test/lex_re1.py @@ -2,7 +2,10 @@ # # Bad regular expression in a string -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -18,7 +21,6 @@ def t_error(t): pass import sys -sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_re2.exp b/ext/ply/test/lex_re2.exp new file mode 100644 index 000000000..a4e2e8920 --- /dev/null +++ b/ext/ply/test/lex_re2.exp @@ -0,0 +1,7 @@ +lex: Regular expression for rule 't_PLUS' matches empty string. +Traceback (most recent call last): + File "./lex_re2.py", line 25, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_re2.py b/ext/ply/test/lex_re2.py new file mode 100644 index 000000000..522b41592 --- /dev/null +++ b/ext/ply/test/lex_re2.py @@ -0,0 +1,27 @@ +# lex_token.py +# +# Regular expression rule matches empty string + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +t_PLUS = r'\+?' +t_MINUS = r'-' +t_NUMBER = r'(\d+)' + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_re3.exp b/ext/ply/test/lex_re3.exp new file mode 100644 index 000000000..b9ada216d --- /dev/null +++ b/ext/ply/test/lex_re3.exp @@ -0,0 +1,8 @@ +lex: Invalid regular expression for rule 't_POUND'. unbalanced parenthesis +lex: Make sure '#' in rule 't_POUND' is escaped with '\#'. +Traceback (most recent call last): + File "./lex_re3.py", line 27, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_re3.py b/ext/ply/test/lex_re3.py new file mode 100644 index 000000000..099e1568c --- /dev/null +++ b/ext/ply/test/lex_re3.py @@ -0,0 +1,29 @@ +# lex_token.py +# +# Regular expression rule matches empty string + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + "POUND", + ] + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'(\d+)' +t_POUND = r'#' + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_rule1.py b/ext/ply/test/lex_rule1.py index ff3764ea1..e49a15bba 100644 --- a/ext/ply/test/lex_rule1.py +++ b/ext/ply/test/lex_rule1.py @@ -2,7 +2,10 @@ # # Rule defined as some other type -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -17,7 +20,6 @@ t_NUMBER = 1 def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_state1.exp b/ext/ply/test/lex_state1.exp new file mode 100644 index 000000000..facad03cc --- /dev/null +++ b/ext/ply/test/lex_state1.exp @@ -0,0 +1,7 @@ +lex: states must be defined as a tuple or list. +Traceback (most recent call last): + File "./lex_state1.py", line 38, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state1.py b/ext/ply/test/lex_state1.py new file mode 100644 index 000000000..887bc2345 --- /dev/null +++ b/ext/ply/test/lex_state1.py @@ -0,0 +1,40 @@ +# lex_state1.py +# +# Bad state declaration + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +states = 'comment' + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state2.exp b/ext/ply/test/lex_state2.exp new file mode 100644 index 000000000..8b042515a --- /dev/null +++ b/ext/ply/test/lex_state2.exp @@ -0,0 +1,8 @@ +lex: invalid state specifier 'comment'. Must be a tuple (statename,'exclusive|inclusive') +lex: invalid state specifier 'example'. Must be a tuple (statename,'exclusive|inclusive') +Traceback (most recent call last): + File "./lex_state2.py", line 38, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state2.py b/ext/ply/test/lex_state2.py new file mode 100644 index 000000000..3053c7110 --- /dev/null +++ b/ext/ply/test/lex_state2.py @@ -0,0 +1,40 @@ +# lex_state2.py +# +# Bad state declaration + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +states = ('comment','example') + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state3.exp b/ext/ply/test/lex_state3.exp new file mode 100644 index 000000000..53ab57ff1 --- /dev/null +++ b/ext/ply/test/lex_state3.exp @@ -0,0 +1,8 @@ +lex: state name 1 must be a string +lex: No rules defined for state 'example' +Traceback (most recent call last): + File "./lex_state3.py", line 40, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state3.py b/ext/ply/test/lex_state3.py new file mode 100644 index 000000000..bb22d241e --- /dev/null +++ b/ext/ply/test/lex_state3.py @@ -0,0 +1,42 @@ +# lex_state2.py +# +# Bad state declaration + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = ((comment, 'inclusive'), + ('example', 'exclusive')) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state4.exp b/ext/ply/test/lex_state4.exp new file mode 100644 index 000000000..412ae8f8a --- /dev/null +++ b/ext/ply/test/lex_state4.exp @@ -0,0 +1,7 @@ +lex: state type for state comment must be 'inclusive' or 'exclusive' +Traceback (most recent call last): + File "./lex_state4.py", line 39, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state4.py b/ext/ply/test/lex_state4.py new file mode 100644 index 000000000..3815135b4 --- /dev/null +++ b/ext/ply/test/lex_state4.py @@ -0,0 +1,41 @@ +# lex_state2.py +# +# Bad state declaration + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclsive'),) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state5.exp b/ext/ply/test/lex_state5.exp new file mode 100644 index 000000000..8eeae5641 --- /dev/null +++ b/ext/ply/test/lex_state5.exp @@ -0,0 +1,7 @@ +lex: state 'comment' already defined. +Traceback (most recent call last): + File "./lex_state5.py", line 40, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state5.py b/ext/ply/test/lex_state5.py new file mode 100644 index 000000000..58718538c --- /dev/null +++ b/ext/ply/test/lex_state5.py @@ -0,0 +1,42 @@ +# lex_state2.py +# +# Bad state declaration + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclusive'), + ('comment', 'exclusive')) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state_noerror.exp b/ext/ply/test/lex_state_noerror.exp new file mode 100644 index 000000000..e14149f18 --- /dev/null +++ b/ext/ply/test/lex_state_noerror.exp @@ -0,0 +1 @@ +lex: Warning. no error rule is defined for exclusive state 'comment' diff --git a/ext/ply/test/lex_state_noerror.py b/ext/ply/test/lex_state_noerror.py new file mode 100644 index 000000000..3fda7da49 --- /dev/null +++ b/ext/ply/test/lex_state_noerror.py @@ -0,0 +1,41 @@ +# lex_state2.py +# +# Declaration of a state for which no rules are defined + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclusive'),) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state_norule.exp b/ext/ply/test/lex_state_norule.exp new file mode 100644 index 000000000..7097d2a3a --- /dev/null +++ b/ext/ply/test/lex_state_norule.exp @@ -0,0 +1,7 @@ +lex: No rules defined for state 'example' +Traceback (most recent call last): + File "./lex_state_norule.py", line 40, in + lex.lex() + File "../ply/lex.py", line 759, in lex + raise SyntaxError,"lex: Unable to build lexer." +SyntaxError: lex: Unable to build lexer. diff --git a/ext/ply/test/lex_state_norule.py b/ext/ply/test/lex_state_norule.py new file mode 100644 index 000000000..2f6cabc51 --- /dev/null +++ b/ext/ply/test/lex_state_norule.py @@ -0,0 +1,42 @@ +# lex_state2.py +# +# Declaration of a state for which no rules are defined + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclusive'), + ('example', 'exclusive')) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +import sys + +lex.lex() + + diff --git a/ext/ply/test/lex_state_try.exp b/ext/ply/test/lex_state_try.exp new file mode 100644 index 000000000..11768b893 --- /dev/null +++ b/ext/ply/test/lex_state_try.exp @@ -0,0 +1,7 @@ +(NUMBER,'3',1,0) +(PLUS,'+',1,2) +(NUMBER,'4',1,4) +Entering comment state +comment body LexToken(body_part,'This is a comment */',1,9) +(PLUS,'+',1,30) +(NUMBER,'10',1,32) diff --git a/ext/ply/test/lex_state_try.py b/ext/ply/test/lex_state_try.py new file mode 100644 index 000000000..a2206cbc3 --- /dev/null +++ b/ext/ply/test/lex_state_try.py @@ -0,0 +1,48 @@ +# lex_state2.py +# +# Declaration of a state for which no rules are defined + +import sys +sys.path.insert(0,"..") + +import ply.lex as lex + +tokens = [ + "PLUS", + "MINUS", + "NUMBER", + ] + +comment = 1 +states = (('comment', 'exclusive'),) + +t_PLUS = r'\+' +t_MINUS = r'-' +t_NUMBER = r'\d+' + +t_ignore = " \t" + +# Comments +def t_comment(t): + r'/\*' + t.lexer.begin('comment') + print "Entering comment state" + +def t_comment_body_part(t): + r'(.|\n)*\*/' + print "comment body", t + t.lexer.begin('INITIAL') + +def t_error(t): + pass + +t_comment_error = t_error +t_comment_ignore = t_ignore + +import sys + +lex.lex() + +data = "3 + 4 /* This is a comment */ + 10" + +lex.runmain(data=data) diff --git a/ext/ply/test/lex_token1.py b/ext/ply/test/lex_token1.py index e8eca2b63..380c31ce1 100644 --- a/ext/ply/test/lex_token1.py +++ b/ext/ply/test/lex_token1.py @@ -2,7 +2,10 @@ # # Tests for absence of tokens variable -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex t_PLUS = r'\+' t_MINUS = r'-' @@ -11,7 +14,6 @@ t_NUMBER = r'\d+' def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_token2.py b/ext/ply/test/lex_token2.py index 38b34dabe..87db8a0ab 100644 --- a/ext/ply/test/lex_token2.py +++ b/ext/ply/test/lex_token2.py @@ -2,7 +2,10 @@ # # Tests for tokens of wrong type -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = "PLUS MINUS NUMBER" @@ -13,7 +16,6 @@ t_NUMBER = r'\d+' def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_token3.py b/ext/ply/test/lex_token3.py index 909f9180d..27ce9476d 100644 --- a/ext/ply/test/lex_token3.py +++ b/ext/ply/test/lex_token3.py @@ -2,7 +2,10 @@ # # tokens is right type, but is missing a token for one rule -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -16,7 +19,7 @@ t_NUMBER = r'\d+' def t_error(t): pass -import sys + sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_token4.py b/ext/ply/test/lex_token4.py index d77d1662c..612ff13c2 100644 --- a/ext/ply/test/lex_token4.py +++ b/ext/ply/test/lex_token4.py @@ -2,7 +2,10 @@ # # Bad token name -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -18,7 +21,6 @@ t_NUMBER = r'\d+' def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/lex_token5.exp b/ext/ply/test/lex_token5.exp index d7bcb2e7c..2f038890a 100644 --- a/ext/ply/test/lex_token5.exp +++ b/ext/ply/test/lex_token5.exp @@ -1 +1 @@ -lex.LexError: ./lex_token5.py:16: Rule 't_NUMBER' returned an unknown token type 'NUM' +ply.lex.LexError: ./lex_token5.py:19: Rule 't_NUMBER' returned an unknown token type 'NUM' diff --git a/ext/ply/test/lex_token5.py b/ext/ply/test/lex_token5.py index d9b0c96aa..77fabdee9 100644 --- a/ext/ply/test/lex_token5.py +++ b/ext/ply/test/lex_token5.py @@ -2,7 +2,10 @@ # # Return a bad token name -import lex +import sys +sys.path.insert(0,"..") + +import ply.lex as lex tokens = [ "PLUS", @@ -21,7 +24,6 @@ def t_NUMBER(t): def t_error(t): pass -import sys sys.tracebacklimit = 0 lex.lex() diff --git a/ext/ply/test/rununit.py b/ext/ply/test/rununit.py new file mode 100644 index 000000000..cb7a2298b --- /dev/null +++ b/ext/ply/test/rununit.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +'''Script to run all tests using python "unittest" module''' + +__author__ = "Miki Tebeka " + +from unittest import TestCase, main, makeSuite, TestSuite +from os import popen, environ, remove +from glob import glob +from sys import executable, argv +from os.path import isfile, basename, splitext + +# Add path to lex.py and yacc.py +environ["PYTHONPATH"] = ".." + +class PLYTest(TestCase): + '''General test case for PLY test''' + def _runtest(self, filename): + '''Run a single test file an compare result''' + exp_file = filename.replace(".py", ".exp") + self.failUnless(isfile(exp_file), "can't find %s" % exp_file) + pipe = popen("%s %s 2>&1" % (executable, filename)) + out = pipe.read().strip() + self.failUnlessEqual(out, open(exp_file).read().strip()) + + +class LexText(PLYTest): + '''Testing Lex''' + pass + +class YaccTest(PLYTest): + '''Testing Yacc''' + + def tearDown(self): + '''Cleanup parsetab.py[c] file''' + for ext in (".py", ".pyc"): + fname = "parsetab%s" % ext + if isfile(fname): + remove(fname) + +def add_test(klass, filename): + '''Add a test to TestCase class''' + def t(self): + self._runtest(filename) + # Test name is test_FILENAME without the ./ and without the .py + setattr(klass, "test_%s" % (splitext(basename(filename))[0]), t) + +# Add lex tests +for file in glob("./lex_*.py"): + add_test(LexText, file) +lex_suite = makeSuite(LexText, "test_") + +# Add yacc tests +for file in glob("./yacc_*.py"): + add_test(YaccTest, file) +yacc_suite = makeSuite(YaccTest, "test_") + +# All tests suite +test_suite = TestSuite((lex_suite, yacc_suite)) + +if __name__ == "__main__": + main() + diff --git a/ext/ply/test/yacc_badargs.exp b/ext/ply/test/yacc_badargs.exp index b145c51f2..e99467659 100644 --- a/ext/ply/test/yacc_badargs.exp +++ b/ext/ply/test/yacc_badargs.exp @@ -1,3 +1,3 @@ -./yacc_badargs.py:21: Rule 'p_statement_assign' has too many arguments. -./yacc_badargs.py:25: Rule 'p_statement_expr' requires an argument. -yacc.YaccError: Unable to construct parser. +./yacc_badargs.py:23: Rule 'p_statement_assign' has too many arguments. +./yacc_badargs.py:27: Rule 'p_statement_expr' requires an argument. +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_badargs.py b/ext/ply/test/yacc_badargs.py index 12075efcc..810e5298a 100644 --- a/ext/ply/test/yacc_badargs.py +++ b/ext/ply/test/yacc_badargs.py @@ -5,6 +5,8 @@ # ----------------------------------------------------------------------------- import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc from calclex import tokens @@ -59,7 +61,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_badprec.exp b/ext/ply/test/yacc_badprec.exp index 7764b0246..f4f574b99 100644 --- a/ext/ply/test/yacc_badprec.exp +++ b/ext/ply/test/yacc_badprec.exp @@ -1 +1 @@ -yacc.YaccError: precedence must be a list or tuple. +ply.yacc.YaccError: precedence must be a list or tuple. diff --git a/ext/ply/test/yacc_badprec.py b/ext/ply/test/yacc_badprec.py index 55bf7720d..8f64652e6 100644 --- a/ext/ply/test/yacc_badprec.py +++ b/ext/ply/test/yacc_badprec.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -55,7 +58,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_badprec2.exp b/ext/ply/test/yacc_badprec2.exp index 1df1427b2..8fac075ce 100644 --- a/ext/ply/test/yacc_badprec2.exp +++ b/ext/ply/test/yacc_badprec2.exp @@ -1,3 +1,3 @@ yacc: Invalid precedence table. -yacc: Generating SLR parsing table... -yacc: 4 shift/reduce conflicts +yacc: Generating LALR parsing table... +yacc: 8 shift/reduce conflicts diff --git a/ext/ply/test/yacc_badprec2.py b/ext/ply/test/yacc_badprec2.py index 9cbc99827..206bda768 100644 --- a/ext/ply/test/yacc_badprec2.py +++ b/ext/ply/test/yacc_badprec2.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_badrule.exp b/ext/ply/test/yacc_badrule.exp index 553779778..a87bf7d68 100644 --- a/ext/ply/test/yacc_badrule.exp +++ b/ext/ply/test/yacc_badrule.exp @@ -1,5 +1,5 @@ -./yacc_badrule.py:22: Syntax error. Expected ':' -./yacc_badrule.py:26: Syntax error in rule 'statement' -./yacc_badrule.py:31: Syntax error. Expected ':' -./yacc_badrule.py:40: Syntax error. Expected ':' -yacc.YaccError: Unable to construct parser. +./yacc_badrule.py:25: Syntax error. Expected ':' +./yacc_badrule.py:29: Syntax error in rule 'statement' +./yacc_badrule.py:34: Syntax error. Expected ':' +./yacc_badrule.py:43: Syntax error. Expected ':' +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_badrule.py b/ext/ply/test/yacc_badrule.py index cad3a967e..f5fef8ad6 100644 --- a/ext/ply/test/yacc_badrule.py +++ b/ext/ply/test/yacc_badrule.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_badtok.exp b/ext/ply/test/yacc_badtok.exp index f6e64726c..ccdc0e7a1 100644 --- a/ext/ply/test/yacc_badtok.exp +++ b/ext/ply/test/yacc_badtok.exp @@ -1 +1 @@ -yacc.YaccError: tokens must be a list or tuple. +ply.yacc.YaccError: tokens must be a list or tuple. diff --git a/ext/ply/test/yacc_badtok.py b/ext/ply/test/yacc_badtok.py index a17d26aaa..4f2af5162 100644 --- a/ext/ply/test/yacc_badtok.py +++ b/ext/ply/test/yacc_badtok.py @@ -7,6 +7,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + tokens = "Hello" # Parsing rules @@ -60,7 +63,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_dup.exp b/ext/ply/test/yacc_dup.exp index 99f3fe22c..fdfb2103d 100644 --- a/ext/ply/test/yacc_dup.exp +++ b/ext/ply/test/yacc_dup.exp @@ -1,4 +1,4 @@ -./yacc_dup.py:25: Function p_statement redefined. Previously defined on line 21 +./yacc_dup.py:28: Function p_statement redefined. Previously defined on line 24 yacc: Warning. Token 'EQUALS' defined, but not used. yacc: Warning. There is 1 unused token. -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_dup.py b/ext/ply/test/yacc_dup.py index 557cd0ae1..e0b683d8f 100644 --- a/ext/ply/test/yacc_dup.py +++ b/ext/ply/test/yacc_dup.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_error1.exp b/ext/ply/test/yacc_error1.exp index 980fc905c..13bed0461 100644 --- a/ext/ply/test/yacc_error1.exp +++ b/ext/ply/test/yacc_error1.exp @@ -1 +1 @@ -yacc.YaccError: ./yacc_error1.py:59: p_error() requires 1 argument. +ply.yacc.YaccError: ./yacc_error1.py:62: p_error() requires 1 argument. diff --git a/ext/ply/test/yacc_error1.py b/ext/ply/test/yacc_error1.py index 413004520..2768fc14a 100644 --- a/ext/ply/test/yacc_error1.py +++ b/ext/ply/test/yacc_error1.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t,s): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_error2.exp b/ext/ply/test/yacc_error2.exp index d0573b4dd..4a7628d78 100644 --- a/ext/ply/test/yacc_error2.exp +++ b/ext/ply/test/yacc_error2.exp @@ -1 +1 @@ -yacc.YaccError: ./yacc_error2.py:59: p_error() requires 1 argument. +ply.yacc.YaccError: ./yacc_error2.py:62: p_error() requires 1 argument. diff --git a/ext/ply/test/yacc_error2.py b/ext/ply/test/yacc_error2.py index d4fd1d219..8f3a05290 100644 --- a/ext/ply/test/yacc_error2.py +++ b/ext/ply/test/yacc_error2.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_error3.exp b/ext/ply/test/yacc_error3.exp index 31eaee754..7fca2fe95 100644 --- a/ext/ply/test/yacc_error3.exp +++ b/ext/ply/test/yacc_error3.exp @@ -1 +1 @@ -yacc.YaccError: 'p_error' defined, but is not a function. +ply.yacc.YaccError: 'p_error' defined, but is not a function or method. diff --git a/ext/ply/test/yacc_error3.py b/ext/ply/test/yacc_error3.py index 7093fab48..b387de5d1 100644 --- a/ext/ply/test/yacc_error3.py +++ b/ext/ply/test/yacc_error3.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -58,7 +61,6 @@ def p_expression_name(t): p_error = "blah" -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_inf.exp b/ext/ply/test/yacc_inf.exp index a7f47dada..88cfa4a2e 100644 --- a/ext/ply/test/yacc_inf.exp +++ b/ext/ply/test/yacc_inf.exp @@ -2,4 +2,4 @@ yacc: Warning. Token 'NUMBER' defined, but not used. yacc: Warning. There is 1 unused token. yacc: Infinite recursion detected for symbol 'statement'. yacc: Infinite recursion detected for symbol 'expression'. -yacc.YaccError: Unable to construct parser. +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_inf.py b/ext/ply/test/yacc_inf.py index 885e2c4df..9b9aef75d 100644 --- a/ext/ply/test/yacc_inf.py +++ b/ext/ply/test/yacc_inf.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -47,7 +50,6 @@ def p_expression_group(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_missing1.exp b/ext/ply/test/yacc_missing1.exp index 065d6a54a..de63d4f48 100644 --- a/ext/ply/test/yacc_missing1.exp +++ b/ext/ply/test/yacc_missing1.exp @@ -1,2 +1,2 @@ -./yacc_missing1.py:22: Symbol 'location' used, but not defined as a token or a rule. -yacc.YaccError: Unable to construct parser. +./yacc_missing1.py:25: Symbol 'location' used, but not defined as a token or a rule. +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_missing1.py b/ext/ply/test/yacc_missing1.py index e63904d0e..fbc54d8c5 100644 --- a/ext/ply/test/yacc_missing1.py +++ b/ext/ply/test/yacc_missing1.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_nodoc.exp b/ext/ply/test/yacc_nodoc.exp index 3f52a3287..889ccfce7 100644 --- a/ext/ply/test/yacc_nodoc.exp +++ b/ext/ply/test/yacc_nodoc.exp @@ -1,2 +1,2 @@ -./yacc_nodoc.py:25: No documentation string specified in function 'p_statement_expr' -yacc: Generating SLR parsing table... +./yacc_nodoc.py:28: No documentation string specified in function 'p_statement_expr' +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_nodoc.py b/ext/ply/test/yacc_nodoc.py index e3941bdaa..4c5ab20a9 100644 --- a/ext/ply/test/yacc_nodoc.py +++ b/ext/ply/test/yacc_nodoc.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -58,7 +61,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_noerror.exp b/ext/ply/test/yacc_noerror.exp index 986fa31fa..3ae771225 100644 --- a/ext/ply/test/yacc_noerror.exp +++ b/ext/ply/test/yacc_noerror.exp @@ -1,2 +1,2 @@ yacc: Warning. no p_error() function is defined. -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_noerror.py b/ext/ply/test/yacc_noerror.py index d92f48ea6..9c11838eb 100644 --- a/ext/ply/test/yacc_noerror.py +++ b/ext/ply/test/yacc_noerror.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -56,7 +59,7 @@ def p_expression_name(t): print "Undefined name '%s'" % t[1] t[0] = 0 -import yacc + yacc.yacc() diff --git a/ext/ply/test/yacc_nop.exp b/ext/ply/test/yacc_nop.exp index 062878b9e..515fff7dc 100644 --- a/ext/ply/test/yacc_nop.exp +++ b/ext/ply/test/yacc_nop.exp @@ -1,2 +1,2 @@ -./yacc_nop.py:25: Warning. Possible grammar rule 'statement_expr' defined without p_ prefix. -yacc: Generating SLR parsing table... +./yacc_nop.py:28: Warning. Possible grammar rule 'statement_expr' defined without p_ prefix. +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_nop.py b/ext/ply/test/yacc_nop.py index c599ffd5d..c0b431d4b 100644 --- a/ext/ply/test/yacc_nop.py +++ b/ext/ply/test/yacc_nop.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_notfunc.exp b/ext/ply/test/yacc_notfunc.exp index 271167341..f73bc93a5 100644 --- a/ext/ply/test/yacc_notfunc.exp +++ b/ext/ply/test/yacc_notfunc.exp @@ -1,4 +1,4 @@ yacc: Warning. 'p_statement_assign' not defined as a function yacc: Warning. Token 'EQUALS' defined, but not used. yacc: Warning. There is 1 unused token. -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_notfunc.py b/ext/ply/test/yacc_notfunc.py index f61663d60..838935509 100644 --- a/ext/ply/test/yacc_notfunc.py +++ b/ext/ply/test/yacc_notfunc.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -57,7 +60,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_notok.exp b/ext/ply/test/yacc_notok.exp index 708f6f597..d2399fe17 100644 --- a/ext/ply/test/yacc_notok.exp +++ b/ext/ply/test/yacc_notok.exp @@ -1 +1 @@ -yacc.YaccError: module does not define a list 'tokens' +ply.yacc.YaccError: module does not define a list 'tokens' diff --git a/ext/ply/test/yacc_notok.py b/ext/ply/test/yacc_notok.py index dfa0059be..e566a1bf4 100644 --- a/ext/ply/test/yacc_notok.py +++ b/ext/ply/test/yacc_notok.py @@ -7,6 +7,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + # Parsing rules precedence = ( ('left','PLUS','MINUS'), @@ -58,7 +61,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_rr.exp b/ext/ply/test/yacc_rr.exp index 0ec556d16..f73cefdec 100644 --- a/ext/ply/test/yacc_rr.exp +++ b/ext/ply/test/yacc_rr.exp @@ -1,2 +1,2 @@ -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... yacc: 1 reduce/reduce conflict diff --git a/ext/ply/test/yacc_rr.py b/ext/ply/test/yacc_rr.py index c061c2c17..bb8cba235 100644 --- a/ext/ply/test/yacc_rr.py +++ b/ext/ply/test/yacc_rr.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -63,7 +66,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_simple.exp b/ext/ply/test/yacc_simple.exp index de7964b6f..38360315f 100644 --- a/ext/ply/test/yacc_simple.exp +++ b/ext/ply/test/yacc_simple.exp @@ -1 +1 @@ -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... diff --git a/ext/ply/test/yacc_simple.py b/ext/ply/test/yacc_simple.py index 7b4b40b17..b5dc9f39c 100644 --- a/ext/ply/test/yacc_simple.py +++ b/ext/ply/test/yacc_simple.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_sr.exp b/ext/ply/test/yacc_sr.exp index 7225ad94b..1b764502c 100644 --- a/ext/ply/test/yacc_sr.exp +++ b/ext/ply/test/yacc_sr.exp @@ -1,2 +1,2 @@ -yacc: Generating SLR parsing table... +yacc: Generating LALR parsing table... yacc: 20 shift/reduce conflicts diff --git a/ext/ply/test/yacc_sr.py b/ext/ply/test/yacc_sr.py index 4341f6997..e2f03ec74 100644 --- a/ext/ply/test/yacc_sr.py +++ b/ext/ply/test/yacc_sr.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -54,7 +57,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_term1.exp b/ext/ply/test/yacc_term1.exp index 422d2bacd..40f9bdf64 100644 --- a/ext/ply/test/yacc_term1.exp +++ b/ext/ply/test/yacc_term1.exp @@ -1,2 +1,2 @@ -./yacc_term1.py:22: Illegal rule name 'NUMBER'. Already defined as a token. -yacc.YaccError: Unable to construct parser. +./yacc_term1.py:25: Illegal rule name 'NUMBER'. Already defined as a token. +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_term1.py b/ext/ply/test/yacc_term1.py index 97a2e7a60..bbc52da86 100644 --- a/ext/ply/test/yacc_term1.py +++ b/ext/ply/test/yacc_term1.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -59,7 +62,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_unused.exp b/ext/ply/test/yacc_unused.exp index 390754de3..6caafd266 100644 --- a/ext/ply/test/yacc_unused.exp +++ b/ext/ply/test/yacc_unused.exp @@ -1,4 +1,4 @@ -./yacc_unused.py:60: Symbol 'COMMA' used, but not defined as a token or a rule. +./yacc_unused.py:63: Symbol 'COMMA' used, but not defined as a token or a rule. yacc: Symbol 'COMMA' is unreachable. yacc: Symbol 'exprlist' is unreachable. -yacc.YaccError: Unable to construct parser. +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_unused.py b/ext/ply/test/yacc_unused.py index 4cbd63327..3a61f99cd 100644 --- a/ext/ply/test/yacc_unused.py +++ b/ext/ply/test/yacc_unused.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -68,7 +71,6 @@ def p_expr_list_2(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() diff --git a/ext/ply/test/yacc_uprec.exp b/ext/ply/test/yacc_uprec.exp index b1a71a250..eb9a39886 100644 --- a/ext/ply/test/yacc_uprec.exp +++ b/ext/ply/test/yacc_uprec.exp @@ -1,2 +1,2 @@ -./yacc_uprec.py:35: Nothing known about the precedence of 'UMINUS' -yacc.YaccError: Unable to construct parser. +./yacc_uprec.py:38: Nothing known about the precedence of 'UMINUS' +ply.yacc.YaccError: Unable to construct parser. diff --git a/ext/ply/test/yacc_uprec.py b/ext/ply/test/yacc_uprec.py index 139ce6318..0e8711e88 100644 --- a/ext/ply/test/yacc_uprec.py +++ b/ext/ply/test/yacc_uprec.py @@ -6,6 +6,9 @@ import sys sys.tracebacklimit = 0 +sys.path.insert(0,"..") +import ply.yacc as yacc + from calclex import tokens # Parsing rules @@ -54,7 +57,6 @@ def p_expression_name(t): def p_error(t): print "Syntax error at '%s'" % t.value -import yacc yacc.yacc() -- cgit v1.2.3