Added extra validation check in Lexer construction
This commit is contained in:
parent
e9346daff0
commit
b74e7223ce
6
CHANGES
6
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
|
||||
-----------
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user