diff options
author | David Beazley <dave@dabeaz.com> | 2007-02-28 19:00:59 +0000 |
---|---|---|
committer | David Beazley <dave@dabeaz.com> | 2007-02-28 19:00:59 +0000 |
commit | e4989423fb06998f9e5c0011332469320597ec64 (patch) | |
tree | 87b66e72e637fc6ee18a67627be7a5ced36a1723 /example | |
parent | e012665bc2b9f1593145a043cfbe27ed6d618208 (diff) | |
download | ply-e4989423fb06998f9e5c0011332469320597ec64.tar.gz |
Fixed examples for EOF condition in p_error
Diffstat (limited to 'example')
-rw-r--r-- | example/calc/calc.py | 5 | ||||
-rwxr-xr-x | example/classcalc/calc.py | 5 | ||||
-rwxr-xr-x | example/newclasscalc/calc.py | 5 | ||||
-rw-r--r-- | example/optcalc/calc.py | 5 | ||||
-rw-r--r-- | example/unicalc/calc.py | 5 |
5 files changed, 20 insertions, 5 deletions
diff --git a/example/calc/calc.py b/example/calc/calc.py index 5bf5d5d..1df0aeb 100644 --- a/example/calc/calc.py +++ b/example/calc/calc.py @@ -91,7 +91,10 @@ def p_expression_name(p): p[0] = 0 def p_error(p): - print "Syntax error at '%s'" % p.value + if p: + print "Syntax error at '%s'" % p.value + else: + print "Syntax error at EOF" import ply.yacc as yacc yacc.yacc() diff --git a/example/classcalc/calc.py b/example/classcalc/calc.py index 7ec09a6..2af8d60 100755 --- a/example/classcalc/calc.py +++ b/example/classcalc/calc.py @@ -145,7 +145,10 @@ class Calc(Parser): p[0] = 0 def p_error(self, p): - print "Syntax error at '%s'" % p.value + if p: + print "Syntax error at '%s'" % p.value + else: + print "Syntax error at EOF" if __name__ == '__main__': calc = Calc() diff --git a/example/newclasscalc/calc.py b/example/newclasscalc/calc.py index b021b6b..00d7e8d 100755 --- a/example/newclasscalc/calc.py +++ b/example/newclasscalc/calc.py @@ -148,7 +148,10 @@ class Calc(Parser): p[0] = 0 def p_error(self, p): - print "Syntax error at '%s'" % p.value + if p: + print "Syntax error at '%s'" % p.value + else: + print "Syntax error at EOF" if __name__ == '__main__': calc = Calc() diff --git a/example/optcalc/calc.py b/example/optcalc/calc.py index 325f67c..2b1db77 100644 --- a/example/optcalc/calc.py +++ b/example/optcalc/calc.py @@ -99,7 +99,10 @@ def p_expression_name(t): t[0] = 0 def p_error(t): - print "Syntax error at '%s'" % t.value + if t: + print "Syntax error at '%s'" % t.value + else: + print "Syntax error at EOF" import ply.yacc as yacc yacc.yacc(optimize=1) diff --git a/example/unicalc/calc.py b/example/unicalc/calc.py index 7e60433..55fb48d 100644 --- a/example/unicalc/calc.py +++ b/example/unicalc/calc.py @@ -100,7 +100,10 @@ def p_expression_name(p): p[0] = 0 def p_error(p): - print "Syntax error at '%s'" % p.value + if p: + print "Syntax error at '%s'" % p.value + else: + print "Syntax error at EOF" import ply.yacc as yacc yacc.yacc() |