Is there a way to access the parser state/stack in p_error()?
All I know is that I can look at the offending token.
You can pass
parse when you call it and it will output the parser stack.
Here is the function definition for that, for convenience:
You can send the debugging output to a file too, if you set it up when you call
yacc. Here is that function definition, for convenience:
def yacc(method='LALR', debug=yaccdebug, module=None, tabmodule=tab_module, start=None, check_recursion=1, optimize=0, write_tables=1, debugfile=debug_file,outputdir='', debuglog=None, errorlog = None, picklefile=None):
You may find it useful to checkout the
parse methods in
yacc.py to see how this works.