coco c39edf: braceless objects can now have trailing herecomments

This commit is contained in:
Jeremy Ashkenas
2010-11-12 20:16:08 -05:00
parent 9fa973debe
commit 6d3e9df89f
3 changed files with 5 additions and 5 deletions

View File

@@ -115,10 +115,10 @@
start = null;
condition = function(token, i) {
var one, tag, three, two, _ref, _ref2;
if ('HERECOMMENT' === this.tag(i + 1) || 'HERECOMMENT' === this.tag(i - 1)) {
_ref = this.tokens, one = _ref[i + 1], two = _ref[i + 2], three = _ref[i + 3];
if ('HERECOMMENT' === (one != null ? one[0] : void 0)) {
return false;
}
_ref = this.tokens, one = _ref[i + 1], two = _ref[i + 2], three = _ref[i + 3];
tag = token[0];
return (tag === 'TERMINATOR' || tag === 'OUTDENT') && !((two != null ? two[0] : void 0) === ':' || (one != null ? one[0] : void 0) === '@' && (three != null ? three[0] : void 0) === ':') || tag === ',' && one && ((_ref2 = one[0]) !== 'IDENTIFIER' && _ref2 !== 'NUMBER' && _ref2 !== 'STRING' && _ref2 !== '@' && _ref2 !== 'TERMINATOR' && _ref2 !== 'OUTDENT' && _ref2 !== '(');
};

View File

@@ -96,8 +96,8 @@ class exports.Rewriter
stack = []
start = null
condition = (token, i) ->
return false if 'HERECOMMENT' in [@tag(i + 1), @tag(i - 1)]
{(i+1): one, (i+2): two, (i+3): three} = @tokens
return false if 'HERECOMMENT' is one?[0]
[tag] = token
tag in ['TERMINATOR', 'OUTDENT'] and
not (two?[0] is ':' or one?[0] is '@' and three?[0] is ':') or

View File

@@ -69,9 +69,9 @@ ok obj.is()
ok not obj.not()
# Top-level object literal doesn't break things.
### Top-level object literal... ###
obj: 1
### ...doesn't break things. ###
# Funky indentation within non-comma-seperated arrays.
result = [['a']