You don't. You add a counter and parse everything that comes up, then you
issue a semantic error saying that there are too many inputStatements.
Always push the errors as far down the chain as you can as they gain more
context and are therefore clearer to the end user.

Jim

> -----Original Message-----
> From: [email protected] [mailto:antlr-interest-
> [email protected]] On Behalf Of devdoer bird
> Sent: Wednesday, February 16, 2011 9:05 PM
> To: antlr-interest Interest
> Subject: [antlr-interest] How can I make sure there's one such rule in
> the input ?
>
> HI:
>
> I have the grammar:
>
> statements:(inputStatement|schemaStatement|filtersStatement|COMMENT)*
> EOF;
>
>
> As you see ,it will match as many inputStatements as there are in the
> input file.
>
>
> How can change the grammar to  make sure there is only one
> inputStatment in the input file?
>
>
> Thanks.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address

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.

Reply via email to