Commit Graph

1055 Commits

Author SHA1 Message Date
Yorick Peterse f3f3c7d31c Cleaned up literal usage in the XPath compiler 2015-08-19 20:14:22 +02:00
Yorick Peterse 44bd0751bc Removed commented out code
Something something I should just get a decent debugging mode.
2015-08-19 20:14:22 +02:00
Yorick Peterse e4e777ac4a XPath compiler support for preceding-sibling 2015-08-19 20:14:22 +02:00
Yorick Peterse 7362a783b8 XPath compiler support for the preceding axis 2015-08-19 20:14:22 +02:00
Yorick Peterse 67bc338474 XPath compiler support for the namespace axis 2015-08-19 20:14:22 +02:00
Yorick Peterse 07b52fb48a Added Ruby::Node#not
This is a shortcut for "!foo". Using this method one doesn't have to
worry about how the "!" operator binds. For example, this:

    !foo.or(bar)

would be parsed/evaluated as this:

    !(foo.or(bar))

when instead we want it to be this:

    (!foo).or(bar)

Using explicit parenthesis leads to ugly code, so now we can do this
instead:

    foo.not.or(bar)
2015-08-19 20:14:22 +02:00
Yorick Peterse 4698e98632 XPath compiler support for the following axis 2015-08-19 20:14:22 +02:00
Yorick Peterse e04ca9be35 XPath compiler Support for following-sibling
This is a direct port of the same handler used in the Evaluator class.
The code is a bit rough on the edges but this will be cleaned up in
upcoming commits.
2015-08-19 20:14:22 +02:00
Yorick Peterse 02ee35122a XPath compiler support for the self axis 2015-08-19 20:14:22 +02:00
Yorick Peterse bc49af02a2 XPath compiler support for the parent axis 2015-08-19 20:14:22 +02:00
Yorick Peterse ca7930cbf4 XPath compiler support for "descendant" 2015-08-19 20:14:22 +02:00
Yorick Peterse f8671a96b7 Fixed compiler support for descendant-or-self 2015-08-19 20:14:22 +02:00
Yorick Peterse 23379d6467 Fixed node() type test for the XPath compiler
This ensures the handler behaves the same as in the old XPath evaluator.
2015-08-19 20:14:22 +02:00
Yorick Peterse 4da1c637bc Cleaned up descendant-or-self compiler specs 2015-08-19 20:14:22 +02:00
Yorick Peterse 8a49d9c0ee 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.
2015-08-19 20:14:22 +02:00
Yorick Peterse d50f89cdf1 Use "node" for axis variables
This ensures that any nested code uses the right variables.
2015-08-19 20:14:22 +02:00
Yorick Peterse 045cfe4ab8 XPath compiler support for operators in predicates
Previously the operator methods would ignore any blocks set by the
on_predicate family of methods.
2015-08-19 20:14:22 +02:00
Yorick Peterse aa8386e6f3 Cleaned up compiler handling of axes/calls
Function call handlers don't receive a single AST node, instead they
receive the XPath arguments as separate method arguments.
2015-08-19 20:14:21 +02:00
Yorick Peterse bfc970a95a XPath compiler support for type tests 2015-08-19 20:14:21 +02:00
Yorick Peterse ef59f160c7 XPath compiler support for true()/false() 2015-08-19 20:14:21 +02:00
Yorick Peterse 2eb12eced6 XPath compiler support for all operators
Some specs still fail due to true()/false() not being implemented but
the operators themselves should work just fine.
2015-08-19 20:14:21 +02:00
Yorick Peterse 3a18d23792 to_boolean support for truthy Ruby values 2015-08-19 20:14:21 +02:00
Yorick Peterse 06ae1503d4 nodes/attributes support in to_compatible_types
This extends XPath::Conversion.to_compatible_types so that it can also
take XML::Node and XML::Attribute objects as input.
2015-08-19 20:14:21 +02:00
Yorick Peterse 376d016acd Expanded supported input for Conversion.to_float
This extends XPath::Conversion.to_float so it can also convert NodeSet
and Node instances.
2015-08-19 20:14:21 +02:00
Yorick Peterse 8a82cc3593 XPath compiler support for the "=" operator 2015-08-19 20:14:21 +02:00
Yorick Peterse 04aa8f6546 Ruby generator support for "begin" blocks 2015-08-19 20:14:21 +02:00
Yorick Peterse 92b43a7500 Renamed on_begin to on_followed_by 2015-08-19 20:14:21 +02:00
Yorick Peterse c98ba21a87 Ruby generator support for mass assignments 2015-08-19 20:14:21 +02:00
Yorick Peterse 53c142ca26 Prefix compiler predicate methods with on_ 2015-08-19 20:14:21 +02:00
Yorick Peterse bea7e19d57 Cast compiled predicate indexes to integers 2015-08-19 20:14:21 +02:00
Yorick Peterse 1f2545c03b Renamed xpath_number? to number? 2015-08-19 20:14:21 +02:00
Yorick Peterse 0e9f533358 Use return_nodeset? vs USE_NODESET 2015-08-19 20:14:21 +02:00
Yorick Peterse 9000d5efdb XPath::Compiler#compile specifies blocks for paths
Previously the on_path method itself would specify a block to use when a
node was matched. This makes it impossible to customize this behaviour
which is needed when a path is used in an operator or predicate. By
letting the #compile() method specify the block other handlers can
overwrite it.
2015-08-19 20:14:21 +02:00
Yorick Peterse e549b28ca4 Removed useless YARD docs from the XPath compiler
The method names already explain their intent.
2015-08-19 20:14:21 +02:00
Yorick Peterse 20c6bbdaa8 Removed left-over comment in the XPath compiler 2015-08-19 20:14:21 +02:00
Yorick Peterse 616fd42600 XPath compiler support for the "attribute" axis 2015-08-19 20:14:21 +02:00
Yorick Peterse 4f03bf19c1 XPath compiler support for "ancestor" 2015-08-19 20:14:21 +02:00
Yorick Peterse f96b30fb1f Tag the XPath compiler as private 2015-08-19 20:14:21 +02:00
Yorick Peterse f7484f1c8d Use each_ancestor for ancestor-or-self in XPath
The XPath compiler now uses XML::Node#each_ancestor for compiling the
"ancestor-or-self" axis.
2015-08-19 20:14:20 +02:00
Yorick Peterse 52741a3b78 Added XML::Node#each_ancestor
This method can be used to walk through the ancestor tree of a Node.
2015-08-19 20:14:20 +02:00
Yorick Peterse db39b25546 XPath compiler support for ancestor-or-self
This also comes with some changes to the specs as the old behaviour of
the Evaluator was incorrect. The Evaluator would bail after matching a
single node but instead it's meant to continue until it runs out of
parent nodes.
2015-08-19 20:14:20 +02:00
Yorick Peterse d8fbaf75d8 Ruby generator support for while loops 2015-08-19 20:14:20 +02:00
Yorick Peterse 9925b2a9c9 XPath compiler support for predicates
This currently supports index predicates (e.g. "foo[10]") and predicates
using paths (e.g. foo[bar/baz]). The usage of boolean operators and more
complex expressions has not yet been tested as these are not yet
supported in the first place.
2015-08-19 20:14:20 +02:00
Yorick Peterse 7fdf8d7460 Rewrote XPath compiler predicate specs 2015-08-19 20:14:20 +02:00
Yorick Peterse 6f6151fd52 Added Ruby generator support for Symbols 2015-08-19 20:14:20 +02:00
Yorick Peterse 05a57a807e XPath compiler support for variable references 2015-08-19 20:14:20 +02:00
Yorick Peterse cf2405998b Ruby::Generator support for #[] methods 2015-08-19 20:14:20 +02:00
Yorick Peterse 17f6b3a3bb Added simple method docs for the XPath compiler 2015-08-19 20:14:20 +02:00
Yorick Peterse 2c1b4e7cbc Support for generating "else" statements 2015-08-19 20:14:20 +02:00
Yorick Peterse ac6c0d806e Updated XPath variables spec to use the compiler 2015-08-19 20:14:20 +02:00