tags:

views:

22

answers:

1

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 parsing without returning from the yyparse function. */ } ;

A: 

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.

Rudi