Skip to content

Commit

Permalink
be able to discard parens when possible around the three associative
Browse files Browse the repository at this point in the history
operators in JavaScript (&&, || and *)
  • Loading branch information
mishoo committed Feb 3, 2011
1 parent 45ca9da commit 74b3410
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/codegen.lisp
Expand Up @@ -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)))

Expand Down

0 comments on commit 74b3410

Please sign in to comment.