diff --git a/CHANGES b/CHANGES index 40af0eb..988aa6b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +Version 0.3 +----------- +1/16/2018 Usability improvement on Lexer class. Regular expression rules + specified as strings that don't match any name in tokens are + now reported as errors. + Version 0.2 ----------- diff --git a/sly/lex.py b/sly/lex.py index 9ac6575..82b5a24 100644 --- a/sly/lex.py +++ b/sly/lex.py @@ -141,6 +141,8 @@ class Lexer(metaclass=LexerMeta): for key, value in definitions: if (key in cls.tokens) or key.startswith('ignore_') or hasattr(value, 'pattern'): rules.append((key, value)) + elif isinstance(value, str) and not key.startswith('_') and key not in {'ignore'}: + raise LexerBuildError(f'{key} does not match a name in tokens') return rules @classmethod