From dc9cec26113c5c4290f749b753c91466c203eb55 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 13 Feb 2010 00:24:26 -0500 Subject: [PATCH] fixing object/comment printing --- lib/coffee_script/grammar.js | 2 +- lib/coffee_script/nodes.js | 4 ++-- src/grammar.coffee | 2 +- src/nodes.coffee | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/coffee_script/grammar.js b/lib/coffee_script/grammar.js index 5a460b65..84acee5b 100644 --- a/lib/coffee_script/grammar.js +++ b/lib/coffee_script/grammar.js @@ -558,7 +558,7 @@ // puts parser.generate() posix = require('posix'); parser_path = 'lib/coffee_script/parser.js'; - posix.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, 0755).addCallback(function(fd) { + posix.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback(function(fd) { return posix.write(fd, js); }); })(); \ No newline at end of file diff --git a/lib/coffee_script/nodes.js b/lib/coffee_script/nodes.js index b1872352..4aa02f98 100644 --- a/lib/coffee_script/nodes.js +++ b/lib/coffee_script/nodes.js @@ -661,10 +661,10 @@ prop = __e[i]; __d.push((function() { join = ",\n"; - if (prop === last_noncom || prop instanceof CommentNode) { + if ((prop === last_noncom) || (prop instanceof CommentNode)) { join = "\n"; } - if (i === non_comments.length - 1) { + if (i === this.properties.length - 1) { join = ''; } indent = prop instanceof CommentNode ? '' : this.idt(1); diff --git a/src/grammar.coffee b/src/grammar.coffee index 50ec78d4..a6c75cac 100644 --- a/src/grammar.coffee +++ b/src/grammar.coffee @@ -456,5 +456,5 @@ js: parser.generate() # puts parser.generate() posix: require 'posix' parser_path: 'lib/coffee_script/parser.js' -posix.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, 0755).addCallback (fd) -> +posix.open(parser_path, process.O_CREAT | process.O_WRONLY | process.O_TRUNC, parseInt('0755', 8)).addCallback (fd) -> posix.write(fd, js) diff --git a/src/nodes.coffee b/src/nodes.coffee index 7ef9435b..1f591d04 100644 --- a/src/nodes.coffee +++ b/src/nodes.coffee @@ -511,8 +511,8 @@ ObjectNode: exports.ObjectNode: inherit Node, { last_noncom: non_comments[non_comments.length - 1] props: for prop, i in @properties join: ",\n" - join: "\n" if prop is last_noncom or prop instanceof CommentNode - join: '' if i is non_comments.length - 1 + join: "\n" if (prop is last_noncom) or (prop instanceof CommentNode) + join: '' if i is @properties.length - 1 indent: if prop instanceof CommentNode then '' else @idt(1) indent + prop.compile(o) + join props: props.join('')