Here are some examples from a site on the internet.
  1. A grammar for simple sentences. Things in this language are:

    Things not in this language are:

    Here is the grammar:

  2. An ambiguous grammar for binary numbers:

  3. An unambiguous grammar for binary numbers:

  4. An ambiguous grammar for some arithmatic expressions using + and - and variables X, Y and Z. This grammar also does not assert any precedence between + and - or associativity.

  5. An unambiguous grammar for some arithmatic expressions using + and - and variables X, Y and Z. THis asserts * is performed before + and both * and + are done left to right.

  6. The following shows the ^ operator performed right to left

  7. This is ambiguous. Why?

  8. This solves the ambiguity but doesn't handle all cases that you might want.

  9. How is this language defined by this grammar different than the language above?

  10. This is a grammar for a language that has signed digits.

  11. This is a grammar for an even number of X's

  12. This is a grammar for numbers with no leading zeros and signs allowed on nonzero numbers.


Some more grammars with errors:

  1. This is ambiguous

  2. This is ambiguous

  3. This has a different sort of problem