![]() |
Sprex![]() |
||||||
|
| |||||||
|
News: Downloadable PDA Demos
Introduction |
* Make sure a line with %% and nothing else separates the TYPE
declarations and the rules
* Make sure the type declared in a TYPE statement is surrounded by
quotation marks ("), as in TYPE "char *" $STRING_VALUED_RULE
* Make sure each rule, including the final rule, is terminated by a
semicolon, and that each action's final expression is NOT
terminated by a semicolon.
* Action variables count from 1 (not from 0!) up to the least number
of words in any of the associated alternatives in the expansion.
* All the alternatives within a rule's expansion associated
with a given action must have the same number of words,
so that action variables can count appropriately.
If you do have extra words in an alternative, the action will
ignore them.
* Every action must end with an expression which is (or can be cast to)
the correct data type specified for that rule in the TYPE section.
This expression must be present and must not be terminated by a semicolon.
* "parse error before "else"":
The action-final expression cannot be nested inside an if-else
control structure. For example the following will produce a
compilation error (and a logic error):
$NOYOU = no you
{
static int i = 0;
if (i++)
reply("YOU");
else
reply("no_YOU")
}
;
The intent here was for the return value of the NOYOU action to come
from the final statement of either branch of the if..else.. structure.
But gxc cannot implement this intention: gxc writes the
action function so as to return() the value of the final statement;
but the entire if..else.. construct cannot itself be passed as an argument
to return().
It's easy to work around this. Simply assign the final expressions
of both branches to an intermediate variable, and tell gxc to return
its value, as in this fixed version of the above action:
$NOYOU = no you
{
static int i = 0;
int r;
if (i++) { r = reply("YOU"); }
else { r = reply("no_YOU"); }
r
}
;
Here, the intended result is implemented, since gxc converts the
final expression to "return(r)".
* Whitespace is ignored except to separate tokens in the .gx file.
* Comments are considered whitespace. Comments start with // or #
followed by any other text up until the end of the line, \n.
* Make sure every rule has a TYPE declaration, including the last,
all-encompassing rule. If you see functions in the .c file declared
as type "(null)" then this is the problem. Give that rule a TYPE.
* Rule names always start with a $, whether it is being TYPE'd,
defined, or used.
* No circular reference! Rules must be defined before they are used.
If you need recursion, make different rules for each layer
that you want to model.
|
||||||
Copyright © 1996-2005
Sprex, Inc.
All rights reserved. Sprex, Speech in the Network, TallyGram and ANSR are trademarks of Sprex, Inc.
|