summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Beazley <dave@dabeaz.com>2008-02-28 20:08:40 +0000
committerDavid Beazley <dave@dabeaz.com>2008-02-28 20:08:40 +0000
commited1cb91715f6cd6fb368e8f624158b1614420687 (patch)
tree74d8549a720ec66e43ef57140411fb0d2db535f8
parent29c3673964f97bb8cc9446a44b93ff6087e0f6eb (diff)
downloadply-ed1cb91715f6cd6fb368e8f624158b1614420687.tar.gz
Fixed bug with nonassoc precedence
-rw-r--r--CHANGES7
-rw-r--r--example/BASIC/basic.py7
-rw-r--r--ply/yacc.py2
3 files changed, 13 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 7e2d3a4..669e187 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,11 @@
Version 2.4
-----------------------------
-02/16/07: beazley
+02/28/08: beazley
+ Fixed a bug with 'nonassoc' precedence rules. Basically the
+ non-precedence was being ignored and not producing the correct
+ run-time behavior in the parser.
+
+02/16/08: beazley
Slight relaxation of what the input() method to a lexer will
accept as a string. Instead of testing the input to see
if the input is a string or unicode string, it checks to see
diff --git a/example/BASIC/basic.py b/example/BASIC/basic.py
index 6a2f489..4b3675d 100644
--- a/example/BASIC/basic.py
+++ b/example/BASIC/basic.py
@@ -12,7 +12,12 @@ import basinterp
# If a runtime error occurs, we bail out and enter
# interactive mode below
if len(sys.argv) == 2:
- data = open(sys.argv[1]).read()
+ import os,mmap
+ data = mmap.mmap(os.open(sys.argv[1],os.O_RDONLY),
+ os.path.getsize(sys.argv[1]),
+ access=mmap.ACCESS_READ)
+
+# data = open(sys.argv[1]).read()
prog = basparse.parse(data)
if not prog: raise SystemExit
b = basinterp.BasicInterpreter(prog)
diff --git a/ply/yacc.py b/ply/yacc.py
index 48c4c4b..cf2154b 100644
--- a/ply/yacc.py
+++ b/ply/yacc.py
@@ -1766,7 +1766,7 @@ def lr_parse_table(method):
# - otherwise we shift
rprec,rlevel = Productions[st_actionp[a].number].prec
sprec,slevel = Precedence.get(a,('right',0))
- if (slevel > rlevel) or ((slevel == rlevel) and (rprec != 'left')):
+ if (slevel > rlevel) or ((slevel == rlevel) and (rprec == 'right')):
# We decide to shift here... highest precedence to shift
st_action[a] = j
st_actionp[a] = p