Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-18T22:09:55.253Z
Answers.LastActivityDate: 2021-11-18T22:09:55.253Z
Answers.UserDisplayName: Dave R
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T10:59:55.747Z
Comments.Text: What is CFG? That is new to me.
Comments.UserDisplayName: Buffy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T13:09:46.433Z
Comments.Text: @Buffy   [CFG](https://en.wikipedia.org/wiki/Context-free_grammar) - Context Free Grammar.
Comments.UserDisplayName: Guy Coder
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T13:20:52.903Z
Comments.Text: @GuyCoder Hmmm. It shouldn't have flown by me, I guess.
Comments.UserDisplayName: Buffy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T13:22:54.780Z
Comments.Text: 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?
Comments.UserDisplayName: Buffy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T14:26:16.273Z
Comments.Text: @GuyCoder, actually, I taught language principles and compilers for about 20 years. Getting old. Not Dead Yet.
Comments.UserDisplayName: Buffy
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-11T16:02:29.633Z
Comments.Text: 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.
Comments.UserDisplayName: Ben I.
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-16T08:54:23.373Z
Comments.Text: @BenI. dear sir, can you please share that pdf here? i have already learnt pda but types will be very helpful.
Comments.UserDisplayName: supcem
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-16T13:22:07.910Z
Comments.Text: @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 :)
Comments.UserDisplayName: Ben I.
Tags: <self-learning>
Title: How do I figure the types of problems in making Context Free Grammars?
ThreadText: # 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**: @username_2 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**: @username_2, 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$.
  
  
  ---
  
  