Dashboard > ANTLR 3 > ... > To implement > filter tree grammar mode
  ANTLR 3 Log In | Sign Up   View a printable version of the current page.  
  filter tree grammar mode
Added by Terence Parr, last edited by Terence Parr on Oct 04, 2006
Labels: 

I think what we really need is a filter mode for trees just like we have for lexer's. This would be almost a declarative approach where you say what trees you want to match and what actions to execute when you see it. For example,

tree grammar TP;

options {filter=true;}

IDENTITY
	:	^(MULT i:INT j:INT) {$i.text.equals("1")||$j.text.equals("1")}?
		-> i
	;

pretty sweet. of course I need tree grammars to be able to generate trees before I can do this.

The idea will be that it tries all patterns looking for a match in the order specified. An index can be used to speedthings up by only attempting rules on nodes in the tree that can possibly match. For example if there is only one MULT node in the entire tree, don't walk the entire tree looking for that pattern.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.1 Build:#806 May 06, 2007) - Bug/feature request - Contact Administrators