Changes for 0.2

This commit is contained in:
David Beazley
2018-01-10 06:09:20 -06:00
parent d8903d8301
commit e05748494c
10 changed files with 55 additions and 22 deletions

View File

@@ -31,7 +31,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
__version__ = '0.1'
__version__ = '0.2'
__all__ = ['Lexer', 'LexerStateChange']
import re
@@ -251,7 +251,12 @@ class Lexer(metaclass=LexerMeta):
# A lexing error
self.index = index
self.lineno = lineno
self.error(text[index:])
tok.type = 'ERROR'
tok.value = text[index:]
tok = self.error(tok)
if tok is not None:
yield tok
index = self.index
lineno = self.lineno
@@ -267,5 +272,5 @@ class Lexer(metaclass=LexerMeta):
self.lineno = lineno
# Default implementations of the error handler. May be changed in subclasses
def error(self, value):
raise LexError(f'Illegal character {value[0]!r} at index {self.index}', value, self.index)
def error(self, t):
raise LexError(f'Illegal character {t.value[0]!r} at index {self.index}', value, self.index)

View File

@@ -35,7 +35,7 @@ import sys
import inspect
from collections import OrderedDict, defaultdict
__version__ = '0.1'
__version__ = '0.2'
__all__ = [ 'Parser' ]
class YaccError(Exception):