Programming Languages Class: Given the grammar (1) E Prefix ( E ) (2) E V Tail (
ID: 2246901 • Letter: P
Question
Programming Languages Class:
Given the grammar
(1) E Prefix ( E )
(2) E V Tail
(3) Prefix F
(4) Prefix
(5) Tail + E
(6) Tail - E
(7) Tail
( is defined as the empty set, NULL or -> )
Determine whether F(V-V) is syntactically correct using left-most derivation. Show your work.
Explanation / Answer
Yes F(V-V) is syntactically correct. The following shows the left most derivation.
Since there is no starting variable given I would assume E to be the start as it is the first varaible. So in the left most derivation we have to replace the left most variable by its productions. So beginning now:
E ->Prefix(E) Beginning Production as we want F outside the parenthesis
E->F(E) By using Prefix->F
E->F(V Tail) By using E->V Tail
E->F(V - E) By using Tail->-E
E->F(V - V Tail) By using E->V Tail
E->F(V-V) By using Tail->null
This proves that we can derive E->F(V-V) using the left most derivation.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.