Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

More work on Core: AndExpr

  • Loading branch information...
commit d1a32ef7f567363055bda9d8389b66298b76d012 1 parent 1a7b673
Vasily Chekalkin authored December 13, 2008
24  XQuery/Core/Creator.pm
@@ -89,11 +89,29 @@ class XQuery::Core::Creator {
89 89
         $res;
90 90
     };
91 91
 
92  
-    method create_and_expr ($and) {
  92
+    method create_and_expr ($node, $pos = 0) {
  93
+        return unless $node<ComparisonExpr>[$pos];
  94
+        self.trace('create AndExpr');
  95
+        my $res;
  96
+        my $c = self.create_castable_expr($node<ComparisonExpr>[$pos]);
  97
+        if 1 < +$node<ComparisonExpr> && $pos == 0 {
  98
+            $res = XQuery::Core::AndExpr.new();
  99
+            $res.expr.push($c);
  100
+            $c.left = self.create_and_expr($node, ++$pos);
  101
+        }
  102
+        else {
  103
+            self.trace('shortcut AndExpr');
  104
+            # Shortcut for single CastableExpr
  105
+            $res = $c;
  106
+        };
  107
+        $res;
  108
+    };
  109
+
  110
+    method create_castable_expr($node) {
93 111
         XQuery::Core::Literal.new(
94  
-            value => ~$and
  112
+            value => ~$node
95 113
         );
96  
-    }
  114
+    };
97 115
 
98 116
     method create_literal($node) {
99 117
         XQuery::Core::Literal.new(
4  XQuery/Core/Nodes.pm
@@ -143,6 +143,10 @@ class XQuery::Core::OrExpr is XQuery::Core::Node {
143 143
 };
144 144
 
145 145
 #[37]    	AndExpr 	   ::=    	CastableExpr ( "and" CastableExpr )*
  146
+class XQuery::Core::AndExpr is XQuery::Core::Node {
  147
+    has @.expr is rw;
  148
+}
  149
+
146 150
 #[38]    	CastableExpr 	   ::=    	CastExpr ( "castable" "as" SingleType )?
147 151
 #[39]    	CastExpr 	   ::=    	ValueExpr ( "cast" "as" SingleType )?
148 152
 #[40]    	ValueExpr 	   ::=    	ValidateExpr | StepExpr | ExtensionExpr

0 notes on commit d1a32ef

Please sign in to comment.
Something went wrong with that request. Please try again.