coffeescript
Advanced tools
Comparing version 2.0.0-beta2 to 2.0.0-beta3
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CoffeeScript, compile, runScripts, |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var Lexer, SourceMap, base64encode, compile, formatSourcePosition, getSourceMap, helpers, lexer, packageJson, parser, sourceMaps, sources, withPrettyErrors; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, | ||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, buildCSOptionParser, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, | ||
indexOf = [].indexOf; | ||
@@ -52,4 +52,9 @@ | ||
exports.buildCSOptionParser = buildCSOptionParser = function() { | ||
return new optparse.OptionParser(SWITCHES, BANNER); | ||
}; | ||
exports.run = function() { | ||
var i, len, literals, ref, replCliOpts, results, source; | ||
optionParser = buildCSOptionParser(); | ||
parseOptions(); | ||
@@ -536,3 +541,2 @@ replCliOpts = { | ||
var o; | ||
optionParser = new optparse.OptionParser(SWITCHES, BANNER); | ||
o = opts = optionParser.parse(process.argv.slice(2)); | ||
@@ -592,3 +596,3 @@ o.compile || (o.compile = !!o.output); | ||
usage = function() { | ||
return printLine((new optparse.OptionParser(SWITCHES, BANNER)).help()); | ||
return printLine(optionParser.help()); | ||
}; | ||
@@ -595,0 +599,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -71,2 +71,4 @@ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; | ||
return new IdentifierLiteral($1); | ||
}), o('CSX_TAG', function() { | ||
return new CSXTag($1); | ||
}) | ||
@@ -125,3 +127,3 @@ ], | ||
return new Value($1); | ||
}), o('ObjAssignable : Expression', function() { | ||
}), o('ObjRestValue'), o('ObjAssignable : Expression', function() { | ||
return new Assign(LOC(1)(new Value($1)), $3, 'object', { | ||
@@ -146,2 +148,25 @@ operatorToken: LOC(2)(new Literal($2)) | ||
ObjAssignable: [o('SimpleObjAssignable'), o('AlphaNumeric')], | ||
ObjRestValue: [ | ||
o('SimpleObjAssignable ...', function() { | ||
return new Splat(new Value($1)); | ||
}), o('ObjSpreadExpr ...', function() { | ||
return new Splat($1); | ||
}) | ||
], | ||
ObjSpreadExpr: [ | ||
o('ObjSpreadIdentifier'), o('Object'), o('Parenthetical'), o('Super'), o('This'), o('SUPER Arguments', function() { | ||
return new SuperCall(LOC(1)(new Super), $2); | ||
}), o('SimpleObjAssignable Arguments', function() { | ||
return new Call(new Value($1), $2); | ||
}), o('ObjSpreadExpr Arguments', function() { | ||
return new Call($1, $2); | ||
}) | ||
], | ||
ObjSpreadIdentifier: [ | ||
o('SimpleObjAssignable . Property', function() { | ||
return (new Value($1)).add(new Access($3)); | ||
}), o('SimpleObjAssignable INDEX_START IndexValue INDEX_END', function() { | ||
return (new Value($1)).add($3); | ||
}) | ||
], | ||
Return: [ | ||
@@ -148,0 +173,0 @@ o('RETURN Expression', function() { |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CoffeeScript, compile, ext, fn, fs, helpers, i, len, path, ref, vm, |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, REGEX_INVALID_ESCAPE, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_INVALID_ESCAPE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, UNICODE_CODE_POINT_ESCAPE, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, isForFrom, isUnassignable, key, locationDataToString, merge, repeat, starts, throwSyntaxError, | ||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARABLE_LEFT_SIDE, COMPARE, COMPOUND_ASSIGN, CSX_ATTRIBUTE, CSX_IDENTIFIER, CSX_INTERPOLATION, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, HERE_JSTOKEN, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INSIDE_CSX, INVERSES, JSTOKEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, REGEX_INVALID_ESCAPE, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_INVALID_ESCAPE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, UNICODE_CODE_POINT_ESCAPE, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, isForFrom, isUnassignable, key, locationDataToString, merge, repeat, starts, throwSyntaxError, | ||
indexOf = [].indexOf; | ||
@@ -12,3 +12,3 @@ | ||
tokenize(code, opts = {}) { | ||
var consumed, end, i; | ||
var consumed, end, i, ref; | ||
this.literate = opts.literate; | ||
@@ -28,2 +28,3 @@ this.indent = 0; | ||
this.exportSpecifierList = false; | ||
this.csxDepth = 0; | ||
this.chunkLine = opts.line || 0; | ||
@@ -34,3 +35,3 @@ this.chunkColumn = opts.column || 0; | ||
while (this.chunk = code.slice(i)) { | ||
consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken(); | ||
consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.stringToken() || this.numberToken() || this.csxToken() || this.regexToken() || this.jsToken() || this.literalToken(); | ||
[this.chunkLine, this.chunkColumn] = this.getLineAndColumnFromChunk(consumed); | ||
@@ -47,3 +48,3 @@ i += consumed; | ||
if (end = this.ends.pop()) { | ||
this.error(`missing ${end.tag}`, end.origin[2]); | ||
this.error(`missing ${end.tag}`, ((ref = end.origin) != null ? ref : end)[2]); | ||
} | ||
@@ -72,4 +73,6 @@ if (opts.rewrite === false) { | ||
identifierToken() { | ||
var alias, colon, colonOffset, id, idLength, input, match, poppedToken, prev, prevprev, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, tag, tagToken; | ||
if (!(match = IDENTIFIER.exec(this.chunk))) { | ||
var alias, colon, colonOffset, colonToken, id, idLength, inCSXTag, input, match, poppedToken, prev, prevprev, ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, regex, tag, tagToken; | ||
inCSXTag = this.atCSXTag(); | ||
regex = inCSXTag ? CSX_ATTRIBUTE : IDENTIFIER; | ||
if (!(match = regex.exec(this.chunk))) { | ||
return 0; | ||
@@ -188,5 +191,11 @@ } | ||
if (colon) { | ||
colonOffset = input.lastIndexOf(':'); | ||
this.token(':', ':', colonOffset, colon.length); | ||
colonOffset = input.lastIndexOf(inCSXTag ? '=' : ':'); | ||
colonToken = this.token(':', ':', colonOffset, colon.length); | ||
if (inCSXTag) { | ||
colonToken.csxColon = true; | ||
} | ||
} | ||
if (inCSXTag && tag === 'IDENTIFIER' && prev[0] !== ':') { | ||
this.token(',', ',', 0, 0, tagToken); | ||
} | ||
return input.length; | ||
@@ -322,2 +331,5 @@ } | ||
} | ||
if (this.atCSXTag()) { | ||
this.token(',', ',', 0, 0, this.prev); | ||
} | ||
return end; | ||
@@ -511,3 +523,3 @@ } | ||
if (!lastIndent) { | ||
moveOut = 0; | ||
this.outdebt = moveOut = 0; | ||
} else if (this.outdebt && moveOut <= this.outdebt) { | ||
@@ -575,2 +587,94 @@ this.outdebt -= moveOut; | ||
csxToken() { | ||
var afterTag, colon, csxTag, end, firstChar, id, input, match, origin, prev, ref, token, tokens; | ||
firstChar = this.chunk[0]; | ||
if (firstChar === '<') { | ||
match = CSX_IDENTIFIER.exec(this.chunk.slice(1)); | ||
if (!(match && (this.csxDepth > 0 || !(prev = this.prev()) || prev.spaced || (ref = prev[0], indexOf.call(COMPARABLE_LEFT_SIDE, ref) < 0)))) { | ||
return 0; | ||
} | ||
[input, id, colon] = match; | ||
origin = this.token('CSX_TAG', id, 1, id.length); | ||
this.token('CALL_START', '('); | ||
this.token('{', '{'); | ||
this.ends.push({ | ||
tag: '/>', | ||
origin: origin, | ||
name: id | ||
}); | ||
this.csxDepth++; | ||
return id.length + 1; | ||
} else if (csxTag = this.atCSXTag()) { | ||
if (this.chunk.slice(0, 2) === '/>') { | ||
this.pair('/>'); | ||
this.token('}', '}', 0, 2); | ||
this.token('CALL_END', ')', 0, 2); | ||
this.csxDepth--; | ||
return 2; | ||
} else if (firstChar === '{') { | ||
token = this.token('(', '('); | ||
this.ends.push({ | ||
tag: '}', | ||
origin: token | ||
}); | ||
return 1; | ||
} else if (firstChar === '>') { | ||
this.pair('/>'); | ||
origin = this.token('}', '}'); | ||
this.token(',', ','); | ||
({ | ||
tokens, | ||
index: end | ||
} = this.matchWithInterpolations(INSIDE_CSX, '>', '</', CSX_INTERPOLATION)); | ||
this.mergeInterpolationTokens(tokens, { | ||
delimiter: '"' | ||
}, (value, i) => { | ||
return this.formatString(value, { | ||
delimiter: '>' | ||
}); | ||
}); | ||
match = CSX_IDENTIFIER.exec(this.chunk.slice(end)); | ||
if (!match || match[0] !== csxTag.name) { | ||
this.error(`expected corresponding CSX closing tag for ${csxTag.name}`, csxTag.origin[2]); | ||
} | ||
afterTag = end + csxTag.name.length; | ||
if (this.chunk[afterTag] !== '>') { | ||
this.error("missing closing > after tag name", { | ||
offset: afterTag, | ||
length: 1 | ||
}); | ||
} | ||
this.token('CALL_END', ')', end, csxTag.name.length + 1); | ||
this.csxDepth--; | ||
return afterTag + 1; | ||
} else { | ||
return 0; | ||
} | ||
} else if (this.atCSXTag(1)) { | ||
if (firstChar === '}') { | ||
this.pair(firstChar); | ||
this.token(')', ')'); | ||
this.token(',', ','); | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} else { | ||
return 0; | ||
} | ||
} | ||
atCSXTag(depth = 0) { | ||
var i, last, ref; | ||
if (this.csxDepth === 0) { | ||
return false; | ||
} | ||
i = this.ends.length - 1; | ||
while (((ref = this.ends[i]) != null ? ref.tag : void 0) === 'OUTDENT' || depth-- > 0) { | ||
i--; | ||
} | ||
last = this.ends[i]; | ||
return (last != null ? last.tag : void 0) === '/>' && last; | ||
} | ||
literalToken() { | ||
@@ -664,3 +768,3 @@ var match, message, origin, prev, ref, ref1, ref2, ref3, skipToken, tag, token, value; | ||
} | ||
this.tokens.push(token); | ||
this.tokens.push(this.makeToken(tag, value)); | ||
return value.length; | ||
@@ -670,3 +774,3 @@ } | ||
tagParameters() { | ||
var i, stack, tok, tokens; | ||
var i, paramEndToken, stack, tok, tokens; | ||
if (this.tag() !== ')') { | ||
@@ -678,3 +782,4 @@ return this; | ||
i = tokens.length; | ||
tokens[--i][0] = 'PARAM_END'; | ||
paramEndToken = tokens[--i]; | ||
paramEndToken[0] = 'PARAM_END'; | ||
while (tok = tokens[--i]) { | ||
@@ -693,2 +798,3 @@ switch (tok[0]) { | ||
} else { | ||
paramEndToken[0] = 'CALL_END'; | ||
return this; | ||
@@ -705,4 +811,10 @@ } | ||
matchWithInterpolations(regex, delimiter) { | ||
var close, column, firstToken, index, lastToken, line, nested, offsetInChunk, open, ref, str, strPart, tokens; | ||
matchWithInterpolations(regex, delimiter, closingDelimiter, interpolators) { | ||
var braceInterpolator, close, column, firstToken, index, interpolationOffset, interpolator, lastToken, line, match, nested, offsetInChunk, open, ref, rest, str, strPart, tokens; | ||
if (closingDelimiter == null) { | ||
closingDelimiter = delimiter; | ||
} | ||
if (interpolators == null) { | ||
interpolators = /^#\{/; | ||
} | ||
tokens = []; | ||
@@ -723,10 +835,13 @@ offsetInChunk = delimiter.length; | ||
offsetInChunk += strPart.length; | ||
if (str.slice(0, 2) !== '#{') { | ||
if (!(match = interpolators.exec(str))) { | ||
break; | ||
} | ||
[line, column] = this.getLineAndColumnFromChunk(offsetInChunk + 1); | ||
[interpolator] = match; | ||
interpolationOffset = interpolator.length - 1; | ||
[line, column] = this.getLineAndColumnFromChunk(offsetInChunk + interpolationOffset); | ||
rest = str.slice(interpolationOffset); | ||
({ | ||
tokens: nested, | ||
index | ||
} = new Lexer().tokenize(str.slice(1), { | ||
} = new Lexer().tokenize(rest, { | ||
line: line, | ||
@@ -736,10 +851,18 @@ column: column, | ||
})); | ||
index += 1; | ||
open = nested[0], close = nested[nested.length - 1]; | ||
open[0] = open[1] = '('; | ||
close[0] = close[1] = ')'; | ||
close.origin = ['', 'end of interpolation', close[2]]; | ||
index += interpolationOffset; | ||
braceInterpolator = str[index - 1] === '}'; | ||
if (braceInterpolator) { | ||
open = nested[0], close = nested[nested.length - 1]; | ||
open[0] = open[1] = '('; | ||
close[0] = close[1] = ')'; | ||
close.origin = ['', 'end of interpolation', close[2]]; | ||
} | ||
if (((ref = nested[1]) != null ? ref[0] : void 0) === 'TERMINATOR') { | ||
nested.splice(1, 1); | ||
} | ||
if (!braceInterpolator) { | ||
open = this.makeToken('(', '(', offsetInChunk, 0); | ||
close = this.makeToken(')', ')', offsetInChunk + index, 0); | ||
nested = [open, ...nested, close]; | ||
} | ||
tokens.push(['TOKENS', nested]); | ||
@@ -749,4 +872,4 @@ str = str.slice(index); | ||
} | ||
if (str.slice(0, delimiter.length) !== delimiter) { | ||
this.error(`missing ${delimiter}`, { | ||
if (str.slice(0, closingDelimiter.length) !== closingDelimiter) { | ||
this.error(`missing ${closingDelimiter}`, { | ||
length: delimiter.length | ||
@@ -759,5 +882,5 @@ }); | ||
lastToken[2].last_line += 1; | ||
lastToken[2].last_column = delimiter.length - 1; | ||
lastToken[2].last_column = closingDelimiter.length - 1; | ||
} else { | ||
lastToken[2].last_column += delimiter.length; | ||
lastToken[2].last_column += closingDelimiter.length; | ||
} | ||
@@ -769,3 +892,3 @@ if (lastToken[1].length === 0) { | ||
tokens, | ||
index: offsetInChunk + delimiter.length | ||
index: offsetInChunk + closingDelimiter.length | ||
}; | ||
@@ -1100,2 +1223,6 @@ } | ||
CSX_IDENTIFIER = /^(?![\d<])((?:(?!\s)[\.\-$\w\x7f-\uffff])+)/; | ||
CSX_ATTRIBUTE = /^(?!\d)((?:(?!\s)[\-$\w\x7f-\uffff])+)([^\S]*=(?!=))?/; | ||
NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; | ||
@@ -1127,2 +1254,6 @@ | ||
INSIDE_CSX = /^(?:[^\{<])*/; | ||
CSX_INTERPOLATION = /^(?:\{|<(?!\/))/; | ||
STRING_OMIT = /((?:\\\\)+)|\\[^\S\n]*\n\s*/g; | ||
@@ -1184,2 +1315,4 @@ | ||
COMPARABLE_LEFT_SIDE = ['IDENTIFIER', ')', ']', 'NUMBER']; | ||
NOT_REGEX = INDEXABLE.concat(['++', '--']); | ||
@@ -1186,0 +1319,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -47,3 +47,3 @@ var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, runInContext, updateSyntaxError, vm; | ||
ast = CoffeeScript.nodes(tokens); | ||
ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]); | ||
ast = new Block([new Assign(new Value(new Literal('__')), ast, '=')]); | ||
js = ast.compile({ | ||
@@ -50,0 +50,0 @@ bare: true, |
@@ -1,6 +0,8 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, Rewriter, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, rite, | ||
var BALANCED_PAIRS, CALL_CLOSERS, CONTROL_IN_IMPLICIT, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, Rewriter, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, rite, throwSyntaxError, | ||
indexOf = [].indexOf; | ||
({throwSyntaxError} = require('./helpers')); | ||
generate = function(tag, value, origin) { | ||
@@ -27,2 +29,3 @@ var tok; | ||
this.addLocationDataToGeneratedTokens(); | ||
this.enforceValidCSXAttributes(); | ||
this.fixOutdentLocationData(); | ||
@@ -42,3 +45,3 @@ return this.tokens; | ||
detectEnd(i, condition, action) { | ||
detectEnd(i, condition, action, opts = {}) { | ||
var levels, ref, ref1, token, tokens; | ||
@@ -51,5 +54,2 @@ ({tokens} = this); | ||
} | ||
if (!token || levels < 0) { | ||
return action.call(this, token, i - 1); | ||
} | ||
if (ref = token[0], indexOf.call(EXPRESSION_START, ref) >= 0) { | ||
@@ -60,2 +60,8 @@ levels += 1; | ||
} | ||
if (levels < 0) { | ||
if (opts.returnOnNegativeLevel) { | ||
return; | ||
} | ||
return action.call(this, token, i); | ||
} | ||
i += 1; | ||
@@ -84,6 +90,6 @@ } | ||
var ref; | ||
return ((ref = token[0]) === ')' || ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; | ||
return (ref = token[0]) === ')' || ref === 'CALL_END'; | ||
}; | ||
action = function(token, i) { | ||
return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END'; | ||
return token[0] = 'CALL_END'; | ||
}; | ||
@@ -176,6 +182,6 @@ return this.scanTokens(function(token, i) { | ||
return this.scanTokens(function(token, i, tokens) { | ||
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, isImplicit, isImplicitCall, isImplicitObject, k, newLine, nextTag, offset, prevTag, prevToken, ref, ref1, ref2, s, sameLine, stackIdx, stackItem, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag; | ||
var endImplicitCall, endImplicitObject, forward, implicitObjectContinues, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, isImplicit, isImplicitCall, isImplicitObject, k, newLine, nextTag, nextToken, offset, prevTag, prevToken, ref, s, sameLine, stackIdx, stackItem, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag; | ||
[tag] = token; | ||
[prevTag] = prevToken = i > 0 ? tokens[i - 1] : []; | ||
[nextTag] = i < tokens.length - 1 ? tokens[i + 1] : []; | ||
[nextTag] = nextToken = i < tokens.length - 1 ? tokens[i + 1] : []; | ||
stackTop = function() { | ||
@@ -211,5 +217,3 @@ return stack[stack.length - 1]; | ||
}; | ||
startImplicitCall = function(j) { | ||
var idx; | ||
idx = j != null ? j : i; | ||
startImplicitCall = function(idx) { | ||
stack.push([ | ||
@@ -220,6 +224,3 @@ '(', idx, { | ||
]); | ||
tokens.splice(idx, 0, generate('CALL_START', '(')); | ||
if (j == null) { | ||
return i += 1; | ||
} | ||
return tokens.splice(idx, 0, generate('CALL_START', '(')); | ||
}; | ||
@@ -231,5 +232,4 @@ endImplicitCall = function() { | ||
}; | ||
startImplicitObject = function(j, startsLine = true) { | ||
var idx, val; | ||
idx = j != null ? j : i; | ||
startImplicitObject = function(idx, startsLine = true) { | ||
var val; | ||
stack.push([ | ||
@@ -244,6 +244,3 @@ '{', idx, { | ||
val.generated = true; | ||
tokens.splice(idx, 0, generate('{', val, token)); | ||
if (j == null) { | ||
return i += 1; | ||
} | ||
return tokens.splice(idx, 0, generate('{', val, token)); | ||
}; | ||
@@ -256,3 +253,18 @@ endImplicitObject = function(j) { | ||
}; | ||
if (inImplicitCall() && (tag === 'IF' || tag === 'TRY' || tag === 'FINALLY' || tag === 'CATCH' || tag === 'CLASS' || tag === 'SWITCH')) { | ||
implicitObjectContinues = (j) => { | ||
var nextTerminatorIdx; | ||
nextTerminatorIdx = null; | ||
this.detectEnd(j, function(token) { | ||
return token[0] === 'TERMINATOR'; | ||
}, function(token, i) { | ||
return nextTerminatorIdx = i; | ||
}, { | ||
returnOnNegativeLevel: true | ||
}); | ||
if (nextTerminatorIdx == null) { | ||
return false; | ||
} | ||
return this.looksObjectish(nextTerminatorIdx + 1); | ||
}; | ||
if ((inImplicitCall() || inImplicitObject()) && indexOf.call(CONTROL_IN_IMPLICIT, tag) >= 0 || inImplicitObject() && prevTag === ':' && tag === 'FOR') { | ||
stack.push([ | ||
@@ -266,5 +278,9 @@ 'CONTROL', i, { | ||
if (tag === 'INDENT' && inImplicit()) { | ||
if (prevTag !== '=>' && prevTag !== '->' && prevTag !== '[' && prevTag !== '(' && prevTag !== ',' && prevTag !== '{' && prevTag !== 'TRY' && prevTag !== 'ELSE' && prevTag !== '=') { | ||
while (inImplicitCall()) { | ||
endImplicitCall(); | ||
if (prevTag !== '=>' && prevTag !== '->' && prevTag !== '[' && prevTag !== '(' && prevTag !== ',' && prevTag !== '{' && prevTag !== 'ELSE' && prevTag !== '=') { | ||
while (inImplicitCall() || inImplicitObject() && prevTag !== ':') { | ||
if (inImplicitCall()) { | ||
endImplicitCall(); | ||
} else { | ||
endImplicitObject(); | ||
} | ||
} | ||
@@ -294,3 +310,3 @@ } | ||
} | ||
if ((indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !((ref = tokens[i + 1]) != null ? ref.spaced : void 0) && !((ref1 = tokens[i + 1]) != null ? ref1.newLine : void 0))) { | ||
if ((indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !nextToken.spaced && !nextToken.newLine)) { | ||
if (tag === '?') { | ||
@@ -309,5 +325,5 @@ tag = token[0] = 'FUNC_EXIST'; | ||
s = (function() { | ||
var ref2; | ||
var ref; | ||
switch (false) { | ||
case ref2 = this.tag(i - 1), indexOf.call(EXPRESSION_END, ref2) < 0: | ||
case ref = this.tag(i - 1), indexOf.call(EXPRESSION_END, ref) < 0: | ||
return start[1]; | ||
@@ -323,4 +339,3 @@ case this.tag(i - 2) !== '@': | ||
} | ||
this.insideForDeclaration = nextTag === 'FOR'; | ||
startsLine = s === 0 || (ref2 = this.tag(s - 1), indexOf.call(LINEBREAKS, ref2) >= 0) || tokens[s - 1].newLine; | ||
startsLine = s === 0 || (ref = this.tag(s - 1), indexOf.call(LINEBREAKS, ref) >= 0) || tokens[s - 1].newLine; | ||
if (stackTop()) { | ||
@@ -349,3 +364,3 @@ [stackTag, stackIdx] = stackTop(); | ||
endImplicitCall(); | ||
} else if (inImplicitObject() && !this.insideForDeclaration && sameLine && tag !== 'TERMINATOR' && prevTag !== ':') { | ||
} else if (inImplicitObject() && sameLine && tag !== 'TERMINATOR' && prevTag !== ':' && !((tag === 'POST_IF' || tag === 'FOR' || tag === 'WHILE' || tag === 'UNTIL') && startsLine && implicitObjectContinues(i + 1))) { | ||
endImplicitObject(); | ||
@@ -362,3 +377,3 @@ } else if (inImplicitObject() && tag === 'TERMINATOR' && prevTag !== ',' && !(startsLine && this.looksObjectish(i + 1))) { | ||
} | ||
if (tag === ',' && !this.looksObjectish(i + 1) && inImplicitObject() && !this.insideForDeclaration && (nextTag !== 'TERMINATOR' || !this.looksObjectish(i + 2))) { | ||
if (tag === ',' && !this.looksObjectish(i + 1) && inImplicitObject() && (nextTag !== 'TERMINATOR' || !this.looksObjectish(i + 2))) { | ||
offset = nextTag === 'OUTDENT' ? 1 : 0; | ||
@@ -373,2 +388,15 @@ while (inImplicitObject()) { | ||
enforceValidCSXAttributes() { | ||
return this.scanTokens(function(token, i, tokens) { | ||
var next, ref; | ||
if (token.csxColon) { | ||
next = tokens[i + 1]; | ||
if ((ref = next[0]) !== 'STRING_START' && ref !== 'STRING' && ref !== '(') { | ||
throwSyntaxError('expected wrapped or quoted CSX attribute', next[2]); | ||
} | ||
} | ||
return 1; | ||
}); | ||
} | ||
addLocationDataToGeneratedTokens() { | ||
@@ -455,2 +483,7 @@ return this.scanTokens(function(token, i, tokens) { | ||
} | ||
if ((tag === '->' || tag === '=>') && (this.tag(i + 1) === ',' || this.tag(i + 1) === '.' && token.newLine)) { | ||
[indent, outdent] = this.indentation(tokens[i]); | ||
tokens.splice(i + 1, 0, indent, outdent); | ||
return 1; | ||
} | ||
if (indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { | ||
@@ -541,3 +574,3 @@ starter = tag; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'PROPERTY', 'NUMBER', 'INFINITY', 'NAN', 'STRING', 'STRING_START', 'REGEX', 'REGEX_START', 'JS', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'UNDEFINED', 'NULL', 'BOOL', 'UNARY', 'YIELD', 'AWAIT', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'CSX_TAG', 'PROPERTY', 'NUMBER', 'INFINITY', 'NAN', 'STRING', 'STRING_START', 'REGEX', 'REGEX_START', 'JS', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'UNDEFINED', 'NULL', 'BOOL', 'UNARY', 'YIELD', 'AWAIT', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
@@ -556,2 +589,4 @@ IMPLICIT_UNSPACED_CALL = ['+', '-']; | ||
CONTROL_IN_IMPLICIT = ['IF', 'TRY', 'FINALLY', 'CATCH', 'CLASS', 'SWITCH']; | ||
}).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var Scope, |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 2.0.0-beta2 | ||
// Generated by CoffeeScript 2.0.0-beta3 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var LineMap, SourceMap; |
@@ -11,3 +11,3 @@ { | ||
"author": "Jeremy Ashkenas", | ||
"version": "2.0.0-beta2", | ||
"version": "2.0.0-beta3", | ||
"license": "MIT", | ||
@@ -14,0 +14,0 @@ "engines": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
427130
9829