Given the following grammar: $$ E \to S$$ $$ S \to T \mid S+T $$ $$ T \to P$$ $$ P \to F\mid P*F $$ $$ F \to V\mid(E)$$ $$ V \to a\mid b\mid c$$
Does this grammar generate the words $(b*a)+c$ and $b*(a+c)$ ?
Given the following grammar: $$ E \to S$$ $$ S \to T \mid S+T $$ $$ T \to P$$ $$ P \to F\mid P*F $$ $$ F \to V\mid(E)$$ $$ V \to a\mid b\mid c$$
Does this grammar generate the words $(b*a)+c$ and $b*(a+c)$ ?
Short answer is yes. You just need to find the rule to generate that, which is easy once you see what they intuitively means.
More intuitively, it's just a standard grammar to generate all mathematical expression in +,* and a,b,c.
E: expression; S: sum; T: term; P: product; F: final element in the product; V: variable
So,the word $(b*a)+c$ is generated by the grammar. Is this right?
– Mary Star Jan 05 '14 at 20:59