E --> E + T | T
T --> T * F | F
F --> (E) | Id
find (a) FIRST (T), FIRST (T * Id) and (b) FOLLOW (E).
A --> d A
A --> d B
A --> f
B --> g
S --> X d
X --> C
X--> B a
C -->
B --> d
S --> XX
X -->xX
X --> y
(a) Show that it is LL(1).
(b) Create a parsing table.
(c) Parse the string xyyx .
(d) Draw the parse tree.
E --> T E'
E' --> + T E' |
T --> F T'
T' --> * F T' |
F --> Id | (E)
(a) Show that the FIRST (E) = { (, Id }
(b) Show that FOLLOW (T) = { +, ) }
T --> T * F | F
F --> (E) | Id
(a) Left-recursion: Show what would happen if we tried to parse a*b + c using this grammar.
(b) Eliminate the left-recursion from each production of this grammar to produce the grammar in Example 7.
E --> E + E | E - E | E * E | E / E | ( E ) | Id
is ambiguous (produces more than one parse is for a given input).
(b) Show that an ambiguous grammar cannot be LL(1).
(b)Derive an algorithm for eliminating this problem.
S -->i E t S(a) Show that this grammar is not LL(1)| i E t S e S
| i E t S e S
E --> c
(b) Create an LL(1) parsing table. (Since the grammar is not LL(1), there will be at least one double entry.)
(c) Show a top-down parse for:
IF c THEN IF c THEN a ELSE a
associating "ELSE" with the closest IF, i.e., choose the table entry that will enforce this: