[antlr-interest] Skip subtree in tree grammar

Martijn Reuvers martijn.reuvers at gmail.com
Tue May 5 06:38:29 PDT 2009


Hello everyone,

Is there an (easy) way to skip a subtree in a tree grammar? For
example in a conditional expression:

if bool_exp {
  // Whatever is here should be skipped
}

---
--- from the tree grammar:
---

bool_function_content[Boolean value]
	:	{value != null && value.booleanValue()}? => function_content*
	;	
	catch [FailedPredicateException e] {
		BufferedTreeNodeStream commonInput = (BufferedTreeNodeStream) input;
                // This is what I had in mind, but how to skip the
current subtree?
	}

I found the link
http://www.antlr.org/wiki/display/ANTLR3/6.+Advanced+processing , but
unfortunately that is about parser grammars. The incoming Boolean
value in bool_function_content already contains what to do (true means
evaluate and execute function_content*, false is skip the content).

Thanks a lot for your time!

Martijn


More information about the antlr-interest mailing list