[tracker/wip/carlosg/sparql-parser-ng: 281/306] libtracker-data: Invert processing of Verb and ObjectList clauses



commit 78deda9d25f37ef5d8043c155d8cfa6226c9bb87
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 10 18:44:34 2018 +0200

    libtracker-data: Invert processing of Verb and ObjectList clauses
    
    For sequential property paths it will be more convenient to have the
    ObjectList node available before processing the property path, so we
    can explode those properly into intermediate blank nodes.

 src/libtracker-data/tracker-sparql.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 1015a0a92..6def40023 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -103,6 +103,7 @@ struct _TrackerSparql
                TrackerStringBuilder *sql;
                TrackerParserNode *node;
                TrackerParserNode *prev_node;
+               TrackerParserNode *object_list;
 
                TrackerToken graph;
                TrackerToken subject;
@@ -3517,6 +3518,7 @@ translate_PropertyListPathNotEmpty (TrackerSparql  *sparql,
 {
        TrackerGrammarNamedRule rule;
        TrackerToken old_predicate;
+       TrackerParserNode *verb;
 
        /* PropertyListPathNotEmpty ::= ( VerbPath | VerbSimple ) ObjectListPath ( ';' ( ( VerbPath | 
VerbSimple ) ObjectList )? )*
         */
@@ -3524,12 +3526,14 @@ translate_PropertyListPathNotEmpty (TrackerSparql  *sparql,
        old_predicate = sparql->current_state.predicate;
 
        if (rule == NAMED_RULE_VerbPath || rule == NAMED_RULE_VerbSimple) {
-               _call_rule (sparql, rule, error);
+               verb = _skip_rule (sparql, rule);
        } else {
                g_assert_not_reached ();
        }
 
-       _call_rule (sparql, NAMED_RULE_ObjectListPath, error);
+       sparql->current_state.object_list = _skip_rule (sparql, NAMED_RULE_ObjectListPath);
+       if (!_postprocess_rule (sparql, verb, NULL, error))
+               return FALSE;
 
        tracker_token_unset (&sparql->current_state.predicate);
 
@@ -3537,12 +3541,15 @@ translate_PropertyListPathNotEmpty (TrackerSparql  *sparql,
                rule = _current_rule (sparql);
 
                if (rule == NAMED_RULE_VerbPath || rule == NAMED_RULE_VerbSimple) {
-                       _call_rule (sparql, rule, error);
+                       verb = _skip_rule (sparql, rule);
                } else {
                        break;
                }
 
-               _call_rule (sparql, NAMED_RULE_ObjectList, error);
+               sparql->current_state.object_list = _skip_rule (sparql, NAMED_RULE_ObjectList);
+               if (!_postprocess_rule (sparql, verb, NULL, error))
+                       return FALSE;
+
                tracker_token_unset (&sparql->current_state.predicate);
        }
 
@@ -3572,6 +3579,10 @@ translate_VerbSimple (TrackerSparql  *sparql,
        _init_token (&sparql->current_state.predicate,
                     sparql->current_state.prev_node, sparql);
 
+       if (!_postprocess_rule (sparql, sparql->current_state.object_list,
+                               NULL, error))
+               return FALSE;
+
        return TRUE;
 }
 
@@ -3670,6 +3681,10 @@ translate_PathElt (TrackerSparql  *sparql,
                _call_rule (sparql, NAMED_RULE_PathMod, error);
        }
 
+       if (!_postprocess_rule (sparql, sparql->current_state.object_list,
+                               NULL, error))
+               return FALSE;
+
        return TRUE;
 }
 


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