Does the grammar generate the words?

54 Views Asked by At

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)$ ?

1

There are 1 best solutions below

2
On BEST ANSWER

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