Derivation
list list + digit
list - digit + digit
digit - digit + digit
9 - digit + digit
9 - 5 + digit
9 - 5 + 2
Therefore, the string 9-5+2 belongs to the language specified by the grammar.
The name context free comes from the fact that use of a production X . does not depend on the context of X
For example, consider the string 9 - 5 + 2 . It can be derived as:
list list + digit list - digit + digit digit - digit + digit 9 - digit + digit 9 - 5 + digit 9 - 5 + 2
It would be interesting to know that the name context free grammar comes from the fact that use of a production X . does not depend on the context of X.
|