[antlr-interest] Tree grammar conditionally run subrule

fridi70 at gmx.de fridi70 at gmx.de
Tue May 27 06:40:02 PDT 2008


Hi,

I have a tree grammar that handles some AND and OR logic and works very well. For performance reasons, in 'OR' I want to run 'b = expression' only if a is false. How can I realize this in the grammar?
Thanks for any answer,
  fridi





expression returns [bool r = false]
: ^(OR a = expression
       b = expression
       {
	  $r = a || b;
       }
    )

| ^(AND a = expression
	b = expression
	{
	  $r = a && b;
	}

| a = condition 
	{
	  $r = a;
	}
      
)


-- 
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten 
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser


More information about the antlr-interest mailing list