[antlr-interest] Generator Bug: Expands $ within Comments

Benjamin Niemann pink at odahoda.de
Thu Aug 7 00:33:59 PDT 2008


Hi Brent,

this is by design. ANTLR doesn't know about the syntax of the target
language, including how comments look like.

-Ben


On Wed, Aug 6, 2008 at 10:43 PM, Foust <javafoust at gmail.com> wrote:
> The latest beta (from 08/03/2008) expands parser variables within comments:
>
>
>
> statement                           : ^(T_STMT expr?)
>
>                                                 {
>
>
> System.out.println("STMT: ");// + $expr.text);
>
>                                                 }
>
>
>
> It wouldn't be such an issue, except there are cases (like this one) where
> the expansion extends over multiple lines, so temporarily-commenting out a
> portion of a line using a line comment as above causes a compilation problem
> in the target language:
>
>
>
>    System.out.println("STMT: ");
> //(object1!=null?(input.getTokenStream().toString(
>
>            input.getTreeAdaptor().getTokenStartIndex(object1.start),
>
>            input.getTreeAdaptor().getTokenStopIndex(object1.start))):null));
>
>
>
>
>
> Brent
>
>


More information about the antlr-interest mailing list