开发者

Accept a yacc-rule from an action

开发者 https://www.devze.com 2022-12-23 00:21 出处:网络
Is it possible to accept a bison-rule from the action in combination with the %glr-parser directive active?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消