Compile and evaluate full XPath 1.0 expressions, not just location paths. Add the four-type Value (node-set, boolean, number, string) with the spec's coercion rules and canonical number formatting, a recursive-descent parser for the operator grammar (or/and, equality, relational, additive, multiplicative, unary minus, union) whose grammatical position disambiguates * and the operator keywords, function calls, variable references, and filter expressions. Predicates are now arbitrary expressions (a numeric predicate is a position test). Comparison follows the node-set quantification rules. Query gains value/number/string/boolean accessors and a $variable binding map; the core functions last, position, count, not, true, false, boolean, number, and string ship with it. Closes #42
10 lines
283 B
Swift
10 lines
283 B
Swift
extension PureXML.XPath {
|
|
/// One compiled location step: an axis, a node test, and zero or more
|
|
/// predicate expressions applied in order.
|
|
struct Step: Equatable, Sendable {
|
|
let axis: Axis
|
|
let test: NodeTest
|
|
let predicates: [Expression]
|
|
}
|
|
}
|