What is an LR(2) parser? How does it differ from an LR(1) parser?
问题 I'm familiar with LR(1) parsers, which are usually taught in traditional compilers courses. I know that LR(2) parsers exist, but I've never seen one constructed before. How is an LR(2) parser constructed? How does it differ from an LR(1) parser? 回答1: In many ways, an LR(2) parser works similarly to an LR(1) parser. It traces out a rightmost derivation in reverse, maintains a stack, executes shift and reduce actions on a stack, has states that consist of sets of LR items, etc. There are,