Contents Back Forward |
| |||||||||||||||||||||||||||||||||||||||||||||||
A 'verb' is a set of possible initial words in keyboard command, which are
treated synonymously (for example, "wear'' and "don'') together with
a 'grammar'. A grammar is a list of 'lines' which the parser tries to match,
one at a time, and accepts the first one which matches. The directive
Verb [meta] <verb-word-1> ... <verb-word-n> <grammar>creates a new verb. If it is said to be meta then it will count as 'out of the game': for instance "score'' or "save''. New synonyms can be added to an old verb with: Verb <new-word-1> ... <new-word-n> = <existing-verb-word>An old verb can be modified with the directive Extend [only] <existing-word-1> ... <existing-word-n> [<priority>] <grammar>If only is specified, the existing words given (which must all be from the same existing verb) are split off into a new independent copy of the verb. If not, the directive extends the whole existing verb. The priority can be first (insert this grammar at the head of the list), last (insert it at the end) or replace (throw away the old list and use this instead); the default is last. A line is a list of 'tokens' together with the action generated if each token matches so that the line is accepted. The syntax of a line is * <token-1> <token-2> ...<token-n> -> <action>where 0 <= n <= 31. The action is named without initial ## signs and if an action which isn't in the standard library set is named then an action routine (named with the action name followed by Sub) must be defined somewhere in the game. A grammar line can optionally be followed by the word reverse. This signals that the action to be generated has two parameters, but which have been parsed in the wrong order and need to swapped over. (Note that a topic is not a parameter, and nor is a preposition.)
A token matches a single particle of what has been typed. The possible
tokens are:
Two or more literal words (only) can be written with slash signs / between them as alternatives. E.g., "in"/"on" matches either the word "in'' or the word "on''. For the
For the
A general parsing routine can match any text it likes. It should use wn, the variable holding the number of the word currently being parsed (counting from the verb being word 1) and the routine NextWord() to read the next word and move wn on by 1. The routine returns: -1 if the user's input isn't understood,In the case of a number, the actual value should be put into the variable parsed_number. On an unsuccessful match (returning -1) it doesn't matter what the final value of wn is. Otherwise it should be left pointing to the next thing after what the routine understood.
|