Avoid recursive queries in SPARQL parser

pull/171/head
Tpt 3 years ago
parent 728a5dadf4
commit 0e2ff7878f
  1. 24
      spargebra/src/parser.rs

@ -1331,16 +1331,10 @@ parser! {
} }
//[52] //[52]
rule TriplesTemplate() -> Vec<TriplePattern> = h:TriplesSameSubject() _ t:TriplesTemplate_tail()? { rule TriplesTemplate() -> Vec<TriplePattern> = ts:TriplesTemplate_inner() ++ (".") ("." _)? {
let mut triples = h; ts.into_iter().flatten().collect()
if let Some(l) = t {
triples.extend(l)
}
triples
}
rule TriplesTemplate_tail() -> Vec<TriplePattern> = "." _ t:TriplesTemplate()? _ {
t.unwrap_or_default()
} }
rule TriplesTemplate_inner() -> Vec<TriplePattern> = _ t:TriplesSameSubject() _ { t }
//[53] //[53]
rule GroupGraphPattern() -> GraphPattern = rule GroupGraphPattern() -> GraphPattern =
@ -1400,16 +1394,10 @@ parser! {
} }
//[55] //[55]
rule TriplesBlock() -> Vec<TripleOrPathPattern> = h:TriplesSameSubjectPath() _ t:TriplesBlock_tail()? { rule TriplesBlock() -> Vec<TripleOrPathPattern> = hs:TriplesBlock_inner() ++ (".") ("." _)? {
let mut triples = h; hs.into_iter().flatten().collect()
if let Some(l) = t {
triples.extend(l)
}
triples
}
rule TriplesBlock_tail() -> Vec<TripleOrPathPattern> = "." _ t:TriplesBlock()? _ {
t.unwrap_or_default()
} }
rule TriplesBlock_inner() -> Vec<TripleOrPathPattern> = _ h:TriplesSameSubjectPath() _ { h }
//[56] //[56]
rule GraphPatternNotTriples() -> PartialGraphPattern = GroupOrUnionGraphPattern() / OptionalGraphPattern() / MinusGraphPattern() / GraphGraphPattern() / ServiceGraphPattern() / Filter() / Bind() / InlineData() rule GraphPatternNotTriples() -> PartialGraphPattern = GroupOrUnionGraphPattern() / OptionalGraphPattern() / MinusGraphPattern() / GraphGraphPattern() / ServiceGraphPattern() / Filter() / Bind() / InlineData()

Loading…
Cancel
Save