What is the difference between LR(0) and SLR parsing?

后端 未结 2 1040
太阳男子
太阳男子 2021-01-29 17:41

I am working on my compilers concepts however I am a little confused... Googling got me nowhere to a definite answer.

Is SLR and LR(0) parsers one and same? If not, what

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 18:04

    This is what I have learnt . Usually LR(0) parser can have ambiguity, i.e one box of the table (you derive for creating the parser) can have multiple values (or) to better put it : the parser leads to two final states with the same input. So SLR parser is created to remove this ambiguity. Inorder to construct it find all the productions which lead to goto states , find the follow for the production symbol on the left hand side and only include those goto states which are present in the follow . This inturn means that you dont include a production which is not possible using the original grammer(coz that state is not in the follow set)

提交回复
热议问题