[antlr-interest] Latest antlr (bug?) incorrect parsing

Terence Parr parrt at cs.usfca.edu
Wed Dec 27 13:56:09 PST 2006


On Dec 27, 2006, at 1:39 PM, Ilia Kantor wrote:

>
> I run my old grammars on antlr 3b5
>
> Here is a rule:
>
> text returns [String value] :
>  (TEXT {$value = $TEXT.text;}) | (WS {$value = $WS.text;})
>
> There is no substutution in second alt for $WS in code:
>
> ..... java code for first alt ......
> TEXT14=(Token)input.LT(1);
> .....
> retval.value = TEXT14.getText();
>
> ..... java code for second alt ......
> WS15=(Token)input.LT(1);
> ...........
> retval.value =$WS.text;  // COMPILE ERROR
> -----

in 3.0b6, I get:

                     WS2=(Token)input.LT(1);
                     match(input,WS,FOLLOW_WS_in_text24);
                     value = WS2.getText();

Thanks,
Ter



More information about the antlr-interest mailing list