diff options
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | doc/ply.html | 9 | ||||
-rw-r--r-- | ply/yacc.py | 9 |
4 files changed, 30 insertions, 9 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b13d007 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +PYTHON ?= python + +test: + cd test && $(PYTHON) testlex.py + cd test && $(PYTHON) testyacc.py + +wheel: + $(PYTHON) setup.py bdist_wheel + +sdist: + $(PYTHON) setup.py sdist + +upload: wheel sdist + $(PYTHON) setup.py bdist_wheel upload + $(PYTHON) setup.py sdist upload + +.PHONY: test wheel sdist upload @@ -1,4 +1,6 @@ -PLY (Python Lex-Yacc) Version 3.11 +# PLY (Python Lex-Yacc) Version 3.11 + +[![Build Status](https://travis-ci.org/dabeaz/ply.svg?branch=master)](https://travis-ci.org/dabeaz/ply) Copyright (C) 2001-2017 David M. Beazley (Dabeaz LLC) diff --git a/doc/ply.html b/doc/ply.html index 30905e2..b35ba44 100644 --- a/doc/ply.html +++ b/doc/ply.html @@ -558,15 +558,12 @@ column information as a separate step. For instance, just count backwards unti <blockquote> <pre> -# Compute column. +# Compute column. # input is the input text string # token is a token instance def find_column(input, token): - last_cr = input.rfind('\n', 0, token.lexpos) - if last_cr < 0: - last_cr = 0 - column = (token.lexpos - last_cr) + 1 - return column + line_start = input.rfind('\n', 0, token.lexpos) + 1 + return (token.lexpos - line_start) + 1 </pre> </blockquote> diff --git a/ply/yacc.py b/ply/yacc.py index 4210239..ceaaefd 100644 --- a/ply/yacc.py +++ b/ply/yacc.py @@ -32,7 +32,7 @@ # ----------------------------------------------------------------------------- # # This implements an LR parser that is constructed from grammar rules defined -# as Python functions. The grammer is specified by supplying the BNF inside +# as Python functions. The grammar is specified by supplying the BNF inside # Python documentation strings. The inspiration for this technique was borrowed # from John Aycock's Spark parsing system. PLY might be viewed as cross between # Spark and the GNU bison utility. @@ -2733,6 +2733,7 @@ class LRGeneratedTable(LRTable): f.write(''' # %s # This file is automatically generated. Do not edit. +# pylint: disable=W,C,R _tabversion = %r _lr_method = %r @@ -3230,9 +3231,13 @@ def yacc(method='LALR', debug=yaccdebug, module=None, tabmodule=tab_module, star if module: _items = [(k, getattr(module, k)) for k in dir(module)] pdict = dict(_items) - # If no __file__ attribute is available, try to obtain it from the __module__ instead + # If no __file__ or __package__ attributes are available, try to obtain them + # from the __module__ instead if '__file__' not in pdict: pdict['__file__'] = sys.modules[pdict['__module__']].__file__ + if '__package__' not in pdict and '__module__' in pdict: + if hasattr(sys.modules[pdict['__module__']], '__package__'): + pdict['__package__'] = sys.modules[pdict['__module__']].__package__ else: pdict = get_caller_module_dict(2) |