Makes SPARQL parser reject all bad blank node combinations

pull/171/head
Tpt 3 years ago
parent 5d3a909105
commit a30081ab60
  1. 20
      spargebra/src/parser.rs
  2. 2
      testsuite/tests/sparql.rs

@ -303,12 +303,7 @@ impl From<AnnotatedTerm> for AnnotatedTermPath {
annotations: term annotations: term
.annotations .annotations
.into_iter() .into_iter()
.map(|(p, o)| { .map(|(p, o)| (p.into(), o.into_iter().map(Self::from).collect()))
(
p.into(),
o.into_iter().map(Self::from).collect(),
)
})
.collect(), .collect(),
} }
} }
@ -1283,8 +1278,13 @@ parser! {
//[53] //[53]
rule GroupGraphPattern() -> GraphPattern = rule GroupGraphPattern() -> GraphPattern =
"{" _ p:GroupGraphPatternSub() _ "}" { p } / "{" _ GroupGraphPattern_clear() p:GroupGraphPatternSub() GroupGraphPattern_clear() _ "}" { p } /
"{" _ p:SubSelect() _ "}" { p } "{" _ GroupGraphPattern_clear() p:SubSelect() GroupGraphPattern_clear() _ "}" { p }
rule GroupGraphPattern_clear() = {
// We deal with blank nodes aliases rule
state.used_bnodes.extend(state.currently_used_bnodes.iter().cloned());
state.currently_used_bnodes.clear();
}
//[54] //[54]
rule GroupGraphPatternSub() -> GraphPattern = a:TriplesBlock()? _ b:GroupGraphPatternSub_item()* { rule GroupGraphPatternSub() -> GraphPattern = a:TriplesBlock()? _ b:GroupGraphPatternSub_item()* {
@ -1314,10 +1314,6 @@ parser! {
} }
} }
// We deal with blank nodes aliases rule (TODO: partial for now)
state.used_bnodes.extend(state.currently_used_bnodes.iter().cloned());
state.currently_used_bnodes.clear();
if let Some(expr) = filter { if let Some(expr) = filter {
GraphPattern::Filter { expr, inner: Box::new(g) } GraphPattern::Filter { expr, inner: Box::new(g) }
} else { } else {

@ -27,8 +27,6 @@ fn sparql10_w3c_query_syntax_testsuite() -> Result<()> {
run_testsuite( run_testsuite(
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-syntax.ttl", "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-syntax.ttl",
vec![ vec![
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql4/manifest#syn-bad-38", // bnode scope
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql4/manifest#syn-bad-34", // bnode scope
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql3/manifest#syn-bad-26", // tokenizer "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/syntax-sparql3/manifest#syn-bad-26", // tokenizer
], ],
) )

Loading…
Cancel
Save