[jboss-svn-commits] JBL Code SVN: r34898 - in labs/jbossrules/branches/DRLv6/src: test/java/org/drools/lang and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Aug 26 08:21:04 EDT 2010


Author: dsotty
Date: 2010-08-26 08:21:04 -0400 (Thu, 26 Aug 2010)
New Revision: 34898

Modified:
   labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g
   labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java
Log:


Modified: labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g
===================================================================
--- labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g	2010-08-26 12:02:07 UTC (rev 34897)
+++ labs/jbossrules/branches/DRLv6/src/main/resources/DRLv6Parser.g	2010-08-26 12:21:04 UTC (rev 34898)
@@ -5,6 +5,7 @@
   output = AST;
   tokenVocab = DRLv6Lexer;  
   ASTLabelType=CommonTree;
+  backtrack=true;
 }
       
      
@@ -1195,7 +1196,6 @@
   | oa_params
   | oa_degree
   | oa_merge
-  //| oa_filter
   | oa_missing
   | oa_defeat
   | oa_default
@@ -1227,12 +1227,6 @@
   : OA_MERGE^ LEFT_PAREN! STRING RIGHT_PAREN!
   ;   
 
-/*    
-oa_filter
-  : OA_FILTER^ LEFT_PAREN! STRING RIGHT_PAREN!
-  ;
-*/
-
 oa_missing
   : OA_MISSING^ LEFT_PAREN! STRING RIGHT_PAREN!
   ;
@@ -1737,7 +1731,7 @@
 /************************************* SLOTTED CONSTRAINTS LOGIC HIERARCHY **********************************/
 
 constr_implies
-  : left=constr_or (imp=imply_connective operator_attributes? right=constr_or)? 
+  : left=constr_or (imp=imply_symbol operator_attributes? right=constr_or)? 
     -> {imp != null}? ^($imp operator_attributes? $left $right)    
     -> ^($left)
   ;
@@ -1753,7 +1747,7 @@
   ;
   
 constr_or_sequitur[Tree leftChild]
