[antlr-interest] Catch all rule and warnings

Andrei Vereha avereha at gmail.com
Wed Dec 13 01:36:21 PST 2006


I have a question about warnings.

I took the "HTML Indexer" from Gramar list section. When I generate
the source with antlr, I get 3 warnings. Is a way to avoid these
warnings?

I have have a similar problem to solve:  I need to look for a lot of
"custom" tags in a html file + the html content(I can't ignore the
HTML content !). If I use this aproach, I will get  more and more
warnings. This is the only solution?

In a simple case, (a JSP file), where I need to recognize just the
"<%" and "%>" tag, TEXT_BETWEEN_TAGS and TEXT(text outside tags), I
made a gramar without warnings, by writing a catch all rule like this:

JSPSTART:"<%" {this.in_jsp=true };
JSPEND:"%>" {this.in_jsp=false };

TEXT options{testLiterals=true} : (~( '<' |  '>' | '%'))+
{
 if(this.in_jsp) $setType(TEXT_BETWEEN_TAGS);
};

In a more complex case, where I need to regonize : <TAG1>, <TAG2>, the
TEXT rule will be imposible to write.

Do you have any suggestions?

Thank you,
 Andrei


More information about the antlr-interest mailing list