[antlr-interest] Matching the * character
Steve O'Hara
sohara at pivotal-solutions.co.uk
Fri Mar 28 02:41:38 PDT 2008
Thanks Gavin for the tip.
Steve
-----Original Message-----
From: info at mirality.co.nz [mailto:info at mirality.co.nz] On Behalf Of
Gavin Lambert
Sent: 28 March 2008 07:50
To: Steve O'Hara; Loring Craymer; antlr-interest at antlr.org
Subject: Re: [antlr-interest] Matching the * character
At 13:58 28/03/2008, Steve O'Hara wrote:
>Thanks for your help Loring - unfortunately, it hasn't helped.
>I've condensed the example down to something really simple;
>
>subExpressionText : QuotedString STAR? WS?;
>QuotedString :'\'' (~'\'')* '\'' ( '\'' (~'\'')* '\'' )* ;
>WS : (' ' | '\t' | '\n' | '\r')+ ;
>STAR : '*' ;
That QuotedString rule seems like a very weird
construction to me. I guess it will work anyway,
but I'd write it more like this (seems more
explicit, and leaves room to add additional
escapes later if you want to):
QuotedString : '\'' (~'\'' | '\'\'')* '\'';
Not really relevant to your problem, but I'm not
sure why you're getting the behaviour you're
describing unless it's something like what Ter
suggested and something else is messing with the
input before it gets to the parser. Or unless
you've got additional rules you haven't shown us
that are interfering.
More information about the antlr-interest
mailing list