[vox-tech] how to get yacc/bison to say "i'm confused"
Peter Jay Salzman
vox-tech@lists.lugod.org
Thu, 27 Dec 2001 10:51:59 -0800
newbie here.
i'm using flex/bison for processing a program's user input, and have a
list of rules that define the user input grammar.
after bison processes all it's input, is there a way of telling it:
if no rule matched the input, take your input and feed it to
ParseError(const char *error)?
the problem i'm having is typically:
ruleset: TOK_RULESET NUMBER { ChangeRuleset($2); }
| TOK_RULESET { ChangeRuleset(-1); }
if the user types something like "ruleset asdf", it'll match
"TOK_RULESET", and (i think) "asdf" gets put back into the buffer since
it's not a NUMBER, and is processed the next time the user inputs
something. in other words, bison gets out of sync and confused.
i have a rule like:
(snip)
WORD { ParseError($1); }
;
and this handles truly garbled input, like "qwerty", but doesn't handle
the situation i outlined above.
thanks,
pete
--
PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
PGP Public Key: finger p@dirac.org