COMS W3261
Computer Science Theory
Lecture 10: October 14, 2009
Context-Free Grammars

1. Outline

2. Review

3. Definition of a Context-Free Grammar (CFG)

4. Derivations

5. Leftmost and Rightmost Derivations

6. Parse Trees

7. Practice Problems

  1. Construct a CFG that generates { anbn | n ≥ 0 }:
  2. Construct a CFG that generates { wwR | w is any string of a's and b's }:
  3. Construct a CFG for arithmetic expressions with the operators + and *, parentheses, and a constant c.
  4. Construct a CFG for regular expressions over the alphabet {0, 1}.

8. Reading Assignment



aho@cs.columbia.edu