[antlr-interest] How to subtract/and two lexer rules in ANTLR v3.0
Oliver Zeigermann
oliver.zeigermann at gmail.com
Tue Aug 8 05:50:07 PDT 2006
2006/8/8, Sandeep Gupta <sandy.pec at gmail.com>:
> I am a newbie to the parsing stuff and have started trying ANTLR v3.0 Beta 3
> for quite some days now. I am trying to write a grammar to parse DTD files
> using the official specifications available at the W3C site. But, I am
> facing a problem. At various points the grammar given in the DTD
> specifications states that
>
> (Char* - (Char* '?>' Char*))
Which means all kind of characters, but not '?>'. AFAIK there is no
equivalence for this in ANTLR. However, this is not really needed. Try
a construct like this
(options {greedy=false;} : CHAR)* '?>'
This option allows to only consume those characters using the CHAR
rule that do not follow it, i.e. '?>'
By the way, this is nothing new to ANTLR 3.
HTH
Oliver
More information about the antlr-interest
mailing list