Reading traces from the unifier is a particularly tedious task. The main problem is that the messages generated by the program are very similar to each other. The :demo directive allows the grammar writer to bring some variety to these messages. A demo-message can be used to output a specific message during the trace of the program when entering an alt (or a ralt) construct. The syntax is indicated by the following figure:
(alt voice (:demo `Is the voice active ~
or passive?')
(((voice active)
...)
((voice passive)
...)))
|
The message will be printed in the trace of the program (only if the tracing flag voice is enabled) as shown:
|
Note that the message is indented in the stream of trace messages. Such messages allow the grammar writer to put some semantic information into the trace messages, so that the whole stream of messages can be more easily interpreted.
In addition to its position at the top of an alt construct, a demo-message can be embedded anywhere in a grammar by using the control-demo function. Control-demo must be used within a control pair and produces an indented demo message in the trace stream. The following example illustrates its use: control-demo
(alt from-loc (:demo `Is there a from-loc role?')
(((from-loc none)
%TRACE-OFF%
(control (control-demo `No from-loc'))
%TRACE-ON%)
((from-loc given)
%TRACE-OFF%
(control (control-demo `From-loc is here'))
%TRACE-ON%)))
|
NOTE: The control pair containing a control-demo call should be put within a %TRACE-OFF% - %TRACE-ON% pair to avoid the printing of system trace messages regarding the control pair.
NOTE: The demo message string is passed to the format common-lisp function, and can therefore contain formatting characters accepted by that function (e.g., ~ or ~%). Refer to your CommonLisp manual for details.