[tracker/wip/carlosg/sparql-parser-ng: 290/306] libtracker-sparql: Allow non bracketted expressions in OrderClause



commit 682f7a7285f6203de4e2829d09361ca6b3f3f0d9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Sep 2 14:05:31 2018 +0200

    libtracker-sparql: Allow non bracketted expressions in OrderClause
    
    This is a Tracker SPARQL extension present in the previous parser.

 src/libtracker-data/tracker-sparql-grammar.h |  6 +++++-
 src/libtracker-data/tracker-sparql.c         | 11 +++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-grammar.h b/src/libtracker-data/tracker-sparql-grammar.h
index 3dcffff4c..caf54b8d5 100644
--- a/src/libtracker-data/tracker-sparql-grammar.h
+++ b/src/libtracker-data/tracker-sparql-grammar.h
@@ -1339,9 +1339,13 @@ static const TrackerGrammarRule rule_LimitOffsetClauses[] = { OR(helper_LimitOff
 
 /* OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression )
  *                    | ( Constraint | Var )
+ *
+ * TRACKER EXTENSION:
+ * The first rule is turned into the more generic:
+ * ( ( 'ASC' | 'DESC' ) Expression )
  */
 static const TrackerGrammarRule helper_OrderCondition_or_1[] = { L(ASC), L(DESC), NIL };
-static const TrackerGrammarRule helper_OrderCondition_seq[] = { OR(helper_OrderCondition_or_1), 
R(BrackettedExpression), NIL };
+static const TrackerGrammarRule helper_OrderCondition_seq[] = { OR(helper_OrderCondition_or_1), 
R(Expression), NIL };
 static const TrackerGrammarRule helper_OrderCondition_or_2[] = { S(helper_OrderCondition_seq), 
R(Constraint), R(Var), NIL };
 static const TrackerGrammarRule rule_OrderCondition[] = { OR(helper_OrderCondition_or_2), NIL };
 
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 3e3dc5b48..db8d74222 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2274,12 +2274,16 @@ translate_OrderCondition (TrackerSparql  *sparql,
 
        /* OrderCondition ::= ( ( 'ASC' | 'DESC' ) BrackettedExpression )
         *                    | ( Constraint | Var )
+        *
+        * TRACKER EXTENSION:
+        * plain Expression is also accepted, the last group is:
+        * ( Constraint | Var | Expression )
         */
        if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_ASC)) {
-               _call_rule (sparql, NAMED_RULE_BrackettedExpression, error);
+               _call_rule (sparql, NAMED_RULE_Expression, error);
                order_str = "ASC ";
        } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_DESC)) {
-               _call_rule (sparql, NAMED_RULE_BrackettedExpression, error);
+               _call_rule (sparql, NAMED_RULE_Expression, error);
                order_str = "DESC ";
        } else if (_check_in_rule (sparql, NAMED_RULE_Constraint)) {
                _call_rule (sparql, NAMED_RULE_Constraint, error);
@@ -2656,8 +2660,7 @@ iterate_solution (TrackerSparql      *sparql,
 
                sparql->solution_var_map = tracker_solution_get_bindings (solution);
                retval = _postprocess_rule (sparql, node, NULL, error);
-               g_clear_pointer (&sparql->solution_var_map,
-                                (GDestroyNotify) g_hash_table_unref);
+               g_clear_pointer (&sparql->solution_var_map, g_hash_table_unref);
 
                tracker_data_update_buffer_might_flush (tracker_data_manager_get_data (sparql->data_manager),
                                                        &flush_error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]