Is it possible to accept a bison-rule from the action in combination with the %glr-parser directive active?
Something like the following:
aRule : 'a' 'b' 'c' { /* Do some calculations and depending on those you allow/disallow this rule and continue the parsin开发者_如何学JAVAg without returning from the yyparse function. */ } ;
AFAICS there is no way to dynamically enable or disable some parts of the grammer. As a hack you can add special tokens as guards in the branches and let the tokenizer yield this extra tokens when some condition is met (I sometimes use an extra FORCE_ERROR token to force parse errors). And yes, this is ugly.
精彩评论