Making a Grammar LL(1)
问题 I have the following grammar: S → a S b S | b S a S | ε Since I'm trying to write a small compiler for it, I'd like to make it LL(1). I see that there seems to be a FIRST/FOLLOW conflict here, and I know I have to use substitution to resolve it, but I'm not exactly sure how to go about it. Here is my proposed grammar, but I'm not sure if it's correct: S-> aSbT | epsilon T-> bFaF| epsilon F-> epsilon Can someone help out? 回答1: In his original paper on LR parsing, Knuth gives the following