Exercise 6, Grammar Development

For this exercise you can work with grammar-coord.lfg, which has integrated a start on imperatives and coordination. Alternatively, you can look at what has been added in grammar-coord.lfg and use it as a model while continuing work on your own grammar version.

The grammar has been changed so that its top node is a category ROOT, rather than the S you have been working with (via the change in the configuration file under ROOTCAT). This conforms to the ParGram grammars and allows for the introduction of different types of main clauses (questions, imperatives, etc.).


Now add some imperatives to your grammar. The following sentences should work.

  1. Eat the beans!
  2. Give the gorilla a banana!
  3. Think a creative thought!
The following sentences should not work.
  1. Eats the beans!
  2. Gave a bone to the dog!

You will need to make (at least) the following changes to your grammar:

Metarulemacros and Coordination

XLE allows for Metarulemacros. Metarulemacros allow the grammar writer to express generalizations that hold for all the rules of a grammar. In the ParGram grammars, this is generally used at least for coordination.

Expand your grammar to include coordination. Basically you will need to copy and paste the following from grammar-coord.lfg: METARULEMACRO, SCCOORD, NPCOORD, NP-CONJUNCT. You will also need the lexical entry for and Also add the OT-Mark GenBadPunct in GENOPTIMALITYORDER as has already been done in grammar5.lfg.

The following sentences should work:

Note that you will also have to add entries for proper names and decide on how to treat these in your grammar. Hint: check the output of the big English ParGram grammar via the INESS XLE-Web site for inspiration on how to treat proper nouns.

Backward Compatibility

Note that as your grammar is expanding, you need to ensure backwards compatibility. So, when you hand in the grammar that solves this exercise, you also need to hand in a testsuite that: a) includes the sentences from this exercise; b) includes the sentences from all the previous exercises; c) sentences you came up with yourself in previous exercises to test your grammar. You should run your testsuite (we will also do this and check your grammar for backwards compatibility) and make sure that everything still works as expected.

Relevant Reading Material

Empty Strings and Nodes in the XLE Documentation.

XLE documentation on Metarulemacros

XLE documentation on Regular Expression Macros

Chapter 13 in Dalrymple (2001)

XLE documentation on Scope relations