Giving example for context-free grammar

176 Views Asked by At

Let $G$ be a grammar for some context-free language $L$, and let $F$ be a finite set of strings. Explain how to modify $G$ to create a context-free grammar for $L\cup F$.

Can someone give me an example to this problem?

1

There are 1 best solutions below

0
On BEST ANSWER

Let $S$ be the start symbol of your grammar and let $T$ be a new symbol not used in the grammar. If $F = \{u_1, \ldots, u_n\}$, just add the rules $S \to T$ and $T \to u_1 + \dots+ u_n$.