I want to have a C++ try/catch block around every rule in a bison
script. Right now, I do:
begin: realbegin|invalid_last_rule{
; //this the actual rule
//REMOVED_BY_SCRIPT }//end of this rule
//REMOVED_BY_SCRIPT }//end of switch(yyn)
//REMOVED_BY_SCRIPT try { switch(yyn){
//REMOVED_BY_SCRIPT case -12345678: { UNREACHABLE();
}
realbegin:
all the rules
// This is the very last rule. No more rules after this !!!
invalid_last_rule: "$$CANTPARSEME" {
//This rule is never parsed. See the begin rule why
//REMOVED_BY_SCRIPT} //end of this rule
//REMOVED_BY_SCRIPT} //end of switch(yyn)
//REMOVED_BY_SCRIPT} //end of try block
catch(BaseException& e){
yyerror(&e.getPosition(),pinfo,e.getMessage());
}
switch(0)
//REMOVED_BY_SCRIPT {
default:
//REMOVED_BY_SCRIPT {
;
A script then removes the text "//REMOVED_BY_SCRIPT" from the bison
parser, leaving some extra }'s and {'s in the code
This method works, but is extremely ugly. Does someone have a better idea?
I can't use the C++ parsers, as I want the code to work on both past
and future versions of bison.
Thanks in advance
Hans
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison