Changeset 366
- Timestamp:
- 12/16/10 13:23:10 (14 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/TM-SPARQL/sparql_filter.lisp ¶
r365 r366 59 59 ;; *replace function(x), function(x, y), function(x, y, z) 60 60 ;; by filter-function(x), (filter-function(x, y), filter-function(x, y, z) 61 ;; check if all functions that will e invoked are allowed 61 ;; check if all functions that will be invoked are allowed 62 ;; add a let with all variables that are used: every variable with $ and ? prefix 63 ;; add a let with (true t) and (false nil) 62 64 ;; *create and store this filter object 63 65 … … 122 124 (list :next-query (string-after cleaned-str result) 123 125 :scope result))) 124 ((string-starts-with cleaned-str " '''")126 ((string-starts-with cleaned-str "\"") 125 127 (let ((result (get-literal cleaned-str))) 126 128 (list :next-query (getf result :next-query) … … 349 351 350 352 351 (defun get-literal (query-string &key (quotation " '''"))353 (defun get-literal (query-string &key (quotation "\"")) 352 354 "Returns a list of the form (:next-query <string> :literal <string> 353 355 where next-query is the query after the found literal and literal … … 367 369 (string-starts-with query-string "'")) 368 370 (let ((literal-end 369 (find-literal-end (subseq query-string 1)(subseq query-string 0 1)))) 371 (find-literal-end (subseq query-string 1) 372 (subseq query-string 0 1)))) 370 373 (when literal-end 371 (list :next-query (subseq query-string (+ 1 literal-end)) 372 :literal (concatenate 'string quotation 373 (subseq query-string 1 literal-end) 374 quotation))))))) 374 (let ((literal 375 (escape-string (subseq query-string 1 literal-end) "\""))) 376 (list :next-query (subseq query-string (+ 1 literal-end)) 377 :literal (concatenate 'string quotation literal 378 quotation)))))))) 375 379 376 380 -
TabularUnified trunk/src/base-tools/base-tools.lisp ¶
r364 r366 30 30 :string-after-number 31 31 :separate-leading-digits 32 :white-space)) 32 :white-space 33 :escape-string)) 33 34 34 35 (in-package :base-tools) … … 262 263 (and position-of-colon (> position-of-colon 0) 263 264 (not (find #\/ (subseq uri 0 position-of-colon))))))) 265 266 267 (defun escape-string (str char-to-escape) 268 "Escapes every occurrence of char-to-escape in str, if it is 269 not escaped." 270 (declare (String str char-to-escape)) 271 (let ((result "")) 272 (dotimes (idx (length str)) 273 (let ((current-char (subseq str idx (1+ idx))) 274 (previous-char (if (= idx 0) "" (subseq str (1- idx) idx)))) 275 (cond ((and (string= current-char char-to-escape) 276 (string/= previous-char "\\")) 277 (push-string "\\" result) 278 (push-string current-char result)) 279 (t 280 (push-string current-char result))))) 281 result)) -
TabularUnified trunk/src/unit_tests/sparql_test.lisp ¶
r365 r366 1060 1060 (is-true result-2) 1061 1061 (is (string= (getf result-1 :filter-string) 1062 "BOUND((progn (progn ?var) )) || (progn isLITERAL($var) && ?var = '''abc''')"))1062 "BOUND((progn (progn ?var) )) || (progn isLITERAL($var) && ?var = \"abc\")")) 1063 1063 (is (string= (getf result-1 :next-query) "}")) 1064 1064 (is (string= (getf result-2 :filter-string) 1065 "(progn REGEX(?var1, '''''', ?var3) || (progn ?var1 > ?var3 && (progn STR( ?var) = '''abc''')))"))1065 "(progn REGEX(?var1, \"\", ?var3) || (progn ?var1 > ?var3 && (progn STR( ?var) = \"abc\")))")) 1066 1066 (is (string= (getf result-2 :next-query) "}")) 1067 1067 (is (string= (getf result-3 :filter-string) … … 1082 1082 (str-2 "!BOUND(?var1) = false}") 1083 1083 (str-3 "+?var1=-$var2}") 1084 (str-4 "!'a bc' && (+12 = - 14)}")1084 (str-4 "!'a\"b\"c' && (+12 = - 14)}") 1085 1085 (result-1 1086 1086 (getf (tm-sparql::set-boundings dummy-object str-1) :filter-string)) … … 1110 1110 (is (string= result-2-1 "(not BOUND(?var1)) = false")) 1111 1111 (is (string= result-3-1 "(1+ ?var1)=(1- $var2)")) 1112 (is (string= result-4-1 "(not '''abc''') && (progn (1+ 12) = (1- 14))"))))1112 (is (string= result-4-1 "(not \"a\\\"b\\\"c\") && (progn (1+ 12) = (1- 14))")))) 1113 1113 1114 1114
Note: See TracChangeset
for help on using the changeset viewer.