▲ | sirwhinesalot 3 days ago | |||||||
Don't compute first and follow sets. Just branch on the current token. It is trivially unambiguous since 1 token = 1 branch. Expressions can be dealt with using precedence climbing / pratt, which still just amounts to branching on the current token after the "lhs" has been computed. If the language doesn't fit this LL1 + operator precedence mold then I would not use a recursive descent parser. | ||||||||
▲ | ufo 3 days ago | parent [-] | |||||||
The whole issue is that, without computing first and follow sets, it's easy to make a mistake and think that the grammar is LL(1) when it actually isn't. When that happens, the if statement does you no good. It'll be deterministic, but will silently mask the ambiguity. | ||||||||
|