Semantic validation
In the semantic validation step, the ZurkParser should not
merely parse the GAME FILE, but should compile the same data
structures that the Zurk engine would employ. Rather than
entering into the user-interface loop, however, ZurkParser
in semantic validation mode will dump the contents of the data
structures in a Scheme-like format.
The data structure dump MUST obey the following rules:
- Dump all ROOM declarations first, followed by OBJECT
declarations, and finally ACTION declarations.
- Dump the contents of all structures in the order declared in
the WDL grammar (Section 4.2.2.3).
- All structures MUST be dumped in the following, Scheme-like prefix
syntax:
(TYPE prop1 ... propN)
followed by a newline, where TYPE is the type of the
structure (ROOM, ACTION, ROOMREF,
AND, OR, NOT, EQ, etc.) and
prop1...propN are the properties associated with
that structure.
E.g., for a ROOM object, its properties are NAME,
DESCRIPTION, OBJECTS, and MOVES. All types
MUST be printed in upper-case.
Data structures MUST be dumped only after the entire parse is completed.
Data structures MUST NOT be dumped if any syntax error is encountered
during parsing; instead, a syntax error (of the same type printed by
the syntactic analyzer) MUST be printed and the semantic validation
step exited.
In addition, the semantic validator MUST verify the following:
- All ROOM, ACTION, and OBJECT declarations are unique.
- All referenced things (ROOMs, OBJECTs, VARIABLEs, etc.) are
declared once and only once in the GAME FILE. For VARIABLEs,
the absolute name must be used to verify declarations (e.g.,
to distinguish between rose.color and
door.color).
- Every OBJECT is assigned to one and only one LOCATION.
- All relative lval references in an ACTION obey the declared
arity of that ACTION.
- That no condstatement in any MOVE employs any relative
lvals. (Since MOVEs have arity 0, this is a consequence of the
above.)
- Reachability: that every ROOM is referenced as a target in at
least one MOVE or ACTION. (Note that such a reference does not
guarantee that the ROOM is reachable, but only that it
is potentially reachable.)
A notification MUST be printed, after the data structure dump, only if
one or more of these conditions is violated. The format of the
notification is up to the designer, but it MUST at least include the
nature of the violation and as much detail about the location as possible. E.g., ERROR: condstatement
references $3, but arity of Action(get) is only 1. Or,
ERROR: Room(garden) references ObjRef(rake), but no
Object(rake) has been declared.
An example of a semantic analysis is given in Appendix C.
Terran Lane
2005-02-28