mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-05-03 03:00:14 -04:00
coco c39edf: braceless objects can now have trailing herecomments
This commit is contained in:
@@ -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 !== '(');
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user