Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はEBNF表記でこの文法を持っています:
expr -> expr (opt1 | opt2 | opt3) expr
そして、Bisonで使用するためにBNFに変換したいのですが、これでshift/reduceエラーが発生します。
expr : expr opt1 expr | expr opt2 expr | expr opt3 expr
途中で何か誤解したと思います。何か助けはありますか?
ありがとう
どうですか
expr: expr optexpr expr optexpr: opt1 | opt2 | opt3
シフト/リデュースエラーは、exprプレフィックスが重複していることが原因です。別の定義を導入することにより、exprの構文解析が明確になります。