Problem 19.5 of languages ββand machines Sudkamp asks the reader to verify that the grammar
G : S' -> S
strongly LL(2) . The set of FIRST and FOLLOW for the variable S calculated using algorithm 19.5.1 (p. 583, 3rd ed.):
FIRST(2)(S) = {Ξ»,aa,bb,ab,ba} FOLLOW(2)(S) = {
It is clear that definitions of look-head of length-2 for rules S will not break the set of look-head length-2 for S , because of the rule S -> Ξ» , which leads to the appearance of length-2 set consisting of FOLLOW(2)(S) :
LA(2)(S) = {
Now itβs possible that I made a mistake when calculating the FIRST , FOLLOW or LA(2) sets for G However, I am sure that the algorithm performed correctly. In particular, I can return to their definitions:
FIRST(2)(S) = trunc(2)({x : S =>* x AND x IN Ξ£*}) = trunc(2)({uu^R : u IN {a,b}^*}) = {Ξ»,aa,bb,ab,ba} FOLLOW(2)(S) = trunc(2)({x : S' =>* uSv AND x IN FIRST(2)(v)}) = trunc(2)({x : x IN FIRST(2)({a,b}^*{
Now the question arises: why is LL(2) strong grammar LL(2) . If the look-head set of length-2 for S rules does not break the set of look-head of length-2 for S , then the grammar should not be strong LL(2) . But I cannot come to the conclusion expected in the book. What? I do not understand?
source share