diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-02-06 11:36:04 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-02-06 11:36:04 +0200 |
commit | de7ec7f1b7e387f933daef7ef035583a8ca8b715 (patch) | |
tree | 8ca8b8b169aa9191381f76cce926df196a5edb31 | |
parent | 3c8a0bdff49b5613fd65ec4a1420451bb69bd104 (diff) | |
download | tracifyjs-de7ec7f1b7e387f933daef7ef035583a8ca8b715.tar.gz tracifyjs-de7ec7f1b7e387f933daef7ef035583a8ca8b715.zip |
Fix parens for negative numbers
Close #115
-rw-r--r-- | lib/output.js | 8 |
1 files changed, 7 insertions, 1 deletions
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("."); } |