JFLAP - Context-Free Grammars

Steven Zeil

Last modified: Aug 12, 2016
Contents:

Abstract

Practice designing and working with CFGs, derivations, and parse trees.

  1. Review the Grammar section of the Tutorial, specifically the sections titled “Enter Grammar”, “Brute Force Parser”, and “User Control Parser”.

  2. Enter the grammar

    \[ \begin{align} E &\rightarrow I \\ E &\rightarrow E + E \\ E &\rightarrow E * E \\ E &\rightarrow (E) \\ I &\rightarrow a \\ I &\rightarrow b \\ I &\rightarrow Ia \\ I &\rightarrow Ib \\ I &\rightarrow I0 \\ I &\rightarrow I1 \\ \end{align} \]

  3. Run the User Control parser to perform leftmost and rightmost derivations of “a * b + a1”.

  4. Show that this grammar is ambiguous by deriving two distinct parse trees for “a * b + a1”.

  5. Do Exercises 5.1.2a,b,c from your textbook.