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.
精彩评论