From de7ec7f1b7e387f933daef7ef035583a8ca8b715 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Wed, 6 Feb 2013 11:36:04 +0200 Subject: [PATCH] Fix parens for negative numbers Close #115 --- lib/output.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/output.js b/lib/output.js index 27b35fe6..ab9b82b4 100644 --- a/lib/output.js +++ b/lib/output.js @@ -514,6 +514,12 @@ function OutputStream(options) { return true; }); + PARENS(AST_Number, function(output){ + var p = output.parent(); + if (this.getValue() < 0 && p instanceof AST_PropAccess && p.expression === this) + return true; + }); + function assign_and_conditional_paren_rules(output) { var p = output.parent(); // !(a = false) → true @@ -942,7 +948,7 @@ function OutputStream(options) { DEFPRINT(AST_Dot, function(self, output){ var expr = self.expression; expr.print(output); - if (expr instanceof AST_Number) { + if (expr instanceof AST_Number && expr.getValue() >= 0) { if (!/[xa-f.]/i.test(output.last())) { output.print("."); } -- 2.34.1