COMS W4115
Programming Languages and Translators
Lecture 7: Parsing Context-Free Grammars
February 11, 2015


  1. Proving a language is not context free
  2. Closure and decidability results for context-free languages
  3. The parsing problem for context-free grammars
  4. Top-down parsing
  5. Transformations on grammars

1. Proving a Language is Not Context Free

2. Closure and Decidability Results for Context-Free Languages

3. The Parsing Problem for Context-Free Grammars

4. Top-Down Parsing

5. Transformations on Grammars

6. Practice Problems

  1. Write down a CFG for regular expressions over the alphabet {a, b}. Show a parse tree for the regular expression a | b*a.
  2. Using the nonterminals stmt and expr, design context-free grammar productions to model
    1. C while-statements
    2. C for-statements
    3. C do-while statements
  3. Consider grammar G:
          S →  S S + | S S * | a
    1. What language does this grammar generate?
    2. Eliminate the left recursion from this grammar.
  5. Use the pumping lemma to show that {anbncn | n ≥ 0 } is not context free.

7. Reading