What advantages do LL parsers have over LR parsers?

后端 未结 6 1498
感情败类
感情败类 2021-01-30 04:36

What advantages do LL parsers have over LR parsers to warrant their relative popularity in today\'s parser generator tools?

According to Wikipedia, LR parsing appears to

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-30 04:57

    From my personal experience (I used both for various situations), the most practical difference is that, with a LL(k), you can define the grammar in an easier way (since it's top-down) without caring about many possible reduce-reduce or shift-reduce conflicts which often occur with LR parsers. The only thing you have to care about is left-recursion which must be transformed into right one.

    Another thing is that the top-down approach usually implies a higher complexity (regarding either space or time), because it has to store the whole tree while parsing and it can grow a lot until ambiguities are solved.

提交回复
热议问题