coffeescript
Advanced tools
Comparing version 1.8.0 to 1.9.0
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -44,3 +44,3 @@ var CoffeeScript, compile, runScripts, | ||
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap; | ||
return "" + js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript"; | ||
return js + "\n//# sourceMappingURL=data:application/json;base64," + (btoa(unescape(encodeURIComponent(v3SourceMap)))) + "\n//# sourceURL=coffeescript"; | ||
}; | ||
@@ -47,0 +47,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -79,3 +79,3 @@ var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; | ||
cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile'); | ||
console.log("" + cakefilePath + " defines the following tasks:\n"); | ||
console.log(cakefilePath + " defines the following tasks:\n"); | ||
for (name in tasks) { | ||
@@ -82,0 +82,0 @@ task = tasks[name]; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -21,3 +21,3 @@ var Lexer, SourceMap, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors, _base, _i, _len, _ref, | ||
exports.VERSION = '1.8.0'; | ||
exports.VERSION = '1.9.0'; | ||
@@ -44,3 +44,3 @@ exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md']; | ||
exports.compile = compile = withPrettyErrors(function(code, options) { | ||
var answer, currentColumn, currentLine, extend, fragment, fragments, header, js, map, merge, newLines, _i, _len; | ||
var answer, currentColumn, currentLine, extend, fragment, fragments, header, js, map, merge, newLines, token, tokens, _i, _len; | ||
merge = helpers.merge, extend = helpers.extend; | ||
@@ -51,3 +51,15 @@ options = extend({}, options); | ||
} | ||
fragments = parser.parse(lexer.tokenize(code, options)).compileToFragments(options); | ||
tokens = lexer.tokenize(code, options); | ||
options.referencedVars = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = tokens.length; _i < _len; _i++) { | ||
token = tokens[_i]; | ||
if (token.variable && token[1].charAt(0) === '_') { | ||
_results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
fragments = parser.parse(tokens).compileToFragments(options); | ||
currentLine = 0; | ||
@@ -126,3 +138,3 @@ if (options.header) { | ||
exports["eval"] = function(code, options) { | ||
var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _require; | ||
var Module, createContext, isContext, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _ref2, _ref3, _require; | ||
if (options == null) { | ||
@@ -134,13 +146,16 @@ options = {}; | ||
} | ||
Script = vm.Script; | ||
if (Script) { | ||
createContext = (_ref = vm.Script.createContext) != null ? _ref : vm.createContext; | ||
isContext = (_ref1 = vm.isContext) != null ? _ref1 : function(ctx) { | ||
return options.sandbox instanceof createContext().constructor; | ||
}; | ||
if (createContext) { | ||
if (options.sandbox != null) { | ||
if (options.sandbox instanceof Script.createContext().constructor) { | ||
if (isContext(options.sandbox)) { | ||
sandbox = options.sandbox; | ||
} else { | ||
sandbox = Script.createContext(); | ||
_ref = options.sandbox; | ||
for (k in _ref) { | ||
if (!__hasProp.call(_ref, k)) continue; | ||
v = _ref[k]; | ||
sandbox = createContext(); | ||
_ref2 = options.sandbox; | ||
for (k in _ref2) { | ||
if (!__hasProp.call(_ref2, k)) continue; | ||
v = _ref2[k]; | ||
sandbox[k] = v; | ||
@@ -162,5 +177,5 @@ } | ||
_module.filename = sandbox.__filename; | ||
_ref1 = Object.getOwnPropertyNames(require); | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
r = _ref1[_i]; | ||
_ref3 = Object.getOwnPropertyNames(require); | ||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) { | ||
r = _ref3[_i]; | ||
if (r !== 'paths') { | ||
@@ -232,6 +247,6 @@ _require[r] = require[r]; | ||
var tag, token; | ||
token = this.tokens[this.pos++]; | ||
token = parser.tokens[this.pos++]; | ||
if (token) { | ||
tag = token[0], this.yytext = token[1], this.yylloc = token[2]; | ||
this.errorToken = token.origin || token; | ||
parser.errorToken = token.origin || token; | ||
this.yylineno = this.yylloc.first_line; | ||
@@ -244,3 +259,3 @@ } else { | ||
setInput: function(tokens) { | ||
this.tokens = tokens; | ||
parser.tokens = tokens; | ||
return this.pos = 0; | ||
@@ -256,5 +271,5 @@ }, | ||
parser.yy.parseError = function(message, _arg) { | ||
var errorLoc, errorTag, errorText, errorToken, token, tokens, _ref1; | ||
var errorLoc, errorTag, errorText, errorToken, token, tokens; | ||
token = _arg.token; | ||
_ref1 = parser.lexer, errorToken = _ref1.errorToken, tokens = _ref1.tokens; | ||
errorToken = parser.errorToken, tokens = parser.tokens; | ||
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2]; | ||
@@ -275,3 +290,3 @@ errorText = errorToken === tokens[tokens.length - 1] ? 'end of input' : errorTag === 'INDENT' || errorTag === 'OUTDENT' ? 'indentation' : helpers.nameWhitespaceCharacter(errorText); | ||
if (!fileName) { | ||
fileLocation = "" + (frame.getEvalOrigin()) + ", "; | ||
fileLocation = (frame.getEvalOrigin()) + ", "; | ||
} | ||
@@ -285,3 +300,3 @@ } else { | ||
source = getSourceMapping(fileName, line, column); | ||
fileLocation = source ? "" + fileName + ":" + source[0] + ":" + source[1] : "" + fileName + ":" + line + ":" + column; | ||
fileLocation = source ? fileName + ":" + source[0] + ":" + source[1] : fileName + ":" + line + ":" + column; | ||
} | ||
@@ -297,3 +312,3 @@ functionName = frame.getFunctionName(); | ||
if (typeName && functionName.indexOf(typeName)) { | ||
tp = "" + typeName + "."; | ||
tp = typeName + "."; | ||
} | ||
@@ -305,3 +320,3 @@ if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) { | ||
} else { | ||
return "" + typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")"; | ||
return typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")"; | ||
} | ||
@@ -311,3 +326,3 @@ } else if (isConstructor) { | ||
} else if (functionName) { | ||
return "" + functionName + " (" + fileLocation + ")"; | ||
return functionName + " (" + fileLocation + ")"; | ||
} else { | ||
@@ -358,5 +373,5 @@ return fileLocation; | ||
})(); | ||
return "" + (err.toString()) + "\n" + (frames.join('\n')) + "\n"; | ||
return (err.toString()) + "\n" + (frames.join('\n')) + "\n"; | ||
}; | ||
}).call(this); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -16,4 +16,2 @@ var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, 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, _ref, | ||
mkdirp = require('mkdirp'); | ||
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec; | ||
@@ -444,2 +442,23 @@ | ||
mkdirp = function(dir, fn) { | ||
var mkdirs, mode; | ||
mode = 0x1ff & ~process.umask(); | ||
return (mkdirs = function(p, fn) { | ||
return fs.exists(p, function(exists) { | ||
if (exists) { | ||
return fn(); | ||
} else { | ||
return mkdirs(path.dirname(p), function() { | ||
return fs.mkdir(p, mode, function(err) { | ||
if (err) { | ||
return fn(err); | ||
} | ||
return fn(); | ||
}); | ||
}); | ||
} | ||
}); | ||
})(dir, fn); | ||
}; | ||
writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) { | ||
@@ -458,3 +477,3 @@ var compile, jsDir, sourceMapPath; | ||
if (generatedSourceMap) { | ||
js = "" + js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n"; | ||
js = js + "\n//# sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, useWinPathSep)) + "\n"; | ||
} | ||
@@ -493,3 +512,3 @@ fs.writeFile(jsPath, js, function(err) { | ||
timeLog = function(message) { | ||
return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message); | ||
return console.log(((new Date).toLocaleTimeString()) + " - " + message); | ||
}; | ||
@@ -496,0 +515,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -424,2 +424,7 @@ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; | ||
}; | ||
}), o('FOR Range BY Expression', function() { | ||
return { | ||
source: LOC(2)(new Value($2)), | ||
step: $4 | ||
}; | ||
}), o('ForStart ForSource', function() { | ||
@@ -556,2 +561,8 @@ $2.own = $1.own; | ||
prec: 'UNARY_MATH' | ||
}), o('YIELD Statement', function() { | ||
return new Op($1, $2); | ||
}), o('YIELD Expression', function() { | ||
return new Op($1, $2); | ||
}), o('YIELD FROM Expression', function() { | ||
return new Op($1.concat($2), $3); | ||
}), o('-- SimpleAssignable', function() { | ||
@@ -599,3 +610,3 @@ return new Op('--', $2); | ||
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']]; | ||
operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['right', '**'], ['right', 'UNARY_MATH'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', 'YIELD'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['left', 'POST_IF']]; | ||
@@ -602,0 +613,0 @@ tokens = []; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -153,3 +153,3 @@ var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref; | ||
if (locationData) { | ||
return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1)); | ||
return ((locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ((locationData.last_line + 1) + ":" + (locationData.last_column + 1)); | ||
} else { | ||
@@ -235,3 +235,3 @@ return "No location data"; | ||
} | ||
return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker; | ||
return filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker; | ||
}; | ||
@@ -238,0 +238,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var key, val, _ref; |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, UNARY_MATH, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1, | ||
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, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NUMBER, OCTAL_ESCAPE, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -14,3 +14,3 @@ | ||
Lexer.prototype.tokenize = function(code, opts) { | ||
var consumed, i, tag, _ref2; | ||
var consumed, end, i, _ref2; | ||
if (opts == null) { | ||
@@ -32,9 +32,15 @@ opts = {}; | ||
while (this.chunk = code.slice(i)) { | ||
consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken(); | ||
consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken(); | ||
_ref2 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = _ref2[0], this.chunkColumn = _ref2[1]; | ||
i += consumed; | ||
if (opts.untilBalanced && this.ends.length === 0) { | ||
return { | ||
tokens: this.tokens, | ||
index: i | ||
}; | ||
} | ||
} | ||
this.closeIndentation(); | ||
if (tag = this.ends.pop()) { | ||
this.error("missing " + tag); | ||
if (end = this.ends.pop()) { | ||
throwSyntaxError("missing " + end.tag, end.origin[2]); | ||
} | ||
@@ -74,2 +80,6 @@ if (opts.rewrite === false) { | ||
} | ||
if (id === 'from' && this.tag() === 'YIELD') { | ||
this.token('FROM', id); | ||
return id.length; | ||
} | ||
forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::' || _ref2 === '?::') || !prev.spaced && prev[0] === '@'); | ||
@@ -135,2 +145,3 @@ tag = 'IDENTIFIER'; | ||
tagToken = this.token(tag, id, 0, idLength); | ||
tagToken.variable = !forcedIdentifier; | ||
if (poppedToken) { | ||
@@ -173,58 +184,85 @@ _ref4 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = _ref4[0], tagToken[2].first_column = _ref4[1]; | ||
Lexer.prototype.stringToken = function() { | ||
var inner, innerLen, numBreak, octalEsc, pos, quote, string, trimmed; | ||
switch (quote = this.chunk.charAt(0)) { | ||
case "'": | ||
string = (SIMPLESTR.exec(this.chunk) || [])[0]; | ||
break; | ||
case '"': | ||
string = this.balancedString(this.chunk, '"'); | ||
} | ||
if (!string) { | ||
var $, attempt, doc, end, heredoc, i, indent, indentRegex, match, quote, regex, start, token, tokens, _ref2, _ref3; | ||
quote = (STRING_START.exec(this.chunk) || [])[0]; | ||
if (!quote) { | ||
return 0; | ||
} | ||
inner = string.slice(1, -1); | ||
trimmed = this.removeNewlines(inner); | ||
if (quote === '"' && 0 < string.indexOf('#{', 1)) { | ||
numBreak = pos = 0; | ||
innerLen = inner.length; | ||
while (inner.charAt(pos++) === '\n' && pos < innerLen) { | ||
numBreak++; | ||
regex = (function() { | ||
switch (quote) { | ||
case "'": | ||
return STRING_SINGLE; | ||
case '"': | ||
return STRING_DOUBLE; | ||
case "'''": | ||
return HEREDOC_SINGLE; | ||
case '"""': | ||
return HEREDOC_DOUBLE; | ||
} | ||
this.interpolateString(trimmed, { | ||
strOffset: 1 + numBreak, | ||
lexedLength: string.length | ||
}); | ||
})(); | ||
heredoc = quote.length === 3; | ||
start = quote.length; | ||
_ref2 = this.matchWithInterpolations(this.chunk.slice(start), regex, quote, start), tokens = _ref2.tokens, end = _ref2.index; | ||
$ = tokens.length - 1; | ||
if (heredoc) { | ||
indent = null; | ||
doc = ((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { | ||
token = tokens[i]; | ||
if (token[0] === 'NEOSTRING') { | ||
_results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
})()).join('#{}'); | ||
while (match = HEREDOC_INDENT.exec(doc)) { | ||
attempt = match[1]; | ||
if (indent === null || (0 < (_ref3 = attempt.length) && _ref3 < indent.length)) { | ||
indent = attempt; | ||
} | ||
} | ||
if (indent) { | ||
indentRegex = RegExp("^" + indent, "gm"); | ||
} | ||
this.mergeInterpolationTokens(tokens, { | ||
quote: quote[0], | ||
start: start, | ||
end: end | ||
}, (function(_this) { | ||
return function(value, i) { | ||
value = _this.formatString(value); | ||
if (i === 0) { | ||
value = value.replace(LEADING_BLANK_LINE, ''); | ||
} | ||
if (i === $) { | ||
value = value.replace(TRAILING_BLANK_LINE, ''); | ||
} | ||
value = value.replace(indentRegex, ''); | ||
value = value.replace(MULTILINER, '\\n'); | ||
return value; | ||
}; | ||
})(this)); | ||
} else { | ||
this.token('STRING', quote + this.escapeLines(trimmed) + quote, 0, string.length); | ||
this.mergeInterpolationTokens(tokens, { | ||
quote: quote, | ||
start: start, | ||
end: end | ||
}, (function(_this) { | ||
return function(value, i) { | ||
value = _this.formatString(value); | ||
value = value.replace(STRING_OMIT, function(match, offset) { | ||
if ((i === 0 && offset === 0) || (i === $ && offset + match.length === value.length)) { | ||
return ''; | ||
} else { | ||
return ' '; | ||
} | ||
}); | ||
return value; | ||
}; | ||
})(this)); | ||
} | ||
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) { | ||
this.error("octal escape sequences " + string + " are not allowed"); | ||
} | ||
return string.length; | ||
return end; | ||
}; | ||
Lexer.prototype.heredocToken = function() { | ||
var doc, heredoc, match, quote, strOffset; | ||
if (!(match = HEREDOC.exec(this.chunk))) { | ||
return 0; | ||
} | ||
heredoc = match[0]; | ||
quote = heredoc.charAt(0); | ||
doc = this.sanitizeHeredoc(match[2], { | ||
quote: quote, | ||
indent: null | ||
}); | ||
if (quote === '"' && 0 <= doc.indexOf('#{')) { | ||
strOffset = match[2].charAt(0) === '\n' ? 4 : 3; | ||
this.interpolateString(doc, { | ||
heredoc: true, | ||
strOffset: strOffset, | ||
lexedLength: heredoc.length | ||
}); | ||
} else { | ||
this.token('STRING', this.makeString(doc, quote, true), 0, heredoc.length); | ||
} | ||
return heredoc.length; | ||
}; | ||
Lexer.prototype.commentToken = function() { | ||
@@ -237,6 +275,9 @@ var comment, here, match; | ||
if (here) { | ||
this.token('HERECOMMENT', this.sanitizeHeredoc(here, { | ||
herecomment: true, | ||
indent: repeat(' ', this.indent) | ||
}), 0, comment.length); | ||
if (match = HERECOMMENT_ILLEGAL.exec(comment)) { | ||
this.error("block comments cannot contain " + match[0], match.index); | ||
} | ||
if (here.indexOf('\n') >= 0) { | ||
here = here.replace(RegExp("\\n" + (repeat(' ', this.indent)), "g"), '\n'); | ||
} | ||
this.token('HERECOMMENT', here, 0, comment.length); | ||
} | ||
@@ -256,82 +297,63 @@ return comment.length; | ||
Lexer.prototype.regexToken = function() { | ||
var flags, length, match, prev, regex, _ref2, _ref3; | ||
if (this.chunk.charAt(0) !== '/') { | ||
return 0; | ||
var closed, end, flags, index, match, prev, re, regex, rparen, tokens, _ref2, _ref3, _ref4; | ||
switch (false) { | ||
case !(match = REGEX_ILLEGAL.exec(this.chunk)): | ||
this.error("regular expressions cannot begin with " + match[2], match.index + match[1].length); | ||
break; | ||
case this.chunk.slice(0, 3) !== '///': | ||
_ref2 = this.matchWithInterpolations(this.chunk.slice(3), HEREGEX, '///', 3), tokens = _ref2.tokens, index = _ref2.index; | ||
break; | ||
case !(match = REGEX.exec(this.chunk)): | ||
regex = match[0], closed = match[1]; | ||
index = regex.length; | ||
prev = last(this.tokens); | ||
if (prev) { | ||
if (prev.spaced && (_ref3 = prev[0], __indexOf.call(CALLABLE, _ref3) >= 0) && !prev.stringEnd && !prev.regexEnd) { | ||
if (!closed || POSSIBLY_DIVISION.test(regex)) { | ||
return 0; | ||
} | ||
} else if (_ref4 = prev[0], __indexOf.call(NOT_REGEX, _ref4) >= 0) { | ||
return 0; | ||
} | ||
} | ||
if (!closed) { | ||
this.error('missing / (unclosed regex)'); | ||
} | ||
break; | ||
default: | ||
return 0; | ||
} | ||
if (length = this.heregexToken()) { | ||
return length; | ||
} | ||
prev = last(this.tokens); | ||
if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) { | ||
return 0; | ||
} | ||
if (!(match = REGEX.exec(this.chunk))) { | ||
return 0; | ||
} | ||
_ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2]; | ||
if (regex === '//') { | ||
return 0; | ||
} | ||
if (regex.slice(0, 2) === '/*') { | ||
this.error('regular expressions cannot begin with `*`'); | ||
} | ||
this.token('REGEX', "" + regex + flags, 0, match.length); | ||
return match.length; | ||
}; | ||
Lexer.prototype.heregexToken = function() { | ||
var body, flags, flagsOffset, heregex, match, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; | ||
if (!(match = HEREGEX.exec(this.chunk))) { | ||
return 0; | ||
} | ||
heregex = match[0], body = match[1], flags = match[2]; | ||
if (0 > body.indexOf('#{')) { | ||
re = this.escapeLines(body.replace(HEREGEX_OMIT, '$1$2').replace(/\//g, '\\/'), true); | ||
if (re.match(/^\*/)) { | ||
this.error('regular expressions cannot begin with `*`'); | ||
} | ||
this.token('REGEX', "/" + (re || '(?:)') + "/" + flags, 0, heregex.length); | ||
return heregex.length; | ||
} | ||
this.token('IDENTIFIER', 'RegExp', 0, 0); | ||
this.token('CALL_START', '(', 0, 0); | ||
tokens = []; | ||
_ref2 = this.interpolateString(body, { | ||
regex: true, | ||
strOffset: 3 | ||
}); | ||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { | ||
token = _ref2[_i]; | ||
tag = token[0], value = token[1]; | ||
if (tag === 'TOKENS') { | ||
tokens.push.apply(tokens, value); | ||
} else if (tag === 'NEOSTRING') { | ||
if (!(value = value.replace(HEREGEX_OMIT, '$1$2'))) { | ||
continue; | ||
flags = REGEX_FLAGS.exec(this.chunk.slice(index))[0]; | ||
end = index + flags.length; | ||
switch (false) { | ||
case !!VALID_FLAGS.test(flags): | ||
this.error("invalid regular expression flags " + flags, index); | ||
break; | ||
case !regex: | ||
this.token('REGEX', "" + regex + flags); | ||
break; | ||
case tokens.length !== 1: | ||
re = this.formatHeregex(tokens[0][1]).replace(/\//g, '\\/'); | ||
this.token('REGEX', "/" + (re || '(?:)') + "/" + flags); | ||
break; | ||
default: | ||
this.token('IDENTIFIER', 'RegExp', 0, 0); | ||
this.token('CALL_START', '(', 0, 0); | ||
this.mergeInterpolationTokens(tokens, { | ||
quote: '"', | ||
start: 3, | ||
end: end | ||
}, (function(_this) { | ||
return function(value) { | ||
return _this.formatHeregex(value).replace(/\\/g, '\\\\'); | ||
}; | ||
})(this)); | ||
if (flags) { | ||
this.token(',', ',', index, 0); | ||
this.token('STRING', '"' + flags + '"', index, flags.length); | ||
} | ||
value = value.replace(/\\/g, '\\\\'); | ||
token[0] = 'STRING'; | ||
token[1] = this.makeString(value, '"', true); | ||
tokens.push(token); | ||
} else { | ||
this.error("Unexpected " + tag); | ||
} | ||
prev = last(this.tokens); | ||
plusToken = ['+', '+']; | ||
plusToken[2] = prev[2]; | ||
tokens.push(plusToken); | ||
rparen = this.token(')', ')', end, 0); | ||
rparen.regexEnd = true; | ||
} | ||
tokens.pop(); | ||
if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') { | ||
this.token('STRING', '""', 0, 0); | ||
this.token('+', '+', 0, 0); | ||
} | ||
(_ref4 = this.tokens).push.apply(_ref4, tokens); | ||
if (flags) { | ||
flagsOffset = heregex.lastIndexOf(flags); | ||
this.token(',', ',', flagsOffset, 0); | ||
this.token('STRING', '"' + flags + '"', flagsOffset, flags.length); | ||
} | ||
this.token(')', ')', heregex.length - 1, 0); | ||
return heregex.length; | ||
return end; | ||
}; | ||
@@ -369,3 +391,5 @@ | ||
this.indents.push(diff); | ||
this.ends.push('OUTDENT'); | ||
this.ends.push({ | ||
tag: 'OUTDENT' | ||
}); | ||
this.outdebt = this.indebt = 0; | ||
@@ -454,3 +478,3 @@ this.indent = size; | ||
Lexer.prototype.literalToken = function() { | ||
var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5; | ||
var match, prev, tag, token, value, _ref2, _ref3, _ref4, _ref5; | ||
if (match = OPERATOR.exec(this.chunk)) { | ||
@@ -494,3 +518,3 @@ value = match[0]; | ||
} else if (prev && !prev.spaced) { | ||
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) { | ||
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0) && !prev.stringEnd && !prev.regexEnd) { | ||
if (prev[0] === '?') { | ||
@@ -508,2 +532,3 @@ prev[0] = 'FUNC_EXIST'; | ||
} | ||
token = this.makeToken(tag, value); | ||
switch (value) { | ||
@@ -513,3 +538,6 @@ case '(': | ||
case '[': | ||
this.ends.push(INVERSES[value]); | ||
this.ends.push({ | ||
tag: INVERSES[value], | ||
origin: token | ||
}); | ||
break; | ||
@@ -521,33 +549,6 @@ case ')': | ||
} | ||
this.token(tag, value); | ||
this.tokens.push(token); | ||
return value.length; | ||
}; | ||
Lexer.prototype.sanitizeHeredoc = function(doc, options) { | ||
var attempt, herecomment, indent, match, _ref2; | ||
indent = options.indent, herecomment = options.herecomment; | ||
if (herecomment) { | ||
if (HEREDOC_ILLEGAL.test(doc)) { | ||
this.error("block comment cannot contain \"*/\", starting"); | ||
} | ||
if (doc.indexOf('\n') < 0) { | ||
return doc; | ||
} | ||
} else { | ||
while (match = HEREDOC_INDENT.exec(doc)) { | ||
attempt = match[1]; | ||
if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) { | ||
indent = attempt; | ||
} | ||
} | ||
} | ||
if (indent) { | ||
doc = doc.replace(RegExp("\\n" + indent, "g"), '\n'); | ||
} | ||
if (!herecomment) { | ||
doc = doc.replace(/^\n/, ''); | ||
} | ||
return doc; | ||
}; | ||
Lexer.prototype.tagParameters = function() { | ||
@@ -586,109 +587,78 @@ var i, stack, tok, tokens; | ||
Lexer.prototype.balancedString = function(str, end) { | ||
var continueCount, i, letter, match, prev, stack, _i, _ref2; | ||
continueCount = 0; | ||
stack = [end]; | ||
for (i = _i = 1, _ref2 = str.length; 1 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 1 <= _ref2 ? ++_i : --_i) { | ||
if (continueCount) { | ||
--continueCount; | ||
continue; | ||
Lexer.prototype.matchWithInterpolations = function(str, regex, end, offsetInChunk) { | ||
var close, column, index, line, nested, open, strPart, tokens, _ref2, _ref3, _ref4; | ||
tokens = []; | ||
while (true) { | ||
strPart = regex.exec(str)[0]; | ||
tokens.push(this.makeToken('NEOSTRING', strPart, offsetInChunk)); | ||
str = str.slice(strPart.length); | ||
offsetInChunk += strPart.length; | ||
if (str.slice(0, 2) !== '#{') { | ||
break; | ||
} | ||
switch (letter = str.charAt(i)) { | ||
case '\\': | ||
++continueCount; | ||
continue; | ||
case end: | ||
stack.pop(); | ||
if (!stack.length) { | ||
return str.slice(0, +i + 1 || 9e9); | ||
} | ||
end = stack[stack.length - 1]; | ||
continue; | ||
_ref2 = this.getLineAndColumnFromChunk(offsetInChunk + 1), line = _ref2[0], column = _ref2[1]; | ||
_ref3 = new Lexer().tokenize(str.slice(1), { | ||
line: line, | ||
column: column, | ||
untilBalanced: true | ||
}), nested = _ref3.tokens, index = _ref3.index; | ||
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]]; | ||
if (((_ref4 = nested[1]) != null ? _ref4[0] : void 0) === 'TERMINATOR') { | ||
nested.splice(1, 1); | ||
} | ||
if (end === '}' && (letter === '"' || letter === "'")) { | ||
stack.push(end = letter); | ||
} else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) { | ||
continueCount += match[0].length - 1; | ||
} else if (end === '}' && letter === '{') { | ||
stack.push(end = '}'); | ||
} else if (end === '"' && prev === '#' && letter === '{') { | ||
stack.push(end = '}'); | ||
} | ||
prev = letter; | ||
tokens.push(['TOKENS', nested]); | ||
str = str.slice(index); | ||
offsetInChunk += index; | ||
} | ||
return this.error("missing " + (stack.pop()) + ", starting"); | ||
if (str.slice(0, end.length) !== end) { | ||
this.error("missing " + end); | ||
} | ||
return { | ||
tokens: tokens, | ||
index: offsetInChunk + end.length | ||
}; | ||
}; | ||
Lexer.prototype.interpolateString = function(str, options) { | ||
var column, errorToken, expr, heredoc, i, inner, interpolated, len, letter, lexedLength, line, locationToken, nested, offsetInChunk, pi, plusToken, popped, regex, rparen, strOffset, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
heredoc = options.heredoc, regex = options.regex, offsetInChunk = options.offsetInChunk, strOffset = options.strOffset, lexedLength = options.lexedLength; | ||
offsetInChunk || (offsetInChunk = 0); | ||
strOffset || (strOffset = 0); | ||
lexedLength || (lexedLength = str.length); | ||
tokens = []; | ||
pi = 0; | ||
i = -1; | ||
while (letter = str.charAt(i += 1)) { | ||
if (letter === '\\') { | ||
i += 1; | ||
continue; | ||
} | ||
if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) { | ||
continue; | ||
} | ||
if (pi < i) { | ||
tokens.push(this.makeToken('NEOSTRING', str.slice(pi, i), strOffset + pi)); | ||
} | ||
if (!errorToken) { | ||
errorToken = this.makeToken('', 'string interpolation', offsetInChunk + i + 1, 2); | ||
} | ||
inner = expr.slice(1, -1); | ||
if (inner.length) { | ||
_ref2 = this.getLineAndColumnFromChunk(strOffset + i + 2), line = _ref2[0], column = _ref2[1]; | ||
nested = new Lexer().tokenize(inner, { | ||
line: line, | ||
column: column, | ||
rewrite: false | ||
}); | ||
popped = nested.pop(); | ||
if (((_ref3 = nested[0]) != null ? _ref3[0] : void 0) === 'TERMINATOR') { | ||
popped = nested.shift(); | ||
} | ||
if (len = nested.length) { | ||
if (len > 1) { | ||
nested.unshift(this.makeToken('(', '(', strOffset + i + 1, 0)); | ||
nested.push(this.makeToken(')', ')', strOffset + i + 1 + inner.length, 0)); | ||
} | ||
tokens.push(['TOKENS', nested]); | ||
} | ||
} | ||
i += expr.length; | ||
pi = i + 1; | ||
} | ||
if ((i > pi && pi < str.length)) { | ||
tokens.push(this.makeToken('NEOSTRING', str.slice(pi), strOffset + pi)); | ||
} | ||
if (regex) { | ||
return tokens; | ||
} | ||
if (!tokens.length) { | ||
return this.token('STRING', '""', offsetInChunk, lexedLength); | ||
} | ||
if (tokens[0][0] !== 'NEOSTRING') { | ||
tokens.unshift(this.makeToken('NEOSTRING', '', offsetInChunk)); | ||
} | ||
Lexer.prototype.mergeInterpolationTokens = function(tokens, _arg, fn) { | ||
var converted, end, errorToken, firstEmptyStringIndex, firstIndex, i, interpolated, locationToken, plusToken, quote, rparen, start, tag, token, tokensToPush, value, _i, _len, _ref2; | ||
quote = _arg.quote, start = _arg.start, end = _arg.end; | ||
if (interpolated = tokens.length > 1) { | ||
this.token('(', '(', offsetInChunk, 0, errorToken); | ||
errorToken = this.makeToken('', 'interpolation', start + tokens[0][1].length, 2); | ||
this.token('(', '(', 0, 0, errorToken); | ||
} | ||
firstIndex = this.tokens.length; | ||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { | ||
token = tokens[i]; | ||
tag = token[0], value = token[1]; | ||
if (i) { | ||
if (i) { | ||
plusToken = this.token('+', '+'); | ||
} | ||
locationToken = tag === 'TOKENS' ? value[0] : token; | ||
switch (tag) { | ||
case 'TOKENS': | ||
if (value.length === 2) { | ||
continue; | ||
} | ||
locationToken = value[0]; | ||
tokensToPush = value; | ||
break; | ||
case 'NEOSTRING': | ||
converted = fn(token[1], i); | ||
if (converted.length === 0) { | ||
if (i === 0) { | ||
firstEmptyStringIndex = this.tokens.length; | ||
} else { | ||
continue; | ||
} | ||
} | ||
if (i === 2 && (firstEmptyStringIndex != null)) { | ||
this.tokens.splice(firstEmptyStringIndex, 2); | ||
} | ||
token[0] = 'STRING'; | ||
token[1] = this.makeString(converted, quote); | ||
locationToken = token; | ||
tokensToPush = [token]; | ||
} | ||
if (this.tokens.length > firstIndex) { | ||
plusToken = this.token('+', '+'); | ||
plusToken[2] = { | ||
@@ -701,23 +671,13 @@ first_line: locationToken[2].first_line, | ||
} | ||
if (tag === 'TOKENS') { | ||
(_ref4 = this.tokens).push.apply(_ref4, value); | ||
} else if (tag === 'NEOSTRING') { | ||
token[0] = 'STRING'; | ||
token[1] = this.makeString(value, '"', heredoc); | ||
this.tokens.push(token); | ||
} else { | ||
this.error("Unexpected " + tag); | ||
} | ||
(_ref2 = this.tokens).push.apply(_ref2, tokensToPush); | ||
} | ||
if (interpolated) { | ||
rparen = this.makeToken(')', ')', offsetInChunk + lexedLength, 0); | ||
rparen.stringEnd = true; | ||
this.tokens.push(rparen); | ||
rparen = this.token(')', ')', end, 0); | ||
return rparen.stringEnd = true; | ||
} | ||
return tokens; | ||
}; | ||
Lexer.prototype.pair = function(tag) { | ||
var wanted; | ||
if (tag !== (wanted = last(this.ends))) { | ||
var wanted, _ref2; | ||
if (tag !== (wanted = (_ref2 = last(this.ends)) != null ? _ref2.tag : void 0)) { | ||
if ('OUTDENT' !== wanted) { | ||
@@ -791,11 +751,7 @@ this.error("unmatched " + tag); | ||
var _ref2; | ||
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === 'UNARY_MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === '**' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); | ||
return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === 'UNARY_MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'YIELD' || _ref2 === '**' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); | ||
}; | ||
Lexer.prototype.removeNewlines = function(str) { | ||
return str.replace(/^\s*\n\s*/, '').replace(/([^\\]|\\\\)\s*\n\s*$/, '$1'); | ||
}; | ||
Lexer.prototype.escapeLines = function(str, heredoc) { | ||
str = str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) { | ||
Lexer.prototype.formatString = function(str) { | ||
return str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) { | ||
if (character === '\n') { | ||
@@ -807,10 +763,10 @@ return ''; | ||
}); | ||
if (heredoc) { | ||
return str.replace(MULTILINER, '\\n'); | ||
} else { | ||
return str.replace(/\s*\n\s*/g, ' '); | ||
} | ||
}; | ||
Lexer.prototype.makeString = function(body, quote, heredoc) { | ||
Lexer.prototype.formatHeregex = function(str) { | ||
return str.replace(HEREGEX_OMIT, '$1$2').replace(MULTILINER, '\\n'); | ||
}; | ||
Lexer.prototype.makeString = function(body, quote) { | ||
var match; | ||
if (!body) { | ||
@@ -827,3 +783,6 @@ return quote + quote; | ||
body = body.replace(RegExp("" + quote, "g"), '\\$&'); | ||
return quote + this.escapeLines(body, heredoc) + quote; | ||
if (match = OCTAL_ESCAPE.exec(body)) { | ||
this.error("octal escape sequences are not allowed " + match[2], match.index + match[1].length + 1); | ||
} | ||
return quote + body + quote; | ||
}; | ||
@@ -847,3 +806,3 @@ | ||
JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; | ||
JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'yield', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; | ||
@@ -875,5 +834,5 @@ COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when']; | ||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield']; | ||
RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static']; | ||
STRICT_PROSCRIBED = ['arguments', 'eval']; | ||
STRICT_PROSCRIBED = ['arguments', 'eval', 'yield*']; | ||
@@ -888,8 +847,6 @@ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED); | ||
IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/; | ||
IDENTIFIER = /^(?!\d)((?:(?!\s)[$\w\x7f-\uffff])+)([^\n\S]*:(?!:))?/; | ||
NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; | ||
HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/; | ||
OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/; | ||
@@ -905,20 +862,44 @@ | ||
SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/; | ||
JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; | ||
REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/; | ||
STRING_START = /^(?:'''|"""|'|")/; | ||
HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/; | ||
STRING_SINGLE = /^(?:[^\\']|\\[\s\S])*/; | ||
STRING_DOUBLE = /^(?:[^\\"#]|\\[\s\S]|\#(?!\{))*/; | ||
HEREDOC_SINGLE = /^(?:[^\\']|\\[\s\S]|'(?!''))*/; | ||
HEREDOC_DOUBLE = /^(?:[^\\"#]|\\[\s\S]|"(?!"")|\#(?!\{))*/; | ||
STRING_OMIT = /\s*\n\s*/g; | ||
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g; | ||
REGEX = /^\/(?!\/)(?:[^[\/\n\\]|\\.|\[(?:\\.|[^\]\n\\])*])*(\/)?/; | ||
REGEX_FLAGS = /^\w*/; | ||
VALID_FLAGS = /^(?!.*(.).*\1)[imgy]*$/; | ||
HEREGEX = /^(?:[^\\\/#]|\\[\s\S]|\/(?!\/\/)|\#(?!\{))*/; | ||
HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g; | ||
REGEX_ILLEGAL = /^(\/|\/{3}\s*)(\*)/; | ||
POSSIBLY_DIVISION = /^\/=?\s/; | ||
MULTILINER = /\n/g; | ||
HEREDOC_INDENT = /\n+([^\n\S]*)/g; | ||
HERECOMMENT_ILLEGAL = /\*\//; | ||
HEREDOC_ILLEGAL = /\*\//; | ||
LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/; | ||
OCTAL_ESCAPE = /^((?:\\.|[^\\])*)(\\(?:0[0-7]|[1-7]))/; | ||
LEADING_BLANK_LINE = /^[^\n\S]*\n/; | ||
TRAILING_BLANK_LINE = /\n[^\n\S]*$/; | ||
TRAILING_SPACES = /\s+$/; | ||
@@ -944,10 +925,8 @@ | ||
NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--']; | ||
CALLABLE = ['IDENTIFIER', ')', ']', '?', '@', 'THIS', 'SUPER']; | ||
NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']'); | ||
INDEXABLE = CALLABLE.concat(['NUMBER', 'STRING', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '}', '::']); | ||
CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER']; | ||
NOT_REGEX = INDEXABLE.concat(['++', '--']); | ||
INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED'); | ||
LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR']; | ||
@@ -954,0 +933,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -8,4 +8,4 @@ var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat; | ||
exports.OptionParser = OptionParser = (function() { | ||
function OptionParser(rules, banner) { | ||
this.banner = banner; | ||
function OptionParser(rules, _at_banner) { | ||
this.banner = _at_banner; | ||
this.rules = buildRules(rules); | ||
@@ -66,3 +66,3 @@ } | ||
if (this.banner) { | ||
lines.unshift("" + this.banner + "\n"); | ||
lines.unshift(this.banner + "\n"); | ||
} | ||
@@ -69,0 +69,0 @@ _ref = this.rules; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -3,0 +3,0 @@ var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -22,3 +22,3 @@ var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref; | ||
"eval": function(input, context, filename, cb) { | ||
var Assign, Block, Literal, Value, ast, err, js, result, _ref1; | ||
var Assign, Block, Literal, Value, ast, err, js, referencedVars, result, token, tokens, _ref1; | ||
input = input.replace(/\uFF00/g, '\n'); | ||
@@ -28,7 +28,20 @@ input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); | ||
try { | ||
ast = CoffeeScript.nodes(input); | ||
tokens = CoffeeScript.tokens(input); | ||
referencedVars = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = tokens.length; _i < _len; _i++) { | ||
token = tokens[_i]; | ||
if (token.variable && token[1].charAt(0) === '_') { | ||
_results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
})(); | ||
ast = CoffeeScript.nodes(tokens); | ||
ast = new Block([new Assign(new Value(new Literal('_')), ast, '=')]); | ||
js = ast.compile({ | ||
bare: true, | ||
locals: Object.keys(context) | ||
locals: Object.keys(context), | ||
referencedVars: referencedVars | ||
}); | ||
@@ -63,3 +76,3 @@ result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename); | ||
if (multiline.enabled) { | ||
multiline.buffer += "" + cmd + "\n"; | ||
multiline.buffer += cmd + "\n"; | ||
rli.setPrompt(multiline.prompt); | ||
@@ -124,3 +137,3 @@ rli.prompt(true); | ||
if (code && code.length && code !== '.history' && lastLine !== code) { | ||
fs.write(fd, "" + code + "\n"); | ||
fs.write(fd, code + "\n"); | ||
return lastLine = code; | ||
@@ -135,3 +148,3 @@ } | ||
action: function() { | ||
repl.outputStream.write("" + (repl.rli.history.slice(0).reverse().join('\n')) + "\n"); | ||
repl.outputStream.write((repl.rli.history.slice(0).reverse().join('\n')) + "\n"); | ||
return repl.displayPrompt(); | ||
@@ -138,0 +151,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -20,4 +20,4 @@ var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, | ||
Rewriter.prototype.rewrite = function(tokens) { | ||
this.tokens = tokens; | ||
Rewriter.prototype.rewrite = function(_at_tokens) { | ||
this.tokens = _at_tokens; | ||
this.removeLeadingNewlines(); | ||
@@ -198,3 +198,3 @@ this.closeOpenCalls(); | ||
stack.pop(); | ||
tokens.splice(i, 0, generate('CALL_END', ')')); | ||
tokens.splice(i, 0, generate('CALL_END', ')', ['', 'end of input', token[2]])); | ||
return i += 1; | ||
@@ -262,3 +262,3 @@ }; | ||
} | ||
if ((__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced && !token.stringEnd || 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 && !token.stringEnd && !token.regexEnd || 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 (tag === '?') { | ||
@@ -270,3 +270,3 @@ tag = token[0] = 'FUNC_EXIST'; | ||
} | ||
if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { | ||
if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && !token.stringEnd && !token.regexEnd && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { | ||
startImplicitCall(i + 1); | ||
@@ -465,3 +465,3 @@ stack.push(['INDENT', i + 2]); | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'YIELD', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
@@ -468,0 +468,0 @@ IMPLICIT_UNSPACED_CALL = ['+', '-']; |
@@ -1,4 +0,5 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
var Scope, extend, last, _ref; | ||
var Scope, extend, last, _ref, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -8,8 +9,8 @@ _ref = require('./helpers'), extend = _ref.extend, last = _ref.last; | ||
exports.Scope = Scope = (function() { | ||
Scope.root = null; | ||
function Scope(parent, expressions, method) { | ||
this.parent = parent; | ||
this.expressions = expressions; | ||
this.method = method; | ||
function Scope(_at_parent, _at_expressions, _at_method, _at_referencedVars) { | ||
var _ref1, _ref2; | ||
this.parent = _at_parent; | ||
this.expressions = _at_expressions; | ||
this.method = _at_method; | ||
this.referencedVars = _at_referencedVars; | ||
this.variables = [ | ||
@@ -23,4 +24,5 @@ { | ||
if (!this.parent) { | ||
Scope.root = this; | ||
this.utilities = {}; | ||
} | ||
this.root = (_ref1 = (_ref2 = this.parent) != null ? _ref2.root : void 0) != null ? _ref1 : this; | ||
} | ||
@@ -96,3 +98,7 @@ | ||
index = 0; | ||
while (this.check((temp = this.temporary(name, index)))) { | ||
while (true) { | ||
temp = this.temporary(name, index); | ||
if (!(this.check(temp) || __indexOf.call(this.root.referencedVars, temp) >= 0)) { | ||
break; | ||
} | ||
index++; | ||
@@ -139,3 +145,3 @@ } | ||
if (v.type.assigned) { | ||
_results.push("" + v.name + " = " + v.type.value); | ||
_results.push(v.name + " = " + v.type.value); | ||
} | ||
@@ -142,0 +148,0 @@ } |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.8.0 | ||
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
@@ -6,4 +6,4 @@ var LineMap, SourceMap; | ||
LineMap = (function() { | ||
function LineMap(line) { | ||
this.line = line; | ||
function LineMap(_at_line) { | ||
this.line = _at_line; | ||
this.columns = []; | ||
@@ -10,0 +10,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
"author": "Jeremy Ashkenas", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"license": "MIT", | ||
@@ -27,3 +27,4 @@ "engines": { | ||
"scripts": { | ||
"test": "node ./bin/cake test" | ||
"test": "node ./bin/cake test", | ||
"test-harmony": "node --harmony ./bin/cake test" | ||
}, | ||
@@ -42,6 +43,3 @@ "homepage": "http://coffeescript.org", | ||
"docco": "~0.6.2" | ||
}, | ||
"dependencies": { | ||
"mkdirp": "~0.3.5" | ||
} | ||
} |
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
0
28
323882
7620
- Removedmkdirp@~0.3.5
- Removedmkdirp@0.3.5(transitive)