[antlr-interest] charVocabulary having no effect
André Næss
andre.naess at gmail.com
Mon Dec 13 23:28:15 PST 2004
On Mon, 13 Dec 2004 11:37:03 -0800, Terence Parr <parrt at cs.usfca.edu> wrote:
> > To my Lexer options.
> >
> > But I'm still getting unexpected char errors. I have a fairly simple
>
> Is it because you have not included a rule to match those chars?
> Saying all ascii in the vocab means you must have a rule to handle any
> ascii char that comes in. For example, you have no rule for left
> bracket. If that comes along, you'll get an unexpected char error.
Well yes, there was no rule to match the character, not until I added
a dummy one anyway. But it was still my understanding that when I use
.*, or in my case:
(
options {
greedy=false;
}
: .
)*
charVocabulary would be used. Useful when you're matching strings for
example. In my case I want to discard that which is matched by the .*,
but what if I wanted to keep it?
> > The error goes away, but then it stops on some other char. This
> > continues until I've added all the chars not listed in some rule in
> > the lexer. So to be sure it seems I will have to explicitly list *all*
> > the ASCII characters.
>
> Well, yeah. If you want it to ignore stuff you don't have rules for,
> just set filter=true. :)
What I'm trying to achieve is to match a function prototype but ignore
it's body. Functions are declared using FUNCTION .. END_FUNCTION
pairs, so I use the above non-greedy (.)* construct to match the body.
But filter seems to work and is probably a much better idea, thanks
for the tip!
Regards
André Næss
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list