Hi,
I'm new to bison and this list so forgive me if I'm asking something
that has been asked before. I've done quite a bit of reading and
searching and haven't found the answer yet.
My goal is to parse a comma separated list and validate the values
that I find therein. I don't have a problem parsing the list. This is
fairly straightforward.
What I would like to do in addition to parsing the list is to validate
that each value I find in that list is one of a set of strings. That
is, I want to validate that each item in the list is correct.
Each token in the list can be a one or two character uppercase string.
i.e. [A-Z]{1,2}
I'd like the parser to raise an error if the parsed token isn't one of
the ones in the predetermined list. Let's say the predetermined valid
list is: AA,BB,C,DE
If BD is entered this should raise an error.
Is this something that would be done in bison? Or would it be better
to handle this post-parse? Or in another context?
Here's what I have in the parser atm:
itemlist: CODE
{
strcat(wordbuf, $1);
}
|
itemlist CODE
{
strcat(wordbuf, ","); strcat(wordbuf, $3);
}
;
Many thanks,
Matt
_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison