Hey Jim, thank you for taking care to answer.
> Don’t try to do that in the grammar. Allow as many of each as possible, then > reject additional ones via semantics – see antlr.markmail.org for many past > answers as to why, I googled before I asked here to find some hints, but unfortunately Google isn't what it used to be. You get a lot of noise, keeping you busy for hours without really helping you. But I'll utilize antlr.markmail.org in the future for my ANTLR questions. > but basically you will have: > > Error @line 4, offset 34: Additional b construct is illegal, only one is > allowed…. > > Instead of: > > Syntax error @line 4, offset 34: Found ‘b’, expecting one of a, c I see. Yes, this makes sense, however by having a grammar construct which would handle that (it could even generate the duplication error message, since it would know that a term must exist only once), things would be more compact and also compatible with different targets. On a side note: what's the rational behind having line numbers being one-based but character offsets zero-based? Mike -- www.soft-gems.net
_______________________________________________ antlr-dev mailing list [email protected] http://www.antlr.org/mailman/listinfo/antlr-dev
