[antlr-interest] Two questions about antlr3 syntax

Oliver Zeigermann oliver.zeigermann at gmail.com
Thu Oct 27 12:59:53 PDT 2005


2005/10/27, shmuel siegel <antlr at shmuelhome.mine.nu>:
> 1) In antlr2 I used EOT to indicate that the entire input file must
> match my syntax. What has replaced this in antlr3.
> example
>      document : contextSection (eventSection)? (handlerList)?
> (settingSection)* EOT!;

AFAIK the EOT is no longer required. The only thing you will need is
at least one start rule. A start rule is called by no other rule.

> 2) in antlr2 we used labels to create referenceable items. The read me
> notes say that we should use an equal sign instead of a colon but
> neither syntax works for me in antlr3. what do I need to do?
>
> example:
>     LINE_DIRECTIVE : a="#line" WS line=NUMBER WS (filename=STRING)?
>         {
>             $setType(Token.SKIP);
>             setLine(Integer.parseInt(line.getText())-1);
>             if(filename!=null)
>             {
>                 currentFilename = filename.getText();
>                 setFilename(currentFilename);
>             }
>         }
>         ;

I suppose this is a lexer rule, isn't it? If so, there is no way to
make this work in ANTLR3ea5, but this will work in the next release.

HTH

Oliver


More information about the antlr-interest mailing list