Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor clean-up

  • Loading branch information...
commit 0f2f6fb4388eaf32ccac4a7c4596e38ca069f3e5 1 parent ff67e17
@mishoo authored
Showing with 22 additions and 23 deletions.
  1. +22 −23 src/squeeze.lisp
View
45 src/squeeze.lisp
@@ -79,28 +79,27 @@
(defun negate (c)
(flet ((not-c ()
`(:unary-prefix :! ,c)))
- (ast-case c
- (:unary-prefix (op expr)
- (if (eq op :!) expr (not-c)))
- (:binary (op left right)
- (case op
- (:< `(:binary :>= ,left ,right))
- (:<= `(:binary :> ,left ,right))
- (:> `(:binary :<= ,left ,right))
- (:>= `(:binary :< ,left ,right))
- (:== `(:binary :!= ,left ,right))
- (:!= `(:binary :== ,left ,right))
- (:=== `(:binary :!== ,left ,right))
- (:!== `(:binary :=== ,left ,right))
- (:|\|\|| (best-of (not-c) `(:binary :&& ,(negate left) ,(negate right))))
- (:&& (best-of (not-c) `(:binary :|\|\|| ,(negate left) ,(negate right))))
- (t (not-c))))
- (:atom (what)
- (case what
- (:true `(:num 0))
- (:false `(:num 1))
- (t (not-c))))
- (t () (not-c)))))
+ (or (ast-case c
+ (:unary-prefix (op expr)
+ (when (eq op :!)
+ expr))
+ (:binary (op left right)
+ (case op
+ (:< `(:binary :>= ,left ,right))
+ (:<= `(:binary :> ,left ,right))
+ (:> `(:binary :<= ,left ,right))
+ (:>= `(:binary :< ,left ,right))
+ (:== `(:binary :!= ,left ,right))
+ (:!= `(:binary :== ,left ,right))
+ (:=== `(:binary :!== ,left ,right))
+ (:!== `(:binary :=== ,left ,right))
+ (:|\|\|| (best-of (not-c) `(:binary :&& ,(negate left) ,(negate right))))
+ (:&& (best-of (not-c) `(:binary :|\|\|| ,(negate left) ,(negate right))))))
+ (:atom (what)
+ (case what
+ (:true `(:num 0))
+ (:false `(:num 1)))))
+ (not-c))))
(defun ast-squeeze (ast &key
(sequences t)
@@ -305,7 +304,7 @@
(is-constant right))
(let ((val (binary-op op (cadr left) (cadr right))))
(when val
- (setf ret (best-of ret `(,(etypecase val (string :string) (number :num)) ,val))))))
+ (setf ret (best-of ret `(,(etypecase val (string :string) (number :num)) ,val))))))
ret))
(:unary-prefix (op ex)
Please sign in to comment.
Something went wrong with that request. Please try again.