<p>Here is one useful strategy. The union of context-free languages is context-free. If you can think of your target language as the union of simpler pieces, and you can think of a grammar for each piece (with start symbol <span class="math-container">$A_1$</span>, <span class="math-container">$A_2$</span>, etc.) then you can join all the grammars together with a production like <span class="math-container">$S \to A_1 \mid A_2 \mid \cdots$</span>.</p>

CC BY-SA 4.0
2021-11-18T22:09:55.253Z
2021-11-18T22:09:55.253Z
Dave R
<p>One thing that I am very clear is that there is no hard and fast algorithm to create CFG. The only wat to practice only. But how do I deal with new questions in exam? Are there types of problems that I need to know in order to be able to solve different types of problems? Can you guide me a bit about this issue?</p>

CC BY-SA 4.0
2021-11-11T10:59:55.747Z
What is CFG? That is new to me.
Buffy
CC BY-SA 4.0
2021-11-11T13:09:46.433Z
@Buffy   [CFG](https://en.wikipedia.org/wiki/Context-free_grammar) - Context Free Grammar.
Guy Coder
CC BY-SA 4.0
2021-11-11T13:20:52.903Z
@GuyCoder Hmmm. It shouldn't have flown by me, I guess.
Buffy
CC BY-SA 4.0
2021-11-11T13:22:54.780Z
You need to say more. The structure of a CFG is standard. Are you asking about finding a grammar for a given language? Or about creation of a context free language through a grammar definition? Something else? Distinguishing LL languages/grammars from LR?
Buffy
CC BY-SA 4.0
2021-11-11T14:26:16.273Z
@GuyCoder, actually, I taught language principles and compilers for about 20 years. Getting old. Not Dead Yet.
Buffy
CC BY-SA 4.0
2021-11-11T16:02:29.633Z
I'm not sure why this is being close-voted, I think it's an excellent question, with important bearing for educators. There *are* some standard formations that will get you pretty far, and teachers would certainly benefit from thinking through them.  I've thought through them for PDAs, and I provide those to my students for practice, but I don't have them specifically in CFG form.
Ben I.
CC BY-SA 4.0
2021-11-16T08:54:23.373Z
@BenI. dear sir, can you please share that pdf here? i have already learnt pda but types will be very helpful.
supcem
CC BY-SA 4.0
2021-11-16T13:22:07.910Z
@supcem I don't have a pdf, I have a series of exercises spread out over two consecutive powerpoints, with the strategies conveyed orally to the students after they try each exercise.  If it were easier to pull together for this sort of purpose, I would have already done it :)
Ben I.
<self-learning>
How do I figure the types of problems in making Context Free Grammars?
# How do I figure the types of problems in making Context Free Grammars?

(Asked by: username_0 on 2021-11-11)

One thing that I am very clear is that there is no hard and fast algorithm to create CFG. The only wat to practice only. But how do I deal with new questions in exam? Are there types of problems that I need to know in order to be able to solve different types of problems? Can you guide me a bit about this issue?

**Tags:** self-learning

> **Comments:**
> **username_1**: What is CFG? That is new to me.  
> **username_2**: @username_1   [CFG](https://en.wikipedia.org/wiki/Context-free_grammar) - Context Free Grammar.  
> **username_1**: @GuyCoder Hmmm. It shouldn't have flown by me, I guess.  
> **username_1**: You need to say more. The structure of a CFG is standard. Are you asking about finding a grammar for a given language? Or about creation of a context free language through a grammar definition? Something else? Distinguishing LL languages/grammars from LR?  
> **username_1**: @GuyCoder, actually, I taught language principles and compilers for about 20 years. Getting old. Not Dead Yet.  
> **username_3**: I'm not sure why this is being close-voted, I think it's an excellent question, with important bearing for educators. There *are* some standard formations that will get you pretty far, and teachers would certainly benefit from thinking through them.  I've thought through them for PDAs, and I provide those to my students for practice, but I don't have them specifically in CFG form.  
> **username_0**: @BenI. dear sir, can you please share that pdf here? i have already learnt pda but types will be very helpful.  
> **username_3**: @username_0 I don't have a pdf, I have a series of exercises spread out over two consecutive powerpoints, with the strategies conveyed orally to the students after they try each exercise.  If it were easier to pull together for this sort of purpose, I would have already done it :)  

---

## 1 answers

### Answer by username_4 on 2021-11-18. Score: 0

Here is one useful strategy. The union of context-free languages is context-free. If you can think of your target language as the union of simpler pieces, and you can think of a grammar for each piece (with start symbol $A\_1$, $A\_2$, etc.) then you can join all the grammars together with a production like $S \to A\_1 \mid A\_2 \mid \cdots$.


---

