diff --git a/spargebra/src/algebra.rs b/spargebra/src/algebra.rs index 64c4c87f..1456701d 100644 --- a/spargebra/src/algebra.rs +++ b/spargebra/src/algebra.rs @@ -194,6 +194,15 @@ impl From for Expression { } } +impl From 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> { diff --git a/spargebra/src/parser.rs b/spargebra/src/parser.rs index a20f7097..91a987ab 100644 --- a/spargebra/src/parser.rs +++ b/spargebra/src/parser.rs @@ -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)>> = "{|" _ 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())* } diff --git a/testsuite/rdf-star b/testsuite/rdf-star index 9788f054..be793266 160000 --- a/testsuite/rdf-star +++ b/testsuite/rdf-star @@ -1 +1 @@ -Subproject commit 9788f05491a036f11eb0e0e57f2c7a8da49d8b48 +Subproject commit be7932662fde2a8af3b92b28a9d91489ae143d16