[antlr-interest] Predicates inside a + block

Brian Geffon bgeffon at linkedin.com
Fri Oct 28 10:51:06 PDT 2011


Hi, I'm trying to something like this:


loop_section
	@init {
		boolean sectionComplete = false;
	}
	    : LD POUND section_start_tag RD 
	         (
	         	 section_end_tag { sectionComplete = true; }
	         	| { !sectionComplete }? body
	         )+
	    ;

The reason i'm using the predicate is because body can actually match a section_end_tag (token by token), so I would prefer to match second_end_tag fully and then if that fails to advance to matching a body tag. However, when I do this it fails with a cannot find symbol error. If I remove the + from the block it works, any suggestions? The exact error is: [10:49:50]         if ( !(evalPredicate( !sectionComplete ," !sectionComplete ")) ) {

Thanks.
Brian


More information about the antlr-interest mailing list