Updates SPARQL-star expression parser

pull/171/head
Tpt 3 years ago
parent b5cb0cce19
commit 500a4d866f
  1. 9
      spargebra/src/algebra.rs
  2. 17
      spargebra/src/parser.rs
  3. 2
      testsuite/rdf-star

@ -194,6 +194,15 @@ impl From<Variable> for Expression {
}
}
impl From<NamedNodePattern> for Expression {
fn from(p: NamedNodePattern) -> Self {
match p {
NamedNodePattern::NamedNode(p) => p.into(),
NamedNodePattern::Variable(p) => p.into(),
}
}
}
struct SparqlExpression<'a>(&'a Expression);
impl<'a> fmt::Display for SparqlExpression<'a> {

@ -1865,7 +1865,7 @@ parser! {
l:NumericLiteral() { l.into() } /
l:BooleanLiteral() { l.into() } /
BuiltInCall() /
TripleExpression()
ExprEmbTP()
//[120]
rule BrackettedExpression() -> Expression = "(" _ e:Expression() _ ")" { e }
@ -2224,11 +2224,20 @@ parser! {
//[180]
rule AnnotationPatternPath() -> FocusedTripleOrPathPattern<Vec<(VariableOrPropertyPath,Vec<AnnotatedTermPath>)>> = "{|" _ a: PropertyListPathNotEmpty() _ "|}" { a }
// Extra rule not yet in the spec
rule TripleExpression() -> Expression = "<<" _ s:Expression() _ p:Expression() _ o:Expression() _ ">>" {
Expression::FunctionCall(Function::Triple, vec![s, p, o])
//[181]
rule ExprEmbTP() -> Expression = "<<" _ s:ExprVarOrTerm() _ p:Verb() _ o:ExprVarOrTerm() _ ">>" {
Expression::FunctionCall(Function::Triple, vec![s, p.into(), o])
}
//[182]
rule ExprVarOrTerm() -> Expression =
i:iri() { i.into() } /
l:RDFLiteral() { l.into() } /
l:NumericLiteral() { l.into() } /
l:BooleanLiteral() { l.into() } /
v:Var() { v.into() } /
ExprEmbTP()
//space
rule _() = quiet! { ([' ' | '\t' | '\n' | '\r'] / comment())* }

@ -1 +1 @@
Subproject commit 9788f05491a036f11eb0e0e57f2c7a8da49d8b48
Subproject commit be7932662fde2a8af3b92b28a9d91489ae143d16
Loading…
Cancel
Save