[antlr-interest] Matching all "other" text
Vaclav Barta
vbar at comp.cz
Fri Jul 20 11:54:49 PDT 2007
On Friday 20 July 2007 18:45, Nathan Ward wrote:
> If I want to parse source code for a given programming language (C for
> example), do I have to define the full grammar first or can I make a
Well, it depends on what you want to do with the parse results... For simple
things - recognizing comments, for example - you might be able to avoid a
full grammar, but in my experience, such shortcuts always end up way more
complicated than I expected at the start...
> catch-all rule that says "match anything not matched by other rules"? Or,
That won't work - that is, it won't work unless the other rules already match
the full grammar.
> perhaps I need to look into catching and ignoring Exceptions in antlr.
I'd rather recommend looking at matching in ANTLR parsers and lexers (which
work quite differently) and potentionally at using backtracking.
Bye
Vasek
More information about the antlr-interest
mailing list