pub enum BuiltinFilter {
Show 18 variants
Eq(Term, Term),
Ne(Term, Term),
Lt(Term, Term),
Le(Term, Term),
Gt(Term, Term),
Ge(Term, Term),
StrStarts(Term, Term),
StrEnds(Term, Term),
Contains(Term, Term),
RegexMatch {
value: Term,
pattern: Term,
flags: Option<Term>,
},
IsIri(Term),
IsLiteral(Term),
IsBlank(Term),
IsNumeric(Term),
LangMatches(Term, Term),
And(Box<BuiltinFilter>, Box<BuiltinFilter>),
Or(Box<BuiltinFilter>, Box<BuiltinFilter>),
Not(Box<BuiltinFilter>),
}Expand description
Built-in filter expression.
Carries a tree of comparisons / string tests over Datalog
Terms plus boolean compositors. The evaluator substitutes
each variable with its bound constant from the current
candidate binding and then evaluates the test; bindings that
fail to substitute (variable not bound), encounter a malformed
regex pattern, or evaluate to anything other than true are
dropped from the frontier.
Comparison semantics: Lt, Le, Gt, Ge compare two
ConstantSymbols
lexicographically over the underlying string representation.
SPARQL value-typed numeric or xsd:dateTime ordering is
not yet implemented at this layer.
String tests: StrStarts, StrEnds, Contains, and
RegexMatch operate on the raw constant string. SPARQL
language-tag and datatype-aware semantics — LANGMATCHES,
language-aware REGEX evaluation against xsd:string-only
arguments, etc. — track as further extension follow-ups; see
the rule validation specification.
Variants§
Eq(Term, Term)
lhs = rhs — equality of constants.
Ne(Term, Term)
lhs != rhs — inequality of constants.
Lt(Term, Term)
lhs < rhs — lexicographic less-than over constants.
Le(Term, Term)
lhs <= rhs — lexicographic less-than-or-equal.
Gt(Term, Term)
lhs > rhs — lexicographic greater-than.
Ge(Term, Term)
lhs >= rhs — lexicographic greater-than-or-equal.
StrStarts(Term, Term)
STRSTARTS(haystack, needle) — haystack begins with
needle over the lexical form of each argument. Plain
literals ("Alice"), xsd:string-typed literals
("Alice"^^xsd:string), and bare IRI constants all
compare against their bare-string representation, so the
match is insensitive to datatype framing.
StrEnds(Term, Term)
STRENDS(haystack, needle) — haystack ends with
needle over the lexical form of each argument. Same
datatype-insensitivity as Self::StrStarts.
Contains(Term, Term)
CONTAINS(haystack, needle) — haystack contains
needle somewhere in the lexical form. Same
datatype-insensitivity as Self::StrStarts.
RegexMatch
REGEX(value, pattern, flags?) — value matches the
regex::Regex compiled from pattern (and the optional
flags), comparing against value’s lexical form (same
datatype-insensitivity as Self::StrStarts). Supported
flags follow the SPARQL subset that maps to the
regex crate’s (?…) inline modifiers: i
(case-insensitive), m (multi-line), s
(dot-matches-newline), x (ignore whitespace inside the
pattern). A compile failure or unsupported flag is treated
as “undefined for the current binding” — the candidate is
dropped, matching the SPARQL “type error → not true”
framing.
Fields
IsIri(Term)
isIRI(?x) — true when ?x resolves to an IRI under the
term-kind classification in the evaluator’s RDF term classification.
IsLiteral(Term)
isLiteral(?x) — true when ?x resolves to a literal.
IsBlank(Term)
isBlank(?x) — true when ?x resolves to a blank node.
IsNumeric(Term)
isNumeric(?x) — true when ?x resolves to a literal
whose datatype IRI is recognized as numeric by
the evaluator’s numeric datatype classification.
LangMatches(Term, Term)
LANGMATCHES(language-tag, language-range) — RFC 4647
basic-range matching over the lexical form of both
arguments. The wildcard range "*" matches any non-empty
tag; otherwise the range matches the tag when the tag’s
initial subtags (split on -) match the range’s subtags
case-insensitively.
Both arguments are resolved through the lexical_form
helper, so callers may supply either a plain string
constant or an encoded literal (typically the result of a
future BindExpr::Lang(?lit) extraction). The full
pipeline integration that wires LANG(?lit) through to
language-tagged literal storage is tracked under R12-21
follow-up — this slice lands the rule and the basic-range
matcher; existing tests construct the language tag as a
plain literal manually.
And(Box<BuiltinFilter>, Box<BuiltinFilter>)
lhs && rhs — logical conjunction of two filters.
Or(Box<BuiltinFilter>, Box<BuiltinFilter>)
lhs || rhs — logical disjunction of two filters.
Not(Box<BuiltinFilter>)
!inner — logical negation.
Implementations§
Source§impl BuiltinFilter
impl BuiltinFilter
Sourcepub fn variables(&self) -> BTreeSet<VariableSymbol>
pub fn variables(&self) -> BTreeSet<VariableSymbol>
All variables referenced anywhere inside the filter expression. Used by safety analysis to require that every such variable is bound by some positive body atom.