LL(2) language that is not LL(1)

前端 未结 2 2177
天命终不由人
天命终不由人 2021-02-19 04:14

In order to further my understanding of parsers and grammars, I\'m searching for a (hopefully simple) example of a language that is LL(2) but not LL(1). That is, a lang

2条回答
  •  迷失自我
    2021-02-19 04:34

    The example mentioned in the book linked in Gunther's answer:

    S -> a S A | epsilon
    A -> a^k b S | c
    

    is a grammar describing an LL(k+1) language that is not LL(k). In particular,

    S -> a S A | epsilon
    A -> a b S | c
    

    is a grammar describing an LL(2) language that is not LL(1).

提交回复
热议问题