-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Description
background
Code generated by goyacc has a dependence on package globals that it doesn't need to have.
yyDebug, and yyErrorVerbose do not specifically need to be globals, and can be variables on the parser instead.
I did not find documentation for bison/yacc that states YYDEBUG or a YYERRORVERBOSE need to be made available inside grammar actions.
We can follow java here and expose them via the Parser which is already technically available to grammar actions but not documented.
description
I'm proposing the following
- Move
yyDebug, andyyErrorVerboseintoyyParserImpl - For compatibility, modify
yyNewParserto grab the value of the package globals, and set them internally when called- something like `return &$$ParserImpl{ debug: $$Debug, errorVerbose: $$ErrorVerbose}
- Create a new
yyNewParser###function that exposeddebug, anderrorVerboseas inputs - Create a new
yyParse###function that exposeddebug, anderrorVerboseas inputs - Modify the
yyParserinterface to expose, and allow modification of, the internal state ofdebug, anderrorVerbose - Modify
yyParserImplto match the updatedyyParserinterface
drawbacks
There is potential that if someone had already written a customer parser to match yyParser their parser would no longer match the interface
Any grammar actions that depend on yyDebug or yyErrorVerbose would break. A key point here is this behavior doesn't seem to be well defined
anyways, and I'm not sure if the intention was to make them available in grammar actions.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status