Prelab 3: Grammars

  1. Read Chapter 2 in Great Ideas.

  2. Read the definition of a grammar at the Free on-Line Dictionary of Computing.

    Grammar and grammar parsing involves constructing a sentence (in programming, you construct a legal statement). Your sentence is constructed with a basic skeleton, in which you define what different parts need to be put together to build your sentence. The best way to understand this concept is to review the examples.

  3. Examine the practice grammars. You can access them at either of the following locations:


    Note how they are written and how they are formatted. The Poem.g grammar in particular is a good one to emulate since it is rather simple. You can use this applet to try out the various grammars in the grammar directory.

  4. Come up with your own grammar idea and write it out in the form of grammars found on page 78-80 in the Great Ideas in Computer Science with Java. Your grammars must meet the following criteria:

    1. Your grammar should include at least 2 non-terminal tags as described in the notes from class.

    2. Your grammar should produce at least 8 different sentences when expanded.

    3. Your grammar should be original.


    If you would like to get a head start on Lab 3, you can test your grammars in the Random Sentence Generator.

All of the preceding must be done before lab begins. It will not be accepted after the lab is in session.


Jeff Forbes
Last modified: Fri Sep 16 11:36:29 EDT 2005