XPath support for nested pipe operators
Basically this will process the left-hand side first, assign the result to a variable and then append this set with the nodes from the right-hand side. Fixes #149
This commit is contained in:
1 parent
40501f9522
commit
6d3c5c2ce9
2 files changed
+44
-12
No files matched your search
@@ -590,16 +590,20 @@ module Oga
|
||||
def on_pipe(ast, input, &block)
|
||||
left, right = *ast
|
||||
|
||||
union = unique_literal(:union)
|
||||
conversion = literal(Conversion)
|
||||
union = unique_literal(:union)
|
||||
|
||||
union.assign(literal(XML::NodeSet).new)
|
||||
.followed_by(process(left, input) { |node| union << node })
|
||||
.followed_by(process(right, input) { |node| union << node })
|
||||
.followed_by do
|
||||
# block present means we're in a predicate
|
||||
block ? conversion.to_boolean(union).if_true(&block) : union
|
||||
end
|
||||
# Expressions such as "a | b | c"
|
||||
if left.type == :pipe
|
||||
union.assign(process(left, input))
|
||||
.followed_by(process(right, input) { |node| union << node })
|
||||
.followed_by(union)
|
||||
# Expressions such as "a | b"
|
||||
else
|
||||
union.assign(literal(XML::NodeSet).new)
|
||||
.followed_by(process(left, input) { |node| union << node })
|
||||
.followed_by(process(right, input) { |node| union << node })
|
||||
.followed_by(union)
|
||||
end
|
||||
end
|
||||
|
||||
# @param [AST::Node] ast
|
||||
|
||||
Reference in new issue
Block a user