diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | ANNOUNCE | 8 | ||||
-rw-r--r-- | CHANGES | 19 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | example/ansic/cparse.py | 2 | ||||
-rw-r--r-- | ply/__init__.py | 2 | ||||
-rw-r--r-- | ply/cpp.py | 13 | ||||
-rw-r--r-- | ply/lex.py | 9 | ||||
-rw-r--r-- | ply/yacc.py | 62 | ||||
-rw-r--r-- | setup.py | 2 |
10 files changed, 83 insertions, 40 deletions
diff --git a/.travis.yml b/.travis.yml index e5733f3..874e3df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,5 @@ python: - "3.3" - "3.4" install: - - "pip install . --use-mirrors" + - "pip install . " script: "cd test && python testlex.py && python testyacc.py" @@ -1,11 +1,11 @@ -October 2, 2015 +August 31, 2016 - Announcing : PLY-3.8 (Python Lex-Yacc) + Announcing : PLY-3.9 (Python Lex-Yacc) http://www.dabeaz.com/ply -I'm pleased to announce PLY-3.7--a pure Python implementation of the -common parsing tools lex and yacc. PLY-3.7 is a minor bug fix +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 release. It supports both Python 2 and Python 3. If you are new to PLY, here are a few highlights: @@ -1,3 +1,22 @@ +Version 3.9 +--------------------- +08/30/16: beazley + Fixed Issue #88. Python3 compatibility with ply/cpp. + +08/30/16: beazley + Fixed Issue #93. Ply can crash if SyntaxError is raised inside + a production. Not actually sure if the original implementation + worked as documented at all. Yacc has been modified to follow + the spec as outlined in the CHANGES noted for 11/27/07 below. + +08/30/16: beazley + Fixed Issue #97. Failure with code validation when the original + source files aren't present. Validation step now ignores + the missing file. + +08/30/16: beazley + Minor fixes to version numbers. + Version 3.8 --------------------- 10/02/15: beazley @@ -1,6 +1,6 @@ -PLY (Python Lex-Yacc) Version 3.8 +PLY (Python Lex-Yacc) Version 3.9 -Copyright (C) 2001-2015, +Copyright (C) 2001-2016 David M. Beazley (Dabeaz LLC) All rights reserved. diff --git a/example/ansic/cparse.py b/example/ansic/cparse.py index 2583075..5c6932c 100644 --- a/example/ansic/cparse.py +++ b/example/ansic/cparse.py @@ -855,7 +855,7 @@ import profile # Build the grammar yacc.yacc() -#yacc.yacc(method='LALR',write_tables=False,debug=True) +#yacc.yacc(method='LALR',write_tables=False,debug=False) #profile.run("yacc.yacc(method='LALR')") diff --git a/ply/__init__.py b/ply/__init__.py index 2461a44..6e53cdd 100644 --- a/ply/__init__.py +++ b/ply/__init__.py @@ -1,5 +1,5 @@ # PLY package # Author: David Beazley (dave@dabeaz.com) -__version__ = '3.7' +__version__ = '3.9' __all__ = ['lex','yacc'] @@ -9,6 +9,15 @@ # ----------------------------------------------------------------------------- from __future__ import generators +import sys + +# Some Python 3 compatibility shims +if sys.version_info.major < 3: + STRING_TYPES = (str, unicode) +else: + STRING_TYPES = str + xrange = range + # ----------------------------------------------------------------------------- # Default preprocessor lexer definitions. These tokens are enough to get # a basic preprocessor working. Other modules may import these if they want @@ -590,7 +599,7 @@ class Preprocessor(object): expr = expr.replace("!"," not ") try: result = eval(expr) - except StandardError: + except Exception: self.error(self.source,tokens[0].lineno,"Couldn't evaluate expression") result = 0 return result @@ -781,7 +790,7 @@ class Preprocessor(object): # ---------------------------------------------------------------------- def define(self,tokens): - if isinstance(tokens,(str,unicode)): + if isinstance(tokens,STRING_TYPES): tokens = self.tokenize(tokens) linetok = tokens @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # ply: lex.py # -# Copyright (C) 2001-2015, +# Copyright (C) 2001-2016 # David M. Beazley (Dabeaz LLC) # All rights reserved. # @@ -31,7 +31,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ----------------------------------------------------------------------------- -__version__ = '3.8' +__version__ = '3.9' __tabversion__ = '3.8' import re @@ -830,7 +830,10 @@ class LexerReflect(object): # ----------------------------------------------------------------------------- def validate_module(self, module): - lines, linen = inspect.getsourcelines(module) + try: + lines, linen = inspect.getsourcelines(module) + except IOError: + return fre = re.compile(r'\s*def\s+(t_[a-zA-Z_0-9]*)\(') sre = re.compile(r'\s*(t_[a-zA-Z_0-9]*)\s*=') diff --git a/ply/yacc.py b/ply/yacc.py index e7f36aa..41f4795 100644 --- a/ply/yacc.py +++ b/ply/yacc.py @@ -1,7 +1,7 @@ # ----------------------------------------------------------------------------- # ply: yacc.py # -# Copyright (C) 2001-2015, +# Copyright (C) 2001-2016 # David M. Beazley (Dabeaz LLC) # All rights reserved. # @@ -67,7 +67,7 @@ import inspect import base64 import warnings -__version__ = '3.8' +__version__ = '3.9' __tabversion__ = '3.8' #----------------------------------------------------------------------------- @@ -497,8 +497,8 @@ class LRParser: try: # Call the grammar rule with our special slice object del symstack[-plen:] - del statestack[-plen:] p.callable(pslice) + del statestack[-plen:] #--! DEBUG debug.info('Result : %s', format_result(pslice[0])) #--! DEBUG @@ -507,14 +507,16 @@ class LRParser: statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + symstack.extend(targ[1:-1]) # Put the production slice back on the stack + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -546,14 +548,15 @@ class LRParser: statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -811,21 +814,23 @@ class LRParser: try: # Call the grammar rule with our special slice object del symstack[-plen:] - del statestack[-plen:] p.callable(pslice) + del statestack[-plen:] symstack.append(sym) state = goto[statestack[-1]][pname] statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + symstack.extend(targ[1:-1]) # Put the production slice back on the stack + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -854,14 +859,15 @@ class LRParser: statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1102,21 +1108,23 @@ class LRParser: try: # Call the grammar rule with our special slice object del symstack[-plen:] - del statestack[-plen:] p.callable(pslice) + del statestack[-plen:] symstack.append(sym) state = goto[statestack[-1]][pname] statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + symstack.extend(targ[1:-1]) # Put the production slice back on the stack + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1140,14 +1148,15 @@ class LRParser: statestack.append(state) except SyntaxError: # If an error was set. Enter error recovery state - lookaheadstack.append(lookahead) - symstack.pop() - statestack.pop() + lookaheadstack.append(lookahead) # Save the current lookahead token + statestack.pop() # Pop back one state (before the reduce) state = statestack[-1] sym.type = 'error' + sym.value = 'error' lookahead = sym errorcount = error_count self.errorok = False + continue # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -1982,7 +1991,7 @@ class LRTable(object): import cPickle as pickle except ImportError: import pickle - + if not os.path.exists(filename): raise ImportError @@ -2979,7 +2988,10 @@ class ParserReflect(object): fre = re.compile(r'\s*def\s+(p_[a-zA-Z_0-9]*)\(') for module in self.modules: - lines, linen = inspect.getsourcelines(module) + try: + lines, linen = inspect.getsourcelines(module) + except IOError: + continue counthash = {} for linen, line in enumerate(lines): @@ -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.8", + version = "3.9", author = "David Beazley", author_email = "dave@dabeaz.com", maintainer = "David Beazley", |