Skip to content

Commit bb0551b

Browse files
oakmaccburgmer
authored andcommitted
cleanup: parser modifications
1 parent 8860515 commit bb0551b

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/json_path/parser.clj

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,22 @@
88
(def boolean-ops
99
{"&&" :and, "||" :or})
1010

11-
(def boolean-ops-strings (set (keys boolean-ops)))
12-
1311
(def comparator-ops
1412
{"=" :eq, "!=" :neq, "<" :lt, "<=" :lt-eq, ">" :gt, ">=" :gt-eq})
1513

14+
(def boolean-ops-strings (set (keys boolean-ops)))
15+
(def comparator-ops-strings (set (keys comparator-ops)))
16+
1617
(defn parse-boolean-expr [expr]
1718
(let [lhs (take-while #(not (boolean-ops-strings %)) expr)
1819
op (first (drop-while #(not (boolean-ops-strings %)) expr))
1920
rhs (rest (drop-while #(not (boolean-ops-strings %)) expr))]
2021
[(boolean-ops op) (parse-expr lhs) (parse-expr rhs)]))
2122

2223
(defn parse-comparator-expr [expr]
23-
(let [supported-ops (set (keys comparator-ops))
24-
lhs (take-while #(not (supported-ops %)) expr)
25-
op (first (drop-while #(not (supported-ops %)) expr))
26-
rhs (rest (drop-while #(not (supported-ops %)) expr))]
27-
; (if (nil? op)
28-
; [:some (parse lhs)])
24+
(let [lhs (take-while #(not (comparator-ops-strings %)) expr)
25+
op (first (drop-while #(not (comparator-ops-strings %)) expr))
26+
rhs (rest (drop-while #(not (comparator-ops-strings %)) expr))]
2927
[(comparator-ops op) (parse lhs) (parse rhs)]))
3028

3129
(defn parse-expr [expr]
@@ -34,10 +32,6 @@
3432
(some (set (keys comparator-ops)) expr) (parse-comparator-expr expr)
3533
:else [:some (parse expr)]))
3634

37-
; (if (some boolean-ops-strings expr)
38-
; (parse-boolean-expr expr)
39-
; (parse-comparator-expr expr)))
40-
4135
(defn parse-indexer [remaining]
4236
(let [next (first remaining)]
4337
(cond

0 commit comments

Comments
 (0)