From 9e0bd6470a20fdcd4ef8e01f2cb2dfd1d203e50b Mon Sep 17 00:00:00 2001 From: Tpt Date: Tue, 26 Jun 2018 18:15:00 +0200 Subject: [PATCH] Adds Selection::default and use it in the parser --- src/sparql/parser.rs | 9 +++++++++ src/sparql/sparql_grammar.rustpeg | 27 +++++++++------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sparql/parser.rs b/src/sparql/parser.rs index effb52f1..71e64f1c 100644 --- a/src/sparql/parser.rs +++ b/src/sparql/parser.rs @@ -165,6 +165,15 @@ mod grammar { pub variables: Option>, } + impl Default for Selection { + fn default() -> Self { + Self { + option: SelectionOption::Default, + variables: None, + } + } + } + fn build_select( select: Selection, wher: MultiSetPattern, diff --git a/src/sparql/sparql_grammar.rustpeg b/src/sparql/sparql_grammar.rustpeg index f708af2c..ff4dd980 100644 --- a/src/sparql/sparql_grammar.rustpeg +++ b/src/sparql/sparql_grammar.rustpeg @@ -74,21 +74,18 @@ ConstructQuery -> Query = Query::ConstructQuery { construct: c, dataset: d, - algebra: build_select(Selection { - option: SelectionOption::Reduced, - variables: None - }, w, h, o, l, v) + algebra: build_select(Selection::default(), w, h, o, l, v) } } / "CONSTRUCT"i _ d:DatasetClauses _ "WHERE"i _ '{' _ c:ConstructQuery_optional_triple_template _ '}' _ GroupClause? _ h:HavingClause? _ o:OrderClause? _ l:LimitOffsetClauses? _ v:ValuesClause { Query::ConstructQuery { construct: c.clone(), dataset: d, - algebra: build_select(Selection { - option: SelectionOption::Reduced, - variables: None - }, MultiSetPattern::BGP(c.into_iter().map(|p| TripleOrPathPattern::from(p)).collect()).into(), - h, o, l, v) + algebra: build_select( + Selection::default(), + MultiSetPattern::BGP(c.into_iter().map(|p| TripleOrPathPattern::from(p)).collect()).into(), + h, o, l, v + ) } } @@ -99,17 +96,14 @@ DescribeQuery -> Query = "DESCRIBE"i _ '*' _ d:DatasetClauses w:WhereClause? _ GroupClause? _ h:HavingClause? _ o:OrderClause? _ l:LimitOffsetClauses? _ v:ValuesClause { Query::DescribeQuery { dataset: d, - algebra: build_select(Selection { - option: SelectionOption::Reduced, - variables: None - }, w.unwrap_or_else(MultiSetPattern::default), h, o, l, v) + algebra: build_select(Selection::default(), w.unwrap_or_else(MultiSetPattern::default), h, o, l, v) } } / "DESCRIBE"i _ p:DescribeQuery_item+ _ d:DatasetClauses w:WhereClause? _ GroupClause? _ h:HavingClause? _ o:OrderClause? _ l:LimitOffsetClauses? _ v:ValuesClause { Query::DescribeQuery { dataset: d, algebra: build_select(Selection { - option: SelectionOption::Reduced, + option: SelectionOption::Default, variables: Some(p.into_iter().map(|var_or_iri| match var_or_iri { NamedNodeOrVariable::NamedNode(n) => SelectionMember::Expression(n.into(), Variable::default()), NamedNodeOrVariable::Variable(v) => SelectionMember::Variable(v) @@ -123,10 +117,7 @@ DescribeQuery_item -> NamedNodeOrVariable = i:VarOrIri _ { i } AskQuery -> Query = "ASK"i _ d:DatasetClauses w:WhereClause _ GroupClause? _ h:HavingClause? _ o:OrderClause? _ l:LimitOffsetClauses? _ v:ValuesClause { Query::AskQuery { dataset: d, - algebra: build_select(Selection { - option: SelectionOption::Reduced, - variables: None - }, w, h, o, l, v) + algebra: build_select(Selection::default(), w, h, o, l, v) } }