How to determine whether a language is LL(1) LR(0) SLR(1)

前端 未结 7 1536
暗喜
暗喜 2020-12-08 07:56

Is there a simple way to determine whether a grammar is LL(1), LR(0), SLR(1)... just from looking on the grammar without doing any complex analysis?

For instance: To

7条回答
  •  佛祖请我去吃肉
    2020-12-08 08:29

    p0 S' → E
    p1 E → id
    p2 E → id ( E )
    p3 E → E + id
    
    • Construct the LR(0) DFA, the FOLLOW set for E and the SLR action/goto tables.
    • Is this an LR(0) grammar? Prove your answer.
    • Using the SLR tables, show the steps (shifts, reductions, accept) of an LR parser parsing:
      id ( id + id )

提交回复
热议问题