John Darrington <[EMAIL PROTECTED]> writes:
> I'm battling with the lexer again implementing subcommands of NPAR
> TESTS. The problem is, some of the subcommands have hyphens. Eg
> NPAR TESTS /K-W foo BY bar (1,2).
> I ran into this once before with T-TEST, which could be worked around
> with a bit of a kludge, but I can't see how to do this in the present
> case without becoming very inelegent.
Are you parsing by hand or with q2c? If you're doing it by hand,
then you should be able to do something like this:
if (lex_token (lexer) == T_ID
&& !strcmp (lex_tokid (lexer), "K")
&& lex_look_ahead (lexer) == '-')
{
/* We know we're at "K-". The only acceptable
follow-on to this is "W". */
lex_get ();
lex_force_match (lexer, '-');
if (!lex_force_match_id (lexer, "W"))
{
....abort parsing....
}
...got K-W...
}
else
{
...not K-W...
}
If you are using q2c, we will have to teach it a similar trick.
--
Ben Pfaff
http://benpfaff.org
_______________________________________________
pspp-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/pspp-dev