rightarrow rightarrow rightarrow 0 1 where and are var
rightarrow | + |- rightarrow | rightarrow 0 | 1 where , and are variables and + -, 0 and 1 are terminals. is the start variable. Determine if the following strings are generated by the above grammar. If it is generated by the above grammar, derive the string. 01 + 11 - 10 -001 + 100 01 +-11 + 1 1010
Solution
a) E -> E-E->E+E-E-> B+B-B->DB+DB-DB->DD+DD-DD-> 01+11-10
(b) and (c) are not derivable->(d) E->B->DB->DDB->DDDB->DDDD->1010
