Read Chapter 2 in Great Ideas.
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.
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.
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:
Your grammar should include at least 2 non-terminal tags as described in the notes from class.
Your grammar should produce at least 8 different sentences when expanded.
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.