[antlr-interest] How to subtract/and two lexer rules in ANTLR v3.0

Sandeep Gupta sandy.pec at gmail.com
Tue Aug 8 06:36:55 PDT 2006


Hi

I have tried using the construct you have mentioned, but it throws a
MisMatchedTokenException.
I have used the following rule

definition  :    '<?' (options {greedy=false;} : Char)* '?>'    ;

where Char is defined as the set of all Unicode Characters mentioned in the
XML specifications. I have tested the Char rule and it works fine. Unable to
figure out what is the problem.


- Sandeep

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20060808/da9e2939/attachment-0001.html


More information about the antlr-interest mailing list