[antlr-interest] Error in HTML lexer for Comments
Matthew Ford
Matthew.Ford at forward.com.au
Thu Jan 15 11:51:28 PST 2004
Hi all,
I think there is an error in the Comment rule in the html.g example
was {LA(2)!='-' && LA(3)!='>'}? '-' // allow '-' if not "-->"
actually and if not "-?>" and if not "--?" these cases cause early
termination of the comment rule befor end of comment reached.
should be {(LA(2)!='-') || (LA(2)=='-' && LA(3)!='>') }? '-' // allow '-'
and "--?" and "-?>" but not "-->"
replacement rule follows below.
You may need to check any other rules you have coded based on this template
of testing for a termination string. I found this problem while trying to
get another rule to work that was based on this template.
matthew
// multiple-line comments
protected
COMMENT_DATA
: ( /* '\r' '\n' can be matched in one alternative or by matching
'\r' in one iteration and '\n' in another. I am trying to
handle any flavor of newline that comes in, but the language
that allows both "\r\n" and "\r" and "\n" to all be valid
newline is ambiguous. Consequently, the resulting grammar
must be ambiguous. I'm shutting this warning off.
*/
options {
generateAmbigWarnings=false;
}
:
{(LA(2)!='-') || (LA(2)=='-' && LA(3)!='>') }? '-' // allow '-' and
"-?>" and "--?" but not "-->"
// was {LA(2)!='-' && LA(3)!='>'}? '-' // allow '-' if
not "-->" and if not "-?>" and if not "--?"
| '\r' '\n' {newline();}
| '\r' {newline();}
| '\n' {newline();}
| ~('-'|'\n'|'\r')
)*
;
----------------------------------------------------
Dr. Matthew.Ford
Forward Computing & Control Pty. Ltd.
www.forward.com.au
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