[tracker/parser] SPARQL: Add type information for additive expressions



commit be8a500dbe3fc905a0cd563e01bcd89cb509745f
Author: Jürg Billeter <j bitron ch>
Date:   Wed Aug 12 14:11:22 2009 +0200

    SPARQL: Add type information for additive expressions

 src/libtracker-data/tracker-sparql-query.vala |   23 +++++++++++++++++------
 1 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 90e6719..fbe30f4 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -1289,28 +1289,39 @@ public class Tracker.SparqlQuery : Object {
 		return optype;
 	}
 
-	void translate_additive_expression (StringBuilder sql) throws SparqlError {
+	DataType translate_additive_expression (StringBuilder sql) throws SparqlError {
 		long begin = sql.len;
-		translate_multiplicative_expression (sql);
+		var optype = translate_multiplicative_expression (sql);
 		while (true) {
 			if (accept (SparqlTokenType.PLUS)) {
+				if (!optype.maybe_numeric ()) {
+					throw new SparqlError.PARSE ("expected numeric operand");
+				}
 				sql.insert (begin, "(");
 				sql.append (" + ");
-				translate_multiplicative_expression (sql);
+				if (!translate_multiplicative_expression (sql).maybe_numeric ()) {
+					throw new SparqlError.PARSE ("expected numeric operand");
+				}
 				sql.append (")");
 			} else if (accept (SparqlTokenType.MINUS)) {
+				if (!optype.maybe_numeric ()) {
+					throw new SparqlError.PARSE ("expected numeric operand");
+				}
 				sql.insert (begin, "(");
 				sql.append (" - ");
-				translate_multiplicative_expression (sql);
+				if (!translate_multiplicative_expression (sql).maybe_numeric ()) {
+					throw new SparqlError.PARSE ("expected numeric operand");
+				}
 				sql.append (")");
 			} else {
 				break;
 			}
 		}
+		return optype;
 	}
 
-	void translate_numeric_expression (StringBuilder sql) throws SparqlError {
-		translate_additive_expression (sql);
+	DataType translate_numeric_expression (StringBuilder sql) throws SparqlError {
+		return translate_additive_expression (sql);
 	}
 
 	void translate_relational_expression (StringBuilder sql) throws SparqlError {



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