[antlr-interest] This is driving me crazy .. please help !
Gavin Lambert
antlr at mirality.co.nz
Fri Apr 4 12:39:07 PDT 2008
At 03:01 5/04/2008, Ymo wrote:
>I already have file defined i dont understand why the parser
>still cant see this rule !
The first thing you should do is to write a test harness for the
lexer alone; feed it some sample input and verify that it's
producing the tokens you want it to. I suspect that this is where
your trouble lies.
Also:
>elementBlock //returns [AstElementBlock aeb]
> : RG textBlock LG?
> ;
[...]
>LG : '\u00AB';
>fragment
>RG: '\u00BB';
RG is a fragment, so you can't refer to it from a parser rule --
it will never match.
>TextBlock //returns [AstTextBlock atb]
> : ~(LG)*
> ;
It's a very bad idea to have a lexer rule that is permitted to
match zero characters of input. Change this to:
TextBlock
: (~LG)+
;
More information about the antlr-interest
mailing list