dangling-else

LL(1) grammar for dangling else

核能气质少年 提交于 2019-12-23 16:45:02
问题 In compiler construction, one of the main ambiguity problems is dangling else . As mentioned in Compilers: Principles, Techniques, and Tools book by Aho, Lam, Sethi and Ullman, the grammar for the dangling else can't be used with LL(1) parsers. Is it true that it can't be handled to be LL(1)? 回答1: Its true, it can't be parsed by LL(k) or by LALR(k) in their pure forms. The problem is that there are two possible interpretations of the dangling else; its an ambiguity problem ("else" belongs to