Basic compiler support for descendant-or-self
The generated code isn't entirely correct which considering the tests do pass means the tests need to be fixed too.
This commit is contained in:
parent
d50f89cdf1
commit
8a49d9c0ee
|
@ -214,6 +214,20 @@ module Oga
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @param [AST::Node] ast
|
||||||
|
# @param [Oga::Ruby::Node] input
|
||||||
|
# @return [Oga::Ruby::Node]
|
||||||
|
def on_axis_descendant_or_self(ast, input, &block)
|
||||||
|
descendant = node_literal
|
||||||
|
self_test = process(ast, input, &block).if_true { yield input }
|
||||||
|
|
||||||
|
descendants_test = input.each_node.add_block(descendant) do
|
||||||
|
process(ast, descendant, &block).if_true { yield descendant }
|
||||||
|
end
|
||||||
|
|
||||||
|
self_test.followed_by(descendants_test)
|
||||||
|
end
|
||||||
|
|
||||||
# @param [AST::Node] ast
|
# @param [AST::Node] ast
|
||||||
# @param [Oga::Ruby::Node] input
|
# @param [Oga::Ruby::Node] input
|
||||||
# @return [Oga::Ruby::Node]
|
# @return [Oga::Ruby::Node]
|
||||||
|
|
Loading…
Reference in New Issue