def p_error(self, p): next_t = yacc.token() raise ParseError("invalid code before %s (at line %s)" % (repr(next_t.value), next_t.lineno))