|
|
@@ -399,10 +399,24 @@
|
|
|
(or (not start) (>= value start))
|
|
|
(or (not end) (< value end))))))))
|
|
|
|
|
|
+(defun .query-coloned-option (option-parser value-parser)
|
|
|
+ (.let* ((option option-parser)
|
|
|
+ (_ (.char= #\:))
|
|
|
+ (value value-parser))
|
|
|
+ (.identity (cons option value))))
|
|
|
+(defun .query-option (option)
|
|
|
+ (.progn (.string= (string-downcase (symbol-name option)))
|
|
|
+ (.identity option)))
|
|
|
+(defun .query-value-boolean ()
|
|
|
+ (.let* ((value (.optional (.chars #\t #\f))))
|
|
|
+ (.identity (ecase value
|
|
|
+ ((nil #\t) :t)
|
|
|
+ (#\f :f)))))
|
|
|
+
|
|
|
(defun .query-term ()
|
|
|
- (.or (.progn (.string= "^cost") (.identity (cons :cost t)))
|
|
|
- (.progn (.string= "^tree") (.identity (cons :tree t)))
|
|
|
- (.progn (.string= "^real") (.identity (cons :real t)))
|
|
|
+ (.or (.query-coloned-option (.query-option :cost) (.query-value-boolean))
|
|
|
+ (.query-coloned-option (.query-option :tree) (.query-value-boolean))
|
|
|
+ (.query-coloned-option (.query-option :real) (.query-value-boolean))
|
|
|
(.query-coloned :acct (.query-postingp "acct" #'posting-account)
|
|
|
(.query-value-regex))
|
|
|
(.query-coloned :amt (.progn (.string= "amt")
|
|
|
@@ -444,28 +458,24 @@
|
|
|
word))))
|
|
|
|
|
|
(defun make-options (terms)
|
|
|
- (let (desc acct status other cost tree real)
|
|
|
+ (let (options desc acct status other)
|
|
|
(loop for (type . f) in terms
|
|
|
do (case type
|
|
|
(:desc (push f desc))
|
|
|
(:comment (push f desc))
|
|
|
(:acct (push f acct))
|
|
|
(:status (push f status))
|
|
|
- (:cost (setf cost f))
|
|
|
- (:real (setf real f))
|
|
|
- (:tree (setf tree f))
|
|
|
+ ((:cost :real :tree) (setf (getf options type) f))
|
|
|
(otherwise (push f other))))
|
|
|
- (list :predicate
|
|
|
- #'(lambda (entry posting)
|
|
|
- (labels ((any (predicates)
|
|
|
- (or (not predicates)
|
|
|
- (find-if #'(lambda (p) (funcall p entry posting)) predicates)))
|
|
|
- (all (predicates)
|
|
|
- (not (find-if-not #'(lambda (p) (funcall p entry posting)) predicates))))
|
|
|
- (and (any desc) (any acct) (any status) (all other))))
|
|
|
- :cost cost
|
|
|
- :tree tree
|
|
|
- :real real)))
|
|
|
+ (append options
|
|
|
+ (list :predicate
|
|
|
+ #'(lambda (entry posting)
|
|
|
+ (labels ((any (predicates)
|
|
|
+ (or (not predicates)
|
|
|
+ (find-if #'(lambda (p) (funcall p entry posting)) predicates)))
|
|
|
+ (all (predicates)
|
|
|
+ (not (find-if-not #'(lambda (p) (funcall p entry posting)) predicates))))
|
|
|
+ (and (any desc) (any acct) (any status) (all other))))))))
|
|
|
|
|
|
(defun .query ()
|
|
|
(.let* ((args (.mapcar* (.prog1 (.arg) (.optional (.whitespace))))))
|