XPath Handling
For https://github.com/YorickPeterse/oga/issues/9 Oga needs to be able to parse XPath queries into an AST. Said AST then has to be consumed in order to figure out what nodes to pull from a DOM document.
For this the following would have to be added:
-
Lexer -
Lexing of all known XPath tokens -
Tests for the primitive types (strings, integers and floats) -
Tests for every known axis -
Benchmarks -
Lex wildcards as identifiers, not T_STAR
-
-
Parser -
Distinguish absolute and relative paths from each other on AST level -
Parsing of function calls (inc arguments) -
Parsing of all the available operators -
Add token precedence for all the operator tokens ( T_EQ,T_OR, etc) -
Ensure behaviour of when certain nodes are allowed (or not) resembles the rules implied by libxml/Nokogiri (this assumes libxml is correct in this) -
Tests for every known axis -
Benchmarks
-
-
AST consumer - Axis evaluation
-
ancestor -
ancestor-or-self -
attribute -
child -
descendant -
descendant-or-self -
following -
following-sibling -
namespace -
parent -
preceding -
preceding-sibling -
self
-
- Functions
-
last -
position -
count -
id -
local-name -
namespace-uri -
name -
string -
concat -
starts-with -
contains -
substring-before -
substring-after -
substring -
string-length -
normalize-space -
translate -
boolean -
not -
true -
false -
lang -
number -
sum -
floor -
ceiling -
round
-
- Node type tests
-
node -
text -
comment -
processing-instruction
-
- Operators
-
| -
and -
or -
+ -
div -
mod -
= -
!= -
< -
> -
<= -
>= -
* -
-
-
-
Variable bindings -
Benchmarks -
Tests
- Axis evaluation
The AST consumer would be fed a DOM document and, based on the XPath query, returns a list of nodes.