Permalink
Browse files

More work on Core: AndExpr

  • Loading branch information...
1 parent 1a7b673 commit d1a32ef7f567363055bda9d8389b66298b76d012 @bacek committed Dec 13, 2008
Showing with 25 additions and 3 deletions.
  1. +21 −3 XQuery/Core/Creator.pm
  2. +4 −0 XQuery/Core/Nodes.pm
View
@@ -89,11 +89,29 @@ class XQuery::Core::Creator {
$res;
};
- method create_and_expr ($and) {
+ method create_and_expr ($node, $pos = 0) {
+ return unless $node<ComparisonExpr>[$pos];
+ self.trace('create AndExpr');
+ my $res;
+ my $c = self.create_castable_expr($node<ComparisonExpr>[$pos]);
+ if 1 < +$node<ComparisonExpr> && $pos == 0 {
+ $res = XQuery::Core::AndExpr.new();
+ $res.expr.push($c);
+ $c.left = self.create_and_expr($node, ++$pos);
+ }
+ else {
+ self.trace('shortcut AndExpr');
+ # Shortcut for single CastableExpr
+ $res = $c;
+ };
+ $res;
+ };
+
+ method create_castable_expr($node) {
XQuery::Core::Literal.new(
- value => ~$and
+ value => ~$node
);
- }
+ };
method create_literal($node) {
XQuery::Core::Literal.new(
View
@@ -143,6 +143,10 @@ class XQuery::Core::OrExpr is XQuery::Core::Node {
};
#[37] AndExpr ::= CastableExpr ( "and" CastableExpr )*
+class XQuery::Core::AndExpr is XQuery::Core::Node {
+ has @.expr is rw;
+}
+
#[38] CastableExpr ::= CastExpr ( "castable" "as" SingleType )?
#[39] CastExpr ::= ValueExpr ( "cast" "as" SingleType )?
#[40] ValueExpr ::= ValidateExpr | StepExpr | ExtensionExpr

0 comments on commit d1a32ef

Please sign in to comment.