[antlr-interest] Nested multi-line comments

Peter Boughton boughtonp at gmail.com
Sat Oct 24 17:03:07 PDT 2009


Thanks John, but this doesn't appear to be working.
(I'm using antlr 3.2 with antlrworks 1.3)

I tried it both as provided and with changing the comment start/end
characters, and both of these give the same error in the generated
Java code:

	C:\tmp\antlr\__Test__.java:14: cannot find symbol
	symbol  : method ML_COMMENT()
	location: class cfml_comment_testParser
	            g.ML_COMMENT();
	             ^
	1 error

I'm testing this with a very basic set of rules at the moment:

	grammar cfml_comment_test;
	
	ML_COMMENT : NESTED_COMMENTARY { $channel=HIDDEN; } ;
	
	fragment NESTED_COMMENTARY :
	     '<!---'
	     ( options {greedy=false;} : . )*
	     ( NESTED_COMMENTARY ( options {greedy=false;} : . )* )*
	     '--->'
	  ;
	
	WS : ( ' ' | '\t' | '\n' | '\r' ) {$channel=HIDDEN;} ;
	
	TEXT: ~'<' ;
	
	code: ( ML_COMMENT | WS | TEXT )+;


Any ideas?


More information about the antlr-interest mailing list