Question: Consider the following context-free grammar. G G B G N B ( E ) E E ( E )
Consider the following context-free grammar.
G → G B
→ G N
→ ∈
B → ( E )
E → E ( E )
→ ∈
N → ( L ]
L → L E
→ L (
→ ∈
(a) Describe, in English, the language generated by this grammar. (Your description should be a high-level characterization of the language—one that is independent of the particular grammar chosen.)
(b) Give a parse tree for the string (( ]( ).
(c) Give a canonical (right-most) derivation of this same string.
(d) What is FIRST(E) in our grammar? What is FOLLOW(E)? (Recall that FIRST and FOLLOW sets are defined for symbols in an arbitrary CFG, regardless of parsing algorithm.)
(e) Given its use of left recursion, our grammar is clearly not LL(1). Does this language have an LL(1) grammar? Explain.
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
a Strings of balanced parentheses with the exception that a right square bracket matches all stillop... View full answer
Get step-by-step solutions from verified subject matter experts
