How can I stop the parser if an error detected?
The example
def t_error(t): print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1)
shows only a skip but I need a stop. How to archive?
You can raise an exception when you encounter an error in the lexer. For example:
class LexerError(Exception): pass def t_error(t): raise LexerError("Illegal character '%s'" % t.value)
You can raise an exception when you encounter an error in the lexer. For example: