[antlr-interest] The unary not (~) vs. W3C EBNF dash operator
Austin Hastings
Austin_Hastings at Yahoo.com
Fri Oct 26 21:13:26 PDT 2007
David,
By analogy with this rule, from
http://antlr.org/grammar/1152141644268/Java.g
COMMENT
: '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
;
Try this:
CDATA_SECTION
: '<![CDATA['
( options { greedy = false; } : . )*
']]>'
;
You will probably want to set the token string value to be just the
contents. If you want the CD-start CData CD-end sequence, you will need
to put the .* and ]]> in a single rule and then emit two tokens. Both
are covered in the e-book.
=Austin
David White wrote:
> I have the ANTLR3 e-book, but I still am unclear how to convert the
> spec for CData above (rule [20]) into ANTLR grammar format.
>
> Is there a simple explanation that I have missed?
>
> regards,
> david
>
>
>
More information about the antlr-interest
mailing list