[antlr-interest] Two (or more?) comments in a row in the grammar file fails

Johannes Luber jaluber at gmx.de
Thu Oct 11 09:56:46 PDT 2007


Cristian Peraferrer wrote:
> Why when I put two or more multiline comments in a grammar file it fails
> to generate the code?
> 
> Here my example:
> 
> tokens {
>       LITINT        = 'int';
>         PLUS        = '+';
>     SEMI        = ';';
> }
> 
> ID    :    ('a'..'z' | 'A'..'Z') ('a'..'z'| 'A'..'Z'|'0'..'9')* ;
> 
> /** comment 1 **/
> 
> /** comment 2 **/
> add    :     (ID (PLUS! ID)+ SEMI!)+ ;
> 

/** starts a so-called DOC_COMMENT token, like the one used in Java. The
grammar accepts only one DOC_COMMENT per rule and you have two. The
solution is to merge the two DOC_COMMENTs onto one or use only /*.

Best regards,
Johannes Luber


More information about the antlr-interest mailing list