diff options
author | David Beazley <dave@dabeaz.com> | 2016-10-07 11:54:02 -0500 |
---|---|---|
committer | David Beazley <dave@dabeaz.com> | 2016-10-07 11:54:02 -0500 |
commit | 393cc558722eb892724701c110e7ae4c101c88c3 (patch) | |
tree | cd7a77c4e3ba6037a227f8b9eddc1f6b1b451fa6 | |
parent | b515c5fa1003a2a575b5c175831142da94e21ee5 (diff) | |
download | ply-393cc558722eb892724701c110e7ae4c101c88c3.tar.gz |
Fixed issue #101. Incorrect shift/reduce conflict resolution
-rw-r--r-- | ANNOUNCE | 8 | ||||
-rw-r--r-- | CHANGES | 16 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | doc/internal.html | 2 | ||||
-rw-r--r-- | doc/ply.html | 2 | ||||
-rw-r--r-- | ply/lex.py | 4 | ||||
-rw-r--r-- | ply/yacc.py | 20 | ||||
-rw-r--r-- | setup.py | 2 |
8 files changed, 41 insertions, 15 deletions
@@ -1,11 +1,11 @@ -August 31, 2016 +October 7, 2016 - Announcing : PLY-3.9 (Python Lex-Yacc) + Announcing : PLY-3.10 (Python Lex-Yacc) http://www.dabeaz.com/ply -I'm pleased to announce PLY-3.9--a pure Python implementation of the -common parsing tools lex and yacc. PLY-3.9 is a minor bug fix +I'm pleased to announce PLY-3.10--a pure Python implementation of the +common parsing tools lex and yacc. PLY-3.10 is a minor bug fix release. It supports both Python 2 and Python 3. If you are new to PLY, here are a few highlights: @@ -1,3 +1,19 @@ +Version 3.10 +--------------------- +10/07/16: beazley + Fixed Issue #101: Incorrect shift-reduce conflict resolution with + precedence specifier. + + PLY was incorrectly resolving shift-reduce conflicts in certain + cases. For example, in the example/calc/calc.py example, you + could trigger it doing this: + + calc > -3 - 4 + 1 (correct answer should be -7) + calc > + + Issue and suggested patch contributed by https://github.com/RomaVis + Version 3.9 --------------------- 08/30/16: beazley @@ -1,4 +1,4 @@ -PLY (Python Lex-Yacc) Version 3.9 +PLY (Python Lex-Yacc) Version 3.10 Copyright (C) 2001-2016 David M. Beazley (Dabeaz LLC) diff --git a/doc/internal.html b/doc/internal.html index 3fabfe2..f73bc43 100644 --- a/doc/internal.html +++ b/doc/internal.html @@ -12,7 +12,7 @@ dave@dabeaz.com<br> </b> <p> -<b>PLY Version: 3.0</b> +<b>PLY Version: 3.10</b> <p> <!-- INDEX --> diff --git a/doc/ply.html b/doc/ply.html index 70a4152..0b232b2 100644 --- a/doc/ply.html +++ b/doc/ply.html @@ -12,7 +12,7 @@ dave@dabeaz.com<br> </b> <p> -<b>PLY Version: 3.9</b> +<b>PLY Version: 3.10</b> <p> <!-- INDEX --> @@ -31,8 +31,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ----------------------------------------------------------------------------- -__version__ = '3.9' -__tabversion__ = '3.8' +__version__ = '3.10' +__tabversion__ = '3.10' import re import sys diff --git a/ply/yacc.py b/ply/yacc.py index 6842832..62ebc88 100644 --- a/ply/yacc.py +++ b/ply/yacc.py @@ -67,8 +67,8 @@ import inspect import base64 import warnings -__version__ = '3.9' -__tabversion__ = '3.8' +__version__ = '3.10' +__tabversion__ = '3.10' #----------------------------------------------------------------------------- # === User configurable parameters === @@ -2585,8 +2585,13 @@ class LRGeneratedTable(LRTable): # Need to decide on shift or reduce here # By default we favor shifting. Need to add # some precedence rules here. - sprec, slevel = Productions[st_actionp[a].number].prec - rprec, rlevel = Precedence.get(a, ('right', 0)) + + # Shift precedence comes from the token + sprec, slevel = Precedence.get(a, ('right', 0)) + + # Reduce precedence comes from rule being reduced (p) + rprec, rlevel = Productions[p.number].prec + if (slevel < rlevel) or ((slevel == rlevel) and (rprec == 'left')): # We really need to reduce here. st_action[a] = -p.number @@ -2644,8 +2649,13 @@ class LRGeneratedTable(LRTable): # - if precedence of reduce rule is higher, we reduce. # - if precedence of reduce is same and left assoc, we reduce. # - otherwise we shift - rprec, rlevel = Productions[st_actionp[a].number].prec + + # Shift precedence comes from the token sprec, slevel = Precedence.get(a, ('right', 0)) + + # Reduce precedence comes from the rule that could have been reduced + rprec, rlevel = Productions[st_actionp[a].number].prec + if (slevel > rlevel) or ((slevel == rlevel) and (rprec == 'right')): # We decide to shift here... highest precedence to shift Productions[st_actionp[a].number].reduced -= 1 @@ -17,7 +17,7 @@ PLY is extremely easy to use and provides very extensive error checking. It is compatible with both Python 2 and Python 3. """, license="""BSD""", - version = "3.9", + version = "3.10", author = "David Beazley", author_email = "dave@dabeaz.com", maintainer = "David Beazley", |