[antlr-interest] How to parse Several Option in one group in dífferent order
Thomas Brandon
tbrandonau at gmail.com
Wed Aug 1 02:14:31 PDT 2007
On 8/1/07, Martin Kortmann <email at kortmann.de> wrote:
> Hi,
>
> I have to parse a textfile which is divided in several
> groups. Inside of this groups where several options.
> This option can occur in any order, but only zero or
> one times. I have this construction:
>
> header: BEG 'HEADER'
> ( project_no version
> | version project_no
> | version
> | project_no
> |
> )
> END 'HEADER'
> ;
>
> This is OK for only two options, but i have also
> sections with mor than ten options.
>
> How can i made this rule easier? Does i have to track
> this by hand?
Yes. Add an action to track seen options. You could add a semantic
predicate that only allowed an option that hadn't been seen, but are
probably best just using an action to report any duplicates as you
probably don't want to generate a parser error when an option is
duplicated.
Tom.
>
> Martin
>
More information about the antlr-interest
mailing list