PureXML/Sources/Pattern/PatternError.swift
Mihaela Mihaljevic f7fe89023c feat(pattern): streaming xmlPattern matching
Add the PureXML.Pattern namespace: a compiler for the streamable XPath
subset (names, *, prefix:*, /, //, leading absolute /, trailing @attr) into
a Matcher, with predicates and . / .. rejected. The backward-matching
algorithm tests an element's ancestor-or-self path. Pattern.matches(_:in:)
streams a document through the pull parser and returns matching node paths
in document order from the open-element stack alone, no tree built.

Closes #44
Closes #45
Closes #22
2026-06-08 05:49:13 +02:00

19 lines
668 B
Swift

public extension PureXML.Pattern {
/// An error compiling a streaming pattern.
enum PatternError: Swift.Error, Equatable, Sendable, CustomStringConvertible {
case empty
case expectedStep
/// A construct outside the streamable subset (a predicate, an attribute
/// step that is not last, or `.`/`..`).
case unsupported(String)
public var description: String {
switch self {
case .empty: "the pattern is empty"
case .expectedStep: "expected a step after '/'"
case let .unsupported(detail): "unsupported pattern construct: \(detail)"
}
}
}
}