Similar questions 7 more →
Parsing & Syntax Analysis


Answer & solution
Answer: Nonempty table entries: Program/begin; X/d,X/s; Y/semi,Y/end. (no official key was published)
Step through it (2 parts)
FIRST(Program)={begin}; FIRST(X)={d,s}; FIRST(Y)={semi,ε}. Program is the start symbol, so FOLLOW(Program)={$}. In Program's production, X is followed by end, hence FOLLOW(X)={end}. The occurrence Y at the end of X→sY gives FOLLOW(Y)={end}; its recursive production adds no new follower.
Fill a production in columns belonging to the FIRST set of its right side. For the ε production, use FOLLOW(Y). The complete non-error entries are:
Nonterminal | lookahead | production Program | begin | Program→begin d semi X end X | d | X→d semi X X | s | X→sY Y | semi | Y→semi sY Y | end | Y→ε
Every other cell, including all cells under $, is an error for these nonterminals. The parsing stack accepts only when both its end marker and the input end marker match after Program is fully processed. There is no conflict: X's alternatives start with different terminals, and FIRST(semi sY)={semi} is disjoint from FOLLOW(Y)={end}. That establishes LL(1), rather than merely presenting a table without explaining why it works.