alex / rply

An attempt to port David Beazley's PLY to RPython, and give it a cooler API.
BSD 3-Clause "New" or "Revised" License
381 stars 60 forks source link

Missing LALRError Exception class #35

Closed prologic closed 10 years ago

prologic commented 10 years ago

Patch:

diff --git a/rply/errors.py b/rply/errors.py
index 1844c5f..ad88ce3 100644
--- a/rply/errors.py
+++ b/rply/errors.py
@@ -2,6 +2,10 @@ class ParserGeneratorError(Exception):
     pass

+class LALRError(Exception):
+    pass
+
+
 class LexingError(Exception):
     """
     Raised by a Lexer, if no rule matches.
diff --git a/rply/parsergenerator.py b/rply/parsergenerator.py
index 407ff82..aa7961f 100644
--- a/rply/parsergenerator.py
+++ b/rply/parsergenerator.py
@@ -8,7 +8,7 @@ import sys
 import tempfile
 import warnings

-from rply.errors import ParserGeneratorError, ParserGeneratorWarning
+from rply.errors import LALRError, ParserGeneratorError, ParserGeneratorWarning
 from rply.grammar import Grammar
 from rply.parser import LRParser
 from rply.utils import IdentityDict, Counter, iteritems, itervalues
@@ -331,7 +331,6 @@ class LRTable(object):
                                     else:
                                         chosenp, rejectp = oldp, pp
                                     rr_conflicts.append((st, repr(chosenp), repr(rejectp)))
-                                else:
                                     raise LALRError("Unknown conflict in state %d" % st)
                             else:
                                 st_action[a] = -p.number
alex commented 10 years ago

I believe this was fixed in 0abcc2e31048524e3eb393cd3d515af158617f0e, can you confirm? (I'm closing now, but will reopen if it's still there, thanks!)

prologic commented 10 years ago

Confirmed. What's even more amazing is a problem I was having with my parser has suddenly gone away :) Thanks!

James Mills / prologic

E: prologic@shortcircuit.net.au W: prologic.shortcircuit.net.au

On Thu, Sep 11, 2014 at 12:25 AM, Alex Gaynor notifications@github.com wrote:

I believe this was fixed in 0abcc2e https://github.com/alex/rply/commit/0abcc2e31048524e3eb393cd3d515af158617f0e, can you confirm? (I'm closing now, but will reopen if it's still there, thanks!)

— Reply to this email directly or view it on GitHub https://github.com/alex/rply/issues/35#issuecomment-55122552.