-  : or=or_connective^ (atts=operator_attributes!)? rightChild=constr_diff!
+  : or=or_symbol^ (atts=operator_attributes!)? rightChild=constr_diff!
              {
                Tree t = $or.tree;               
                if (atts != null)
@@ -1768,7 +1762,7 @@
 
 
 constr_diff
-  : constr_and (( xor_connective^ | eq_connective^ ) operator_attributes? constr_and)?
+  : constr_and (( xor_symbol^ | eq_symbol^ ) operator_attributes? constr_and)?
   ;
     
   
@@ -1786,7 +1780,7 @@
   ;
   
 constr_and_sequitur[Tree leftChild]
-  : and=and_connective^ (atts=operator_attributes!)? rightChild=constr_unary!
+  : and=and_symbol^ (atts=operator_attributes!)? rightChild=constr_unary!
              {
                Tree t = $and.tree;               
                if (atts != null)
@@ -1826,23 +1820,32 @@
   ;
   
 restr_or
+scope{
+  Tree seqTree;
+}
 @init{
   ParserRuleReturnScope seq = null;
 }
   : ld=restr_diff {seq=ld;}
-    ( lios=restr_or_sequitur[(Tree) seq.getTree()] {seq=lios;} )*
+    ( 
+      lios=restr_or_sequitur 
+        {
+          seq=lios;
+          $restr_or::seqTree = (Tree) seq.getTree();
+        } 
+    )*
   -> {lios==null}? ^($ld)
   -> ^($lios)
   ;
   
-restr_or_sequitur[Tree leftChild]
+restr_or_sequitur
   : or=or_symbol^ (atts=operator_attributes!)? rightChild=restr_diff!
              {
                Tree t = $or.tree;               
                if (atts != null)
                  t.addChild($atts.tree);
                                
-               t.addChild(leftChild);
+               t.addChild($restr_or::seqTree);
                t.addChild($rightChild.tree);           
            } 
   ;
@@ -1859,23 +1862,32 @@
   
       
 restr_and
+scope{
+  Tree seqTree;
+}
 @init{
   ParserRuleReturnScope seq = null;
 }
   : ld=restr_unary {seq=ld;}
-    ( lias=restr_and_sequitur[(Tree) seq.getTree()] {seq=lias;} )*
+    ( 
+      lias=restr_and_sequitur 
+        {
+          seq=lias;
+          $restr_and::seqTree = (Tree) seq.getTree();
+        } 
+    )*
   -> {lias==null}? ^($ld)
   -> ^($lias)
   ; 
   
-restr_and_sequitur[Tree leftChild]
+restr_and_sequitur
   : and=and_symbol^ (atts=operator_attributes!)? rightChild=restr_unary!
              {
                Tree t = $and.tree;               
                if (atts != null)
                  t.addChild($atts.tree);
                                
-               t.addChild(leftChild);
+               t.addChild($restr_and::seqTree);
                t.addChild($rightChild.tree);           
            } 
   ;

Modified: labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java
===================================================================
--- labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java	2010-08-26 12:02:07 UTC (rev 34897)
+++ labs/jbossrules/branches/DRLv6/src/test/java/org/drools/lang/Rule_Test.java	2010-08-26 12:21:04 UTC (rev 34898)
@@ -629,7 +629,7 @@
 		String rule = "rule";
 		String[] testDRL = new String[] {
 				"rule test when " + "\n" +
-				" Person( name == \"john\" implies age < 18)" + "\n" +
+				" Person( name == \"john\" -> age < 18)" + "\n" +
 				"then end"
 		};
 		check(rule,testDRL);	
@@ -641,7 +641,7 @@
 		String rule = "rule";
 		String[] testDRL = new String[] {
 				"rule test when " + "\n" +
-				" Person( name == \"john\" implies age < 18 or age > 25)" + "\n" +
+				" Person( name == \"john\" -> age < 18 || age > 25)" + "\n" +
 				"then end"
 		};
 		check(rule,testDRL);											
@@ -654,11 +654,11 @@
 		String rule = "rule";
 		String[] testDRL = new String[] {
 				"rule test when " + "\n" +
-				" Person( age < 18 xor age > 25)" + "\n" +
+				" Person( age < 18 ++ age > 25)" + "\n" +
 				"then end",
 				
 				"rule test when " + "\n" +
-				" Person( age < 18 equiv age > 25)" + "\n" +
+				" Person( age < 18 :: age > 25)" + "\n" +
 				"then end",			
 		};
 		check(rule,testDRL);											
@@ -671,7 +671,7 @@
 		String rule = "rule";
 		String[] testDRL = new String[] {
 				"rule test when " + "\n" +
-				" Person( name == \"john\" and @crisp age < 18 and @kind(\"xx\") age > @id(\"..\") 25)" + "\n" +
+				" Person( name == \"john\" && @crisp age < 18 && @kind(\"xx\") age > @id(\"..\") 25)" + "\n" +
 				"then end"
 		};
 		check(rule,testDRL);										
@@ -684,7 +684,7 @@
 		String rule = "rule";
 		String[] testDRL = new String[] {
 				"rule test when " + "\n" +
-				" Person( neg very (name == \"john\" implies age < 18) )" + "\n" +
+				" Person( neg very (name == \"john\" -> age < 18) )" + "\n" +
 				"then end",							
 		};
 		check(rule,testDRL);									
@@ -921,7 +921,7 @@
 				"then end",
 							
 				"rule test when " + "\n" +
-				" Person( ($a : | age * 2 + 4 * weight |  == 18) implies (age < 25 and age > 4)  )" + "\n" +
+				" Person( ($a : | age * 2 + 4 * weight |  == 18) -> (age < 25 && age > 4)  )" + "\n" +
 				"then end",								
 		};
 		check(rule,testDRL);										



More information about the jboss-svn-commits mailing list