Adds Service to the algebra

pull/10/head
Tpt 7 years ago
parent b42428fc86
commit 9dfe0655e3
  1. 12
      src/sparql/algebra.rs
  2. 7
      src/sparql/sparql_grammar.rustpeg

@ -746,6 +746,7 @@ pub enum MultiSetPattern {
Extend(Box<MultiSetPattern>, Variable, Expression),
Minus(Box<MultiSetPattern>, Box<MultiSetPattern>),
ToMultiSet(Box<ListPattern>),
Service(NamedNodeOrVariable, Box<MultiSetPattern>, bool),
}
impl fmt::Display for MultiSetPattern {
@ -767,6 +768,7 @@ impl fmt::Display for MultiSetPattern {
MultiSetPattern::Extend(p, v, e) => write!(f, "Extend({}), {}, {})", p, v, e),
MultiSetPattern::Minus(a, b) => write!(f, "Minus({}, {})", a, b),
MultiSetPattern::ToMultiSet(l) => write!(f, "{}", l),
MultiSetPattern::Service(n, p, s) => write!(f, "Service({}, {}, {})", n, p, s),
}
}
}
@ -844,6 +846,16 @@ impl<'a> fmt::Display for SparqlMultiSetPattern<'a> {
SparqlMultiSetPattern(&*b)
),
MultiSetPattern::ToMultiSet(l) => write!(f, "{}", SparqlListPattern(&l)),
MultiSetPattern::Service(n, p, s) => if *s {
write!(
f,
"SERVICE SILENT {} {{ {} }}",
n,
SparqlMultiSetPattern(&*p)
)
} else {
write!(f, "SERVICE {} {{ {} }}", n, SparqlMultiSetPattern(&*p))
},
}
}
}

@ -241,10 +241,9 @@ GraphGraphPattern -> PartialGraphPattern = "GRAPH"i _ g:VarOrIri _ p:GroupGraphP
}
//[59]
ServiceGraphPattern -> PartialGraphPattern = "SERVICE"i _ "SILENT"i? _ s:VarOrIri _ p:GroupGraphPattern {
PartialGraphPattern::Other(MultiSetPattern::default())
//TODO PartialGraphPattern::Other(MultiSetPattern::ServicePattern(s, Box::new(p)))
}
ServiceGraphPattern -> PartialGraphPattern =
"SERVICE"i _ "SILENT"i _ s:VarOrIri _ p:GroupGraphPattern { PartialGraphPattern::Other(MultiSetPattern::Service(s, Box::new(p), true)) } /
"SERVICE"i _ s:VarOrIri _ p:GroupGraphPattern { PartialGraphPattern::Other(MultiSetPattern::Service(s, Box::new(p), false)) }
//[60]
Bind -> PartialGraphPattern = "BIND"i _ '(' _ e:Expression _ "AS"i _ v:Var _ ')' {

Loading…
Cancel
Save