Phoenix Grammar Reference
The format of the Phoenix grammar file is as follows. First, all blank lines and lines starting with a pound sign (#) are ignored. These can be used to comment your grammar, which is a very important thing to do if you want to be able to maintain it. Apart from these, everything in the grammar file comes in the form of a slot definition. A slot is a symbol that captures a subset of language, such as "place names" or "ways to say that you want the time for the next bus". The general structure of a slot definition is as follows:
[SlotName] (word1 word2 [other_slot] VARIABLE1) (word3 VARIABLE2 *word4 VARIABLE1) VARIABLE1 (word5) (word6 word7) VARIABLE2 (word8) (word9) ;
All block starts with the name of the slot they define, and ends with a semi-column. Slot names are always enclosed in square brackets. In between are strings of words between parentheses. The words there are of three types:
- standard words: these are the actual natural language words. They are sometimes called terminal symbols because they cannot be decomposed any further. They are always written in lower case.
- slot names: slots are defined recursively in that you can use slots within other slots. By convention, slots that are expected at the top level (i.e. that match full inputs or sentences) are "camel-case" (as in this case SlotName), whereas slots that only appear within other slot definitions are lower case (as "other_slot").
- variables: these are all-caps words that behave like slots but are only defined within this particular slot definition (and not accessible from others). Variables are defined below the parenthesized strings (but before the semi-column) as shown above.
Finally, note the use of the star symbol "*", which denotes an optional word (e.g. "the *blue bus" matches both "the blue bus" and "the bus"). It can be applied indifferently to terminals, slots, and variables.