开发者

Is it possible to factor out bin_op nonterminal in grammar specification?

Inconvenience in specifying grammars - we cannot factor out bin_op in following example (Bison):

expr : expr bin_op expr ;
bi开发者_如何学Gon_op : Add
    | Mul
    ;

because of shift/reduce conflicts. Is there parsing technique or parser generator which allows such thing?


Yes

Yacc has been employed to parse almost every real programming language and some other types. I'm not nearly its biggest fan but it can certainly parse that grammar or perhaps an equivalent that is written with yacc in mind.

And shift/reduce conflicts are not errors.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