Permalink
Browse files

be able to discard parens when possible around the three associative

operators in JavaScript (&&, || and *)
  • Loading branch information...
1 parent 45ca9da commit 74b341010b7e07f05f50aceec51da1b85747746d @mishoo committed Feb 3, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/codegen.lisp
View
4 src/codegen.lisp
@@ -263,7 +263,9 @@ characters in string S to STREAM."
(setf lvalue (format nil "(~A)" lvalue)))
(when (or (member (car right) '(:assign :conditional :seq))
(and (eq (car right) :binary)
- (>= (precedence op) (precedence (cadr right)))))
+ (>= (precedence op) (precedence (cadr right)))
+ (not (and (eq op (cadr right))
+ (member op '(:&& :|\|\|| :*))))))
(setf rvalue (format nil "(~A)" rvalue)))
(add-spaces lvalue (operator-string op) rvalue)))

0 comments on commit 74b3410

Please sign in to comment.