[antlr-interest] Ignoring comments in syntactic predicates

Paul J. Lucas dude at darkfigure.org
Wed Dec 4 22:33:22 PST 2002


	I have rules like:

		ELEMENT options { ignore = IGNORE; }
		    : ("element" '{')=> "element"
		    | "element"
		    ;
		
		IGNORE : (WS | COMMENT) ;

		COMMENT
		    : "{--" ( options { greedy = false; } : . )* "--}" {
		      	$setType( Token.SKIP );
		      }
		    ;

	i.e., "element" when followed by '{' is treated differently than
	"element" when not followed by '{'.  Comments should not matter,
	so:

		element {-- comment --} { ...

	should be treated the same as:

		element { ...

	The problem above is, even with k > 1, that the look-ahead
	token of '{' is the same as the start and is reported as
	ambiguous.

	Is there a way to get rid of the ambiguity?

	- Paul


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list