Hi!
I have a problem with my EBNF I was hoping for a little help with. I
have a block in my grammar that can contain certain keywords
zero-or-one times, and other keywords zero-or-many times. My current
solution is to enable every keyword to be zero-or-many, and then let
my semantic checker deal with the problem. But I was hoping to solve
it already on the grammar side, if possible.
The basic block looks like this:
: 'region' ID=Identifier? '{'
(
psinitial=psinitialDecl?
finalstate=finalstateDecl?
pshistory=pshistoryDecl?
psdeephistory=psdeephistoryDecl?
states+=stateDecl*
transitions+=transitionDecl*
)
'}' ';'?
And the only solution I have come up with, is to generate every
possible variant of this grammar, which is quite ugly.
What would be nice, would be something like this:
: 'region' ID=Identifier? '{'
(
psinitial=psinitialDecl?
finalstate=finalstateDecl?
pshistory=pshistoryDecl?
psdeephistory=psdeephistoryDecl?
states+=stateDecl*
transitions+=transitionDecl*
)*
'}' ';'?
(with * at the end). And for every match to one of the zero-or-one
rule, it would take it "away", so it can not be matched again. But
this does not work.
Any suggestions on how to solve this? If I have to end up with every
possible rule combination, then I would probably be better of just
doing it in the semantic checker as I was doing.
Regards,
Morten
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en.