[tracker] libtracker-data: Add support for STRBEFORE/STRAFTER builtin functions
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Add support for STRBEFORE/STRAFTER builtin functions
- Date: Mon, 19 Oct 2015 12:15:40 +0000 (UTC)
commit 63d825118d361a4d8683927332b42b30fbfb0a4c
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jul 28 23:34:15 2015 +0200
libtracker-data: Add support for STRBEFORE/STRAFTER builtin functions
These functions are defined in Sparql 1.1 query language recommendation,
http://www.w3.org/TR/sparql11-query/#func-strbefore
http://www.w3.org/TR/sparql11-query/#func-strafter
src/libtracker-data/tracker-sparql-expression.vala | 22 ++++++++++++++++
src/libtracker-data/tracker-sparql-scanner.vala | 26 ++++++++++++++++++-
2 files changed, 46 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-expression.vala
b/src/libtracker-data/tracker-sparql-expression.vala
index b0dfb88..afc0d9e 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -1256,6 +1256,28 @@ class Tracker.Sparql.Expression : Object {
var result = translate_function (sql, FN_NS + "substring");
expect (SparqlTokenType.CLOSE_PARENS);
return result;
+ case SparqlTokenType.STRBEFORE:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ sql.append ("SparqlStringBefore (");
+ translate_expression_as_string (sql);
+ expect (SparqlTokenType.COMMA);
+ sql.append (",");
+ translate_expression_as_string (sql);
+ sql.append (")");
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return PropertyType.STRING;
+ case SparqlTokenType.STRAFTER:
+ next ();
+ expect (SparqlTokenType.OPEN_PARENS);
+ sql.append ("SparqlStringAfter (");
+ translate_expression_as_string (sql);
+ expect (SparqlTokenType.COMMA);
+ sql.append (",");
+ translate_expression_as_string (sql);
+ sql.append (")");
+ expect (SparqlTokenType.CLOSE_PARENS);
+ return PropertyType.STRING;
case SparqlTokenType.REGEX:
translate_regex (sql);
query.no_cache = true;
diff --git a/src/libtracker-data/tracker-sparql-scanner.vala b/src/libtracker-data/tracker-sparql-scanner.vala
index f5e919c..51315a4 100644
--- a/src/libtracker-data/tracker-sparql-scanner.vala
+++ b/src/libtracker-data/tracker-sparql-scanner.vala
@@ -405,7 +405,16 @@ public class Tracker.SparqlScanner : Object {
break;
case 'S':
case 's':
- if (matches (begin, "SAMETERM")) return SparqlTokenType.SAMETERM;
+ switch (begin[1]) {
+ case 'A':
+ case 'a':
+ if (matches (begin, "SAMETERM")) return SparqlTokenType.SAMETERM;
+ break;
+ case 'T':
+ case 't':
+ if (matches (begin, "STRAFTER")) return SparqlTokenType.STRAFTER;
+ break;
+ }
break;
}
break;
@@ -421,7 +430,16 @@ public class Tracker.SparqlScanner : Object {
break;
case 'S':
case 's':
- if (matches (begin, "STRSTARTS")) return SparqlTokenType.STRSTARTS;
+ switch (begin[3]) {
+ case 'B':
+ case 'b':
+ if (matches (begin, "STRBEFORE")) return SparqlTokenType.STRBEFORE;
+ break;
+ case 'S':
+ case 's':
+ if (matches (begin, "STRSTARTS")) return SparqlTokenType.STRSTARTS;
+ break;
+ }
break;
}
break;
@@ -1012,6 +1030,8 @@ public enum Tracker.SparqlTokenType {
SILENT,
STAR,
STR,
+ STRAFTER,
+ STRBEFORE,
STRENDS,
STRING_LITERAL1,
STRING_LITERAL2,
@@ -1119,6 +1139,8 @@ public enum Tracker.SparqlTokenType {
case SILENT: return "`SILENT'";
case STAR: return "`*'";
case STR: return "`STR'";
+ case STRAFTER: return "`STRAFTER'";
+ case STRBEFORE: return "`STRBEFORE'";
case STRENDS: return "`STRENDS'";
case STRING_LITERAL1: return "string literal";
case STRING_LITERAL2: return "string literal";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]