[antlr-interest] Handle multiline comment without greedy algo

forumer at smartmobili.com forumer at smartmobili.com
Mon Jul 30 06:45:58 PDT 2012


Hi,

I am using a grammar with comments handling defined as shown below :

BLOCK_COMMENT // excluding javadoc comments
     :   (   '/*' ~'*' ( options {greedy=false;} : . )* '*/'
         |   '/**/'
         )
     {
         if (!mPreserveBlockComments) {
             Skip();
         } else {
             $channel = Hidden;
         }
     }
     ;

JAVADOC_COMMENT
     :   '/**' ( options {greedy=false;} : . )* '*/'
     {
         if (!mPreserveJavaDocComments) {
             Skip();
         } else {
             $channel = Hidden;
         }
     }
     ;

Is it possible to modify this grammar to get a BLOCK_COMMENT token  or 
JAVADOC_COMMENT) for each token
belonging to BLOCK_COMENT(resp. JAVADOC_COMMENT) ?



More information about the antlr-interest mailing list