coffeescript
Advanced tools
Comparing version 1.9.0 to 1.9.1
{ | ||
"name": "coffee-script", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "lib/coffee-script/coffee-script.js" |
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var CoffeeScript, compile, runScripts, | ||
__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; }; | ||
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; }; | ||
@@ -37,3 +37,3 @@ CoffeeScript = require('./coffee-script'); | ||
compile = function(code, options) { | ||
var js, v3SourceMap, _ref; | ||
var js, ref, v3SourceMap; | ||
if (options == null) { | ||
@@ -44,3 +44,3 @@ options = {}; | ||
options.inline = true; | ||
_ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap; | ||
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"; | ||
@@ -65,5 +65,5 @@ }; | ||
xhr.onreadystatechange = function() { | ||
var param, _ref; | ||
var param, ref; | ||
if (xhr.readyState === 4) { | ||
if ((_ref = xhr.status) === 0 || _ref === 200) { | ||
if ((ref = xhr.status) === 0 || ref === 200) { | ||
param = [xhr.responseText, options]; | ||
@@ -85,15 +85,15 @@ if (!hold) { | ||
runScripts = function() { | ||
var coffees, coffeetypes, execute, i, index, s, script, scripts, _fn, _i, _len; | ||
var coffees, coffeetypes, execute, fn, i, index, j, len, s, script, scripts; | ||
scripts = window.document.getElementsByTagName('script'); | ||
coffeetypes = ['text/coffeescript', 'text/literate-coffeescript']; | ||
coffees = (function() { | ||
var _i, _len, _ref, _results; | ||
_results = []; | ||
for (_i = 0, _len = scripts.length; _i < _len; _i++) { | ||
s = scripts[_i]; | ||
if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) { | ||
_results.push(s); | ||
var j, len, ref, results; | ||
results = []; | ||
for (j = 0, len = scripts.length; j < len; j++) { | ||
s = scripts[j]; | ||
if (ref = s.type, indexOf.call(coffeetypes, ref) >= 0) { | ||
results.push(s); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -110,3 +110,3 @@ index = 0; | ||
}; | ||
_fn = function(script, i) { | ||
fn = function(script, i) { | ||
var options; | ||
@@ -126,5 +126,5 @@ options = { | ||
}; | ||
for (i = _i = 0, _len = coffees.length; _i < _len; i = ++_i) { | ||
for (i = j = 0, len = coffees.length; j < len; i = ++j) { | ||
script = coffees[i]; | ||
_fn(script, i); | ||
fn(script, i); | ||
} | ||
@@ -131,0 +131,0 @@ return execute(); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
@@ -27,5 +27,5 @@ var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks; | ||
task: function(name, description, action) { | ||
var _ref; | ||
var ref; | ||
if (!action) { | ||
_ref = [description, action], action = _ref[0], description = _ref[1]; | ||
ref = [description, action], action = ref[0], description = ref[1]; | ||
} | ||
@@ -50,3 +50,3 @@ return tasks[name] = { | ||
exports.run = function() { | ||
var arg, args, e, _i, _len, _ref, _results; | ||
var arg, args, e, i, len, ref, results; | ||
global.__originalDirname = fs.realpathSync('.'); | ||
@@ -68,9 +68,9 @@ process.chdir(cakefileDirectory(__originalDirname)); | ||
} | ||
_ref = options["arguments"]; | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
arg = _ref[_i]; | ||
_results.push(invoke(arg)); | ||
ref = options["arguments"]; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
arg = ref[i]; | ||
results.push(invoke(arg)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -77,0 +77,0 @@ |
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var Lexer, SourceMap, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, lexer, parser, path, sourceMaps, vm, withPrettyErrors, _base, _i, _len, _ref, | ||
__hasProp = {}.hasOwnProperty, | ||
__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; }; | ||
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors, | ||
hasProp = {}.hasOwnProperty, | ||
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; }; | ||
@@ -21,3 +21,3 @@ fs = require('fs'); | ||
exports.VERSION = '1.9.0'; | ||
exports.VERSION = '1.9.1'; | ||
@@ -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, token, tokens, _i, _len; | ||
var answer, currentColumn, currentLine, extend, fragment, fragments, header, i, js, len, map, merge, newLines, token, tokens; | ||
merge = helpers.merge, extend = helpers.extend; | ||
@@ -53,11 +53,11 @@ options = extend({}, 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]); | ||
var i, len, results; | ||
results = []; | ||
for (i = 0, len = tokens.length; i < len; i++) { | ||
token = tokens[i]; | ||
if (token.variable) { | ||
results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -74,4 +74,4 @@ fragments = parser.parse(tokens).compileToFragments(options); | ||
js = ""; | ||
for (_i = 0, _len = fragments.length; _i < _len; _i++) { | ||
fragment = fragments[_i]; | ||
for (i = 0, len = fragments.length; i < len; i++) { | ||
fragment = fragments[i]; | ||
if (options.sourceMap) { | ||
@@ -122,3 +122,3 @@ if (fragment.locationData) { | ||
exports.run = function(code, options) { | ||
var answer, dir, mainModule, _ref; | ||
var answer, dir, mainModule, ref; | ||
if (options == null) { | ||
@@ -134,3 +134,3 @@ options = {}; | ||
answer = compile(code, options); | ||
code = (_ref = answer.js) != null ? _ref : answer; | ||
code = (ref = answer.js) != null ? ref : answer; | ||
} | ||
@@ -141,3 +141,3 @@ return mainModule._compile(code, mainModule.filename); | ||
exports["eval"] = function(code, options) { | ||
var Module, createContext, isContext, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _ref2, _ref3, _require; | ||
var Module, _module, _require, createContext, i, isContext, js, k, len, o, r, ref, ref1, ref2, ref3, sandbox, v; | ||
if (options == null) { | ||
@@ -149,4 +149,4 @@ options = {}; | ||
} | ||
createContext = (_ref = vm.Script.createContext) != null ? _ref : vm.createContext; | ||
isContext = (_ref1 = vm.isContext) != null ? _ref1 : function(ctx) { | ||
createContext = (ref = vm.Script.createContext) != null ? ref : vm.createContext; | ||
isContext = (ref1 = vm.isContext) != null ? ref1 : function(ctx) { | ||
return options.sandbox instanceof createContext().constructor; | ||
@@ -160,6 +160,6 @@ }; | ||
sandbox = createContext(); | ||
_ref2 = options.sandbox; | ||
for (k in _ref2) { | ||
if (!__hasProp.call(_ref2, k)) continue; | ||
v = _ref2[k]; | ||
ref2 = options.sandbox; | ||
for (k in ref2) { | ||
if (!hasProp.call(ref2, k)) continue; | ||
v = ref2[k]; | ||
sandbox[k] = v; | ||
@@ -181,5 +181,5 @@ } | ||
_module.filename = sandbox.__filename; | ||
_ref3 = Object.getOwnPropertyNames(require); | ||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) { | ||
r = _ref3[_i]; | ||
ref3 = Object.getOwnPropertyNames(require); | ||
for (i = 0, len = ref3.length; i < len; i++) { | ||
r = ref3[i]; | ||
if (r !== 'paths') { | ||
@@ -197,3 +197,3 @@ _require[r] = require[r]; | ||
for (k in options) { | ||
if (!__hasProp.call(options, k)) continue; | ||
if (!hasProp.call(options, k)) continue; | ||
v = options[k]; | ||
@@ -216,7 +216,7 @@ o[k] = v; | ||
if (require.extensions) { | ||
_ref = this.FILE_EXTENSIONS; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
ext = _ref[_i]; | ||
if ((_base = require.extensions)[ext] == null) { | ||
_base[ext] = function() { | ||
ref = this.FILE_EXTENSIONS; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
ext = ref[i]; | ||
if ((base = require.extensions)[ext] == null) { | ||
base[ext] = function() { | ||
throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require " + ext + " files."); | ||
@@ -274,8 +274,19 @@ }; | ||
parser.yy.parseError = function(message, _arg) { | ||
parser.yy.parseError = function(message, arg) { | ||
var errorLoc, errorTag, errorText, errorToken, token, tokens; | ||
token = _arg.token; | ||
token = arg.token; | ||
errorToken = parser.errorToken, tokens = parser.tokens; | ||
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2]; | ||
errorText = errorToken === tokens[tokens.length - 1] ? 'end of input' : errorTag === 'INDENT' || errorTag === 'OUTDENT' ? 'indentation' : helpers.nameWhitespaceCharacter(errorText); | ||
errorText = (function() { | ||
switch (false) { | ||
case errorToken !== tokens[tokens.length - 1]: | ||
return 'end of input'; | ||
case errorTag !== 'INDENT' && errorTag !== 'OUTDENT': | ||
return 'indentation'; | ||
case errorTag !== 'IDENTIFIER' && errorTag !== 'NUMBER' && errorTag !== 'STRING' && errorTag !== 'STRING_START' && errorTag !== 'REGEX' && errorTag !== 'REGEX_START': | ||
return errorTag.replace(/_START$/, '').toLowerCase(); | ||
default: | ||
return helpers.nameWhitespaceCharacter(errorText); | ||
} | ||
})(); | ||
return helpers.throwSyntaxError("unexpected " + errorText, errorLoc); | ||
@@ -335,7 +346,7 @@ }; | ||
getSourceMap = function(filename) { | ||
var answer, _ref1; | ||
var answer, ref1; | ||
if (sourceMaps[filename]) { | ||
return sourceMaps[filename]; | ||
} | ||
if (_ref1 = path != null ? path.extname(filename) : void 0, __indexOf.call(exports.FILE_EXTENSIONS, _ref1) < 0) { | ||
if (ref1 = path != null ? path.extname(filename) : void 0, indexOf.call(exports.FILE_EXTENSIONS, ref1) < 0) { | ||
return; | ||
@@ -362,12 +373,12 @@ } | ||
frames = (function() { | ||
var _j, _len1, _results; | ||
_results = []; | ||
for (_j = 0, _len1 = stack.length; _j < _len1; _j++) { | ||
frame = stack[_j]; | ||
var j, len1, results; | ||
results = []; | ||
for (j = 0, len1 = stack.length; j < len1; j++) { | ||
frame = stack[j]; | ||
if (frame.getFunction() === exports.run) { | ||
break; | ||
} | ||
_results.push(" at " + (formatSourcePosition(frame, getSourceMapping))); | ||
results.push(" at " + (formatSourcePosition(frame, getSourceMapping))); | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -374,0 +385,0 @@ return (err.toString()) + "\n" + (frames.join('\n')) + "\n"; |
@@ -1,5 +0,5 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
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, | ||
__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; }; | ||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs, | ||
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; }; | ||
@@ -16,3 +16,3 @@ fs = require('fs'); | ||
_ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec; | ||
ref = require('child_process'), spawn = ref.spawn, exec = ref.exec; | ||
@@ -53,4 +53,6 @@ EventEmitter = require('events').EventEmitter; | ||
jsToSources = {}; | ||
exports.run = function() { | ||
var literals, replCliOpts, source, _i, _len, _ref1, _results; | ||
var i, len, literals, ref1, replCliOpts, results, source; | ||
parseOptions(); | ||
@@ -91,15 +93,15 @@ replCliOpts = { | ||
} | ||
_ref1 = opts["arguments"]; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
source = _ref1[_i]; | ||
ref1 = opts["arguments"]; | ||
results = []; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
source = ref1[i]; | ||
source = path.resolve(source); | ||
_results.push(compilePath(source, true, source)); | ||
results.push(compilePath(source, true, source)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
compilePath = function(source, topLevel, base) { | ||
var code, err, file, files, stats, _i, _len, _results; | ||
if (__indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) { | ||
var code, err, file, files, i, len, results, stats; | ||
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) { | ||
return; | ||
@@ -139,8 +141,8 @@ } | ||
} | ||
_results = []; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
_results.push(compilePath(path.join(source, file), false, base)); | ||
results = []; | ||
for (i = 0, len = files.length; i < len; i++) { | ||
file = files[i]; | ||
results.push(compilePath(path.join(source, file), false, base)); | ||
} | ||
return _results; | ||
return results; | ||
} else if (topLevel || helpers.isCoffee(source)) { | ||
@@ -170,6 +172,6 @@ sources.push(source); | ||
findDirectoryIndex = function(source) { | ||
var err, ext, index, _i, _len, _ref1; | ||
_ref1 = CoffeeScript.FILE_EXTENSIONS; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
ext = _ref1[_i]; | ||
var err, ext, i, index, len, ref1; | ||
ref1 = CoffeeScript.FILE_EXTENSIONS; | ||
for (i = 0, len = ref1.length; i < len; i++) { | ||
ext = ref1[i]; | ||
index = path.join(source, "index" + ext); | ||
@@ -287,3 +289,3 @@ try { | ||
} | ||
if (__indexOf.call(sources, source) < 0) { | ||
if (indexOf.call(sources, source) < 0) { | ||
return; | ||
@@ -355,3 +357,3 @@ } | ||
return readdirTimeout = wait(25, function() { | ||
var err, file, files, _i, _len, _results; | ||
var err, file, files, i, len, results; | ||
try { | ||
@@ -366,8 +368,8 @@ files = fs.readdirSync(source); | ||
} | ||
_results = []; | ||
for (_i = 0, _len = files.length; _i < _len; _i++) { | ||
file = files[_i]; | ||
_results.push(compilePath(path.join(source, file), false, base)); | ||
results = []; | ||
for (i = 0, len = files.length; i < len; i++) { | ||
file = files[i]; | ||
results.push(compilePath(path.join(source, file), false, base)); | ||
} | ||
return _results; | ||
return results; | ||
}); | ||
@@ -392,7 +394,7 @@ }); | ||
removeSourceDir = function(source, base) { | ||
var file, sourcesChanged, _i, _len; | ||
var file, i, len, sourcesChanged; | ||
delete watchedDirs[source]; | ||
sourcesChanged = false; | ||
for (_i = 0, _len = sources.length; _i < _len; _i++) { | ||
file = sources[_i]; | ||
for (i = 0, len = sources.length; i < len; i++) { | ||
file = sources[i]; | ||
if (!(source === path.dirname(file))) { | ||
@@ -422,3 +424,3 @@ continue; | ||
silentUnlink = function(path) { | ||
var err, _ref1; | ||
var err, ref1; | ||
try { | ||
@@ -428,3 +430,3 @@ return fs.unlinkSync(path); | ||
err = _error; | ||
if ((_ref1 = err.code) !== 'ENOENT' && _ref1 !== 'EPERM') { | ||
if ((ref1 = err.code) !== 'ENOENT' && ref1 !== 'EPERM') { | ||
throw err; | ||
@@ -480,2 +482,9 @@ } | ||
jsDir = path.dirname(jsPath); | ||
if (jsPath in jsToSources) { | ||
printLine("Error: The two following source files have the same output file:"); | ||
printLine(" " + jsToSources[jsPath]); | ||
printLine(" " + sourcePath); | ||
process.exit(1); | ||
} | ||
jsToSources[jsPath] = sourcePath; | ||
compile = function() { | ||
@@ -527,11 +536,11 @@ if (opts.compile) { | ||
strings = (function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = tokens.length; _i < _len; _i++) { | ||
token = tokens[_i]; | ||
var i, len, results; | ||
results = []; | ||
for (i = 0, len = tokens.length; i < len; i++) { | ||
token = tokens[i]; | ||
tag = token[0]; | ||
value = token[1].toString().replace(/\n/, '\\n'); | ||
_results.push("[" + tag + " " + value + "]"); | ||
results.push("[" + tag + " " + value + "]"); | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -538,0 +547,0 @@ return printLine(strings.join(' ')); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
@@ -66,13 +66,23 @@ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap; | ||
return new Literal($1); | ||
}), o('STRING', function() { | ||
}), o('String') | ||
], | ||
String: [ | ||
o('STRING', function() { | ||
return new Literal($1); | ||
}), o('STRING_START Body STRING_END', function() { | ||
return new Parens($2); | ||
}) | ||
], | ||
Regex: [ | ||
o('REGEX', function() { | ||
return new Literal($1); | ||
}), o('REGEX_START Invocation REGEX_END', function() { | ||
return $2; | ||
}) | ||
], | ||
Literal: [ | ||
o('AlphaNumeric'), o('JS', function() { | ||
return new Literal($1); | ||
}), o('REGEX', function() { | ||
}), o('Regex'), o('DEBUGGER', function() { | ||
return new Literal($1); | ||
}), o('DEBUGGER', function() { | ||
return new Literal($1); | ||
}), o('UNDEFINED', function() { | ||
@@ -616,9 +626,9 @@ return new Undefined; | ||
grammar[name] = (function() { | ||
var _i, _j, _len, _len1, _ref, _results; | ||
_results = []; | ||
for (_i = 0, _len = alternatives.length; _i < _len; _i++) { | ||
alt = alternatives[_i]; | ||
_ref = alt[0].split(' '); | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
token = _ref[_j]; | ||
var i, j, len, len1, ref, results; | ||
results = []; | ||
for (i = 0, len = alternatives.length; i < len; i++) { | ||
alt = alternatives[i]; | ||
ref = alt[0].split(' '); | ||
for (j = 0, len1 = ref.length; j < len1; j++) { | ||
token = ref[j]; | ||
if (!grammar[token]) { | ||
@@ -631,5 +641,5 @@ tokens.push(token); | ||
} | ||
_results.push(alt); | ||
results.push(alt); | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -636,0 +646,0 @@ } |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref; | ||
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString; | ||
@@ -29,11 +29,11 @@ exports.starts = function(string, literal, start) { | ||
exports.compact = function(array) { | ||
var item, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = array.length; _i < _len; _i++) { | ||
item = array[_i]; | ||
var i, item, len1, results; | ||
results = []; | ||
for (i = 0, len1 = array.length; i < len1; i++) { | ||
item = array[i]; | ||
if (item) { | ||
_results.push(item); | ||
results.push(item); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -67,6 +67,6 @@ | ||
exports.flatten = flatten = function(array) { | ||
var element, flattened, _i, _len; | ||
var element, flattened, i, len1; | ||
flattened = []; | ||
for (_i = 0, _len = array.length; _i < _len; _i++) { | ||
element = array[_i]; | ||
for (i = 0, len1 = array.length; i < len1; i++) { | ||
element = array[i]; | ||
if (element instanceof Array) { | ||
@@ -88,10 +88,6 @@ flattened = flattened.concat(flatten(element)); | ||
exports.last = last = function(array, back) { | ||
return array[array.length - (back || 0) - 1]; | ||
}; | ||
exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) { | ||
var e, _i, _len; | ||
for (_i = 0, _len = this.length; _i < _len; _i++) { | ||
e = this[_i]; | ||
exports.some = (ref = Array.prototype.some) != null ? ref : function(fn) { | ||
var e, i, len1; | ||
for (i = 0, len1 = this.length; i < len1; i++) { | ||
e = this[i]; | ||
if (fn(e)) { | ||
@@ -108,16 +104,16 @@ return true; | ||
lines = (function() { | ||
var _i, _len, _ref1, _results; | ||
_ref1 = code.split('\n'); | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
line = _ref1[_i]; | ||
var i, len1, ref1, results; | ||
ref1 = code.split('\n'); | ||
results = []; | ||
for (i = 0, len1 = ref1.length; i < len1; i++) { | ||
line = ref1[i]; | ||
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) { | ||
_results.push(line); | ||
results.push(line); | ||
} else if (maybe_code = /^\s*$/.test(line)) { | ||
_results.push(line); | ||
results.push(line); | ||
} else { | ||
_results.push('# ' + line); | ||
results.push('# ' + line); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -212,7 +208,7 @@ return lines.join('\n'); | ||
syntaxErrorToString = function() { | ||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2; | ||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start; | ||
if (!(this.code && this.location)) { | ||
return Error.prototype.toString.call(this); | ||
} | ||
_ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; | ||
ref1 = this.location, first_line = ref1.first_line, first_column = ref1.first_column, last_line = ref1.last_line, last_column = ref1.last_column; | ||
if (last_line == null) { | ||
@@ -232,3 +228,3 @@ last_line = first_line; | ||
} | ||
if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) { | ||
if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) { | ||
colorize = function(str) { | ||
@@ -235,0 +231,0 @@ return "\x1B[1;31m" + str + "\x1B[0m"; |
@@ -1,8 +0,8 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var key, val, _ref; | ||
var key, ref, val; | ||
_ref = require('./coffee-script'); | ||
for (key in _ref) { | ||
val = _ref[key]; | ||
ref = require('./coffee-script'); | ||
for (key in ref) { | ||
val = ref[key]; | ||
exports[key] = val; | ||
@@ -9,0 +9,0 @@ } |
@@ -1,9 +0,9 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(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, 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; }; | ||
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, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, 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, locationDataToString, ref, ref1, repeat, starts, throwSyntaxError, | ||
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; }; | ||
_ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES; | ||
ref = require('./rewriter'), Rewriter = ref.Rewriter, INVERSES = ref.INVERSES; | ||
_ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, repeat = _ref1.repeat, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError; | ||
ref1 = require('./helpers'), count = ref1.count, starts = ref1.starts, compact = ref1.compact, repeat = ref1.repeat, invertLiterate = ref1.invertLiterate, locationDataToString = ref1.locationDataToString, throwSyntaxError = ref1.throwSyntaxError; | ||
@@ -14,3 +14,3 @@ exports.Lexer = Lexer = (function() { | ||
Lexer.prototype.tokenize = function(code, opts) { | ||
var consumed, end, i, _ref2; | ||
var consumed, end, i, ref2; | ||
if (opts == null) { | ||
@@ -33,3 +33,3 @@ opts = {}; | ||
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]; | ||
ref2 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = ref2[0], this.chunkColumn = ref2[1]; | ||
i += consumed; | ||
@@ -45,3 +45,3 @@ if (opts.untilBalanced && this.ends.length === 0) { | ||
if (end = this.ends.pop()) { | ||
throwSyntaxError("missing " + end.tag, end.origin[2]); | ||
this.error("missing " + end.tag, end.origin[2]); | ||
} | ||
@@ -70,3 +70,3 @@ if (opts.rewrite === false) { | ||
Lexer.prototype.identifierToken = function() { | ||
var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, tag, tagToken, _ref2, _ref3, _ref4; | ||
var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, ref2, ref3, ref4, ref5, tag, tagToken; | ||
if (!(match = IDENTIFIER.exec(this.chunk))) { | ||
@@ -86,7 +86,8 @@ return 0; | ||
} | ||
forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::' || _ref2 === '?::') || !prev.spaced && prev[0] === '@'); | ||
ref2 = this.tokens, prev = ref2[ref2.length - 1]; | ||
forcedIdentifier = colon || (prev != null) && (((ref3 = prev[0]) === '.' || ref3 === '?.' || ref3 === '::' || ref3 === '?::') || !prev.spaced && prev[0] === '@'); | ||
tag = 'IDENTIFIER'; | ||
if (!forcedIdentifier && (__indexOf.call(JS_KEYWORDS, id) >= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) { | ||
if (!forcedIdentifier && (indexOf.call(JS_KEYWORDS, id) >= 0 || indexOf.call(COFFEE_KEYWORDS, id) >= 0)) { | ||
tag = id.toUpperCase(); | ||
if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) { | ||
if (tag === 'WHEN' && (ref4 = this.tag(), indexOf.call(LINE_BREAK, ref4) >= 0)) { | ||
tag = 'LEADING_WHEN'; | ||
@@ -97,5 +98,5 @@ } else if (tag === 'FOR') { | ||
tag = 'IF'; | ||
} else if (__indexOf.call(UNARY, tag) >= 0) { | ||
} else if (indexOf.call(UNARY, tag) >= 0) { | ||
tag = 'UNARY'; | ||
} else if (__indexOf.call(RELATION, tag) >= 0) { | ||
} else if (indexOf.call(RELATION, tag) >= 0) { | ||
if (tag !== 'INSTANCEOF' && this.seenFor) { | ||
@@ -113,3 +114,3 @@ tag = 'FOR' + tag; | ||
} | ||
if (__indexOf.call(JS_FORBIDDEN, id) >= 0) { | ||
if (indexOf.call(JS_FORBIDDEN, id) >= 0) { | ||
if (forcedIdentifier) { | ||
@@ -119,8 +120,10 @@ tag = 'IDENTIFIER'; | ||
id.reserved = true; | ||
} else if (__indexOf.call(RESERVED, id) >= 0) { | ||
this.error("reserved word \"" + id + "\""); | ||
} else if (indexOf.call(RESERVED, id) >= 0) { | ||
this.error("reserved word '" + id + "'", { | ||
length: id.length | ||
}); | ||
} | ||
} | ||
if (!forcedIdentifier) { | ||
if (__indexOf.call(COFFEE_ALIASES, id) >= 0) { | ||
if (indexOf.call(COFFEE_ALIASES, id) >= 0) { | ||
id = COFFEE_ALIAS_MAP[id]; | ||
@@ -152,3 +155,3 @@ } | ||
if (poppedToken) { | ||
_ref4 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = _ref4[0], tagToken[2].first_column = _ref4[1]; | ||
ref5 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = ref5[0], tagToken[2].first_column = ref5[1]; | ||
} | ||
@@ -168,12 +171,20 @@ if (colon) { | ||
number = match[0]; | ||
lexedLength = number.length; | ||
if (/^0[BOX]/.test(number)) { | ||
this.error("radix prefix '" + number + "' must be lowercase"); | ||
this.error("radix prefix in '" + number + "' must be lowercase", { | ||
offset: 1 | ||
}); | ||
} else if (/E/.test(number) && !/^0x/.test(number)) { | ||
this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'"); | ||
this.error("exponential notation in '" + number + "' must be indicated with a lowercase 'e'", { | ||
offset: number.indexOf('E') | ||
}); | ||
} else if (/^0\d*[89]/.test(number)) { | ||
this.error("decimal literal '" + number + "' must not be prefixed with '0'"); | ||
this.error("decimal literal '" + number + "' must not be prefixed with '0'", { | ||
length: lexedLength | ||
}); | ||
} else if (/^0\d+/.test(number)) { | ||
this.error("octal literal '" + number + "' must be prefixed with '0o'"); | ||
this.error("octal literal '" + number + "' must be prefixed with '0o'", { | ||
length: lexedLength | ||
}); | ||
} | ||
lexedLength = number.length; | ||
if (octalLiteral = /^0o([0-7]+)/.exec(number)) { | ||
@@ -190,3 +201,3 @@ number = '0x' + parseInt(octalLiteral[1], 8).toString(16); | ||
Lexer.prototype.stringToken = function() { | ||
var $, attempt, doc, end, heredoc, i, indent, indentRegex, match, quote, regex, start, token, tokens, _ref2, _ref3; | ||
var $, attempt, delimiter, doc, end, heredoc, i, indent, indentRegex, match, quote, ref2, ref3, regex, token, tokens; | ||
quote = (STRING_START.exec(this.chunk) || [])[0]; | ||
@@ -209,21 +220,21 @@ if (!quote) { | ||
heredoc = quote.length === 3; | ||
start = quote.length; | ||
_ref2 = this.matchWithInterpolations(this.chunk.slice(start), regex, quote, start), tokens = _ref2.tokens, end = _ref2.index; | ||
ref2 = this.matchWithInterpolations(regex, quote), tokens = ref2.tokens, end = ref2.index; | ||
$ = tokens.length - 1; | ||
delimiter = quote[0]; | ||
if (heredoc) { | ||
indent = null; | ||
doc = ((function() { | ||
var _i, _len, _results; | ||
_results = []; | ||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { | ||
var j, len, results; | ||
results = []; | ||
for (i = j = 0, len = tokens.length; j < len; i = ++j) { | ||
token = tokens[i]; | ||
if (token[0] === 'NEOSTRING') { | ||
_results.push(token[1]); | ||
results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
})()).join('#{}'); | ||
while (match = HEREDOC_INDENT.exec(doc)) { | ||
attempt = match[1]; | ||
if (indent === null || (0 < (_ref3 = attempt.length) && _ref3 < indent.length)) { | ||
if (indent === null || (0 < (ref3 = attempt.length) && ref3 < indent.length)) { | ||
indent = attempt; | ||
@@ -236,5 +247,3 @@ } | ||
this.mergeInterpolationTokens(tokens, { | ||
quote: quote[0], | ||
start: start, | ||
end: end | ||
delimiter: delimiter | ||
}, (function(_this) { | ||
@@ -249,4 +258,5 @@ return function(value, i) { | ||
} | ||
value = value.replace(indentRegex, ''); | ||
value = value.replace(MULTILINER, '\\n'); | ||
if (indentRegex) { | ||
value = value.replace(indentRegex, ''); | ||
} | ||
return value; | ||
@@ -257,9 +267,7 @@ }; | ||
this.mergeInterpolationTokens(tokens, { | ||
quote: quote, | ||
start: start, | ||
end: end | ||
delimiter: delimiter | ||
}, (function(_this) { | ||
return function(value, i) { | ||
value = _this.formatString(value); | ||
value = value.replace(STRING_OMIT, function(match, offset) { | ||
value = value.replace(SIMPLE_STRING_OMIT, function(match, offset) { | ||
if ((i === 0 && offset === 0) || (i === $ && offset + match.length === value.length)) { | ||
@@ -286,3 +294,6 @@ return ''; | ||
if (match = HERECOMMENT_ILLEGAL.exec(comment)) { | ||
this.error("block comments cannot contain " + match[0], match.index); | ||
this.error("block comments cannot contain " + match[0], { | ||
offset: match.index, | ||
length: match[0].length | ||
}); | ||
} | ||
@@ -307,20 +318,26 @@ if (here.indexOf('\n') >= 0) { | ||
Lexer.prototype.regexToken = function() { | ||
var closed, end, flags, index, match, prev, re, regex, rparen, tokens, _ref2, _ref3, _ref4; | ||
var body, closed, end, flags, index, match, origin, prev, ref2, ref3, ref4, regex, tokens; | ||
switch (false) { | ||
case !(match = REGEX_ILLEGAL.exec(this.chunk)): | ||
this.error("regular expressions cannot begin with " + match[2], match.index + match[1].length); | ||
this.error("regular expressions cannot begin with " + match[2], { | ||
offset: 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; | ||
case !(match = this.matchWithInterpolations(HEREGEX, '///')): | ||
tokens = match.tokens, index = match.index; | ||
break; | ||
case !(match = REGEX.exec(this.chunk)): | ||
regex = match[0], closed = match[1]; | ||
regex = match[0], body = match[1], closed = match[2]; | ||
this.validateEscapes(body, { | ||
isRegex: true, | ||
offsetInChunk: 1 | ||
}); | ||
index = regex.length; | ||
prev = last(this.tokens); | ||
ref2 = this.tokens, prev = ref2[ref2.length - 1]; | ||
if (prev) { | ||
if (prev.spaced && (_ref3 = prev[0], __indexOf.call(CALLABLE, _ref3) >= 0) && !prev.stringEnd && !prev.regexEnd) { | ||
if (prev.spaced && (ref3 = prev[0], indexOf.call(CALLABLE, ref3) >= 0)) { | ||
if (!closed || POSSIBLY_DIVISION.test(regex)) { | ||
return 0; | ||
} | ||
} else if (_ref4 = prev[0], __indexOf.call(NOT_REGEX, _ref4) >= 0) { | ||
} else if (ref4 = prev[0], indexOf.call(NOT_REGEX, ref4) >= 0) { | ||
return 0; | ||
@@ -338,25 +355,26 @@ } | ||
end = index + flags.length; | ||
origin = this.makeToken('REGEX', null, 0, end); | ||
switch (false) { | ||
case !!VALID_FLAGS.test(flags): | ||
this.error("invalid regular expression flags " + flags, index); | ||
this.error("invalid regular expression flags " + flags, { | ||
offset: index, | ||
length: flags.length | ||
}); | ||
break; | ||
case !regex: | ||
this.token('REGEX', "" + regex + flags); | ||
case !(regex || tokens.length === 1): | ||
if (body == null) { | ||
body = this.formatHeregex(tokens[0][1]); | ||
} | ||
this.token('REGEX', "" + (this.makeDelimitedLiteral(body, { | ||
delimiter: '/' | ||
})) + flags, 0, end, origin); | ||
break; | ||
case tokens.length !== 1: | ||
re = this.formatHeregex(tokens[0][1]).replace(/\//g, '\\/'); | ||
this.token('REGEX', "/" + (re || '(?:)') + "/" + flags); | ||
break; | ||
default: | ||
this.token('REGEX_START', '(', 0, 0, origin); | ||
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)); | ||
delimiter: '"', | ||
double: true | ||
}, this.formatHeregex); | ||
if (flags) { | ||
@@ -366,4 +384,4 @@ this.token(',', ',', index, 0); | ||
} | ||
rparen = this.token(')', ')', end, 0); | ||
rparen.regexEnd = true; | ||
this.token(')', ')', end, 0); | ||
this.token('REGEX_END', ')', end, 0); | ||
} | ||
@@ -409,3 +427,5 @@ return end; | ||
} else if (size < this.baseIndent) { | ||
this.error('missing indentation', indent.length); | ||
this.error('missing indentation', { | ||
offset: indent.length | ||
}); | ||
} else { | ||
@@ -419,3 +439,3 @@ this.indebt = 0; | ||
Lexer.prototype.outdentToken = function(moveOut, noNewlines, outdentLength) { | ||
var decreasedIndent, dent, lastIndent, _ref2; | ||
var decreasedIndent, dent, lastIndent, ref2; | ||
decreasedIndent = this.indent - moveOut; | ||
@@ -434,3 +454,3 @@ while (moveOut > 0) { | ||
dent = this.indents.pop() + this.outdebt; | ||
if (outdentLength && (_ref2 = this.chunk[outdentLength], __indexOf.call(INDENTABLE_CLOSERS, _ref2) >= 0)) { | ||
if (outdentLength && (ref2 = this.chunk[outdentLength], indexOf.call(INDENTABLE_CLOSERS, ref2) >= 0)) { | ||
decreasedIndent -= dent - moveOut; | ||
@@ -459,7 +479,7 @@ moveOut = dent; | ||
Lexer.prototype.whitespaceToken = function() { | ||
var match, nline, prev; | ||
var match, nline, prev, ref2; | ||
if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) { | ||
return 0; | ||
} | ||
prev = last(this.tokens); | ||
ref2 = this.tokens, prev = ref2[ref2.length - 1]; | ||
if (prev) { | ||
@@ -493,3 +513,3 @@ prev[match ? 'spaced' : 'newLine'] = true; | ||
Lexer.prototype.literalToken = function() { | ||
var match, prev, tag, token, value, _ref2, _ref3, _ref4, _ref5; | ||
var match, prev, ref2, ref3, ref4, ref5, ref6, tag, token, value; | ||
if (match = OPERATOR.exec(this.chunk)) { | ||
@@ -504,8 +524,8 @@ value = match[0]; | ||
tag = value; | ||
prev = last(this.tokens); | ||
ref2 = this.tokens, prev = ref2[ref2.length - 1]; | ||
if (value === '=' && prev) { | ||
if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) { | ||
this.error("reserved word \"" + (this.value()) + "\" can't be assigned"); | ||
if (!prev[1].reserved && (ref3 = prev[1], indexOf.call(JS_FORBIDDEN, ref3) >= 0)) { | ||
this.error("reserved word '" + prev[1] + "' can't be assigned", prev[2]); | ||
} | ||
if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') { | ||
if ((ref4 = prev[1]) === '||' || ref4 === '&&') { | ||
prev[0] = 'COMPOUND_ASSIGN'; | ||
@@ -519,18 +539,18 @@ prev[1] += '='; | ||
tag = 'TERMINATOR'; | ||
} else if (__indexOf.call(MATH, value) >= 0) { | ||
} else if (indexOf.call(MATH, value) >= 0) { | ||
tag = 'MATH'; | ||
} else if (__indexOf.call(COMPARE, value) >= 0) { | ||
} else if (indexOf.call(COMPARE, value) >= 0) { | ||
tag = 'COMPARE'; | ||
} else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) { | ||
} else if (indexOf.call(COMPOUND_ASSIGN, value) >= 0) { | ||
tag = 'COMPOUND_ASSIGN'; | ||
} else if (__indexOf.call(UNARY, value) >= 0) { | ||
} else if (indexOf.call(UNARY, value) >= 0) { | ||
tag = 'UNARY'; | ||
} else if (__indexOf.call(UNARY_MATH, value) >= 0) { | ||
} else if (indexOf.call(UNARY_MATH, value) >= 0) { | ||
tag = 'UNARY_MATH'; | ||
} else if (__indexOf.call(SHIFT, value) >= 0) { | ||
} else if (indexOf.call(SHIFT, value) >= 0) { | ||
tag = 'SHIFT'; | ||
} else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) { | ||
} else if (indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) { | ||
tag = 'LOGIC'; | ||
} else if (prev && !prev.spaced) { | ||
if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0) && !prev.stringEnd && !prev.regexEnd) { | ||
if (value === '(' && (ref5 = prev[0], indexOf.call(CALLABLE, ref5) >= 0)) { | ||
if (prev[0] === '?') { | ||
@@ -540,3 +560,3 @@ prev[0] = 'FUNC_EXIST'; | ||
tag = 'CALL_START'; | ||
} else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) { | ||
} else if (value === '[' && (ref6 = prev[0], indexOf.call(INDEXABLE, ref6) >= 0)) { | ||
tag = 'INDEX_START'; | ||
@@ -601,7 +621,16 @@ switch (prev[0]) { | ||
Lexer.prototype.matchWithInterpolations = function(str, regex, end, offsetInChunk) { | ||
var close, column, index, line, nested, open, strPart, tokens, _ref2, _ref3, _ref4; | ||
Lexer.prototype.matchWithInterpolations = function(regex, delimiter) { | ||
var close, column, firstToken, index, lastToken, line, nested, offsetInChunk, open, ref2, ref3, ref4, str, strPart, tokens; | ||
tokens = []; | ||
offsetInChunk = delimiter.length; | ||
if (this.chunk.slice(0, offsetInChunk) !== delimiter) { | ||
return null; | ||
} | ||
str = this.chunk.slice(offsetInChunk); | ||
while (true) { | ||
strPart = regex.exec(str)[0]; | ||
this.validateEscapes(strPart, { | ||
isRegex: delimiter.charAt(0) === '/', | ||
offsetInChunk: offsetInChunk | ||
}); | ||
tokens.push(this.makeToken('NEOSTRING', strPart, offsetInChunk)); | ||
@@ -613,8 +642,8 @@ str = str.slice(strPart.length); | ||
} | ||
_ref2 = this.getLineAndColumnFromChunk(offsetInChunk + 1), line = _ref2[0], column = _ref2[1]; | ||
_ref3 = new Lexer().tokenize(str.slice(1), { | ||
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; | ||
}), nested = ref3.tokens, index = ref3.index; | ||
index += 1; | ||
@@ -625,3 +654,3 @@ open = nested[0], close = nested[nested.length - 1]; | ||
close.origin = ['', 'end of interpolation', close[2]]; | ||
if (((_ref4 = nested[1]) != null ? _ref4[0] : void 0) === 'TERMINATOR') { | ||
if (((ref4 = nested[1]) != null ? ref4[0] : void 0) === 'TERMINATOR') { | ||
nested.splice(1, 1); | ||
@@ -633,20 +662,26 @@ } | ||
} | ||
if (str.slice(0, end.length) !== end) { | ||
this.error("missing " + end); | ||
if (str.slice(0, delimiter.length) !== delimiter) { | ||
this.error("missing " + delimiter, { | ||
length: delimiter.length | ||
}); | ||
} | ||
firstToken = tokens[0], lastToken = tokens[tokens.length - 1]; | ||
firstToken[2].first_column -= delimiter.length; | ||
lastToken[2].last_column += delimiter.length; | ||
if (lastToken[1].length === 0) { | ||
lastToken[2].last_column -= 1; | ||
} | ||
return { | ||
tokens: tokens, | ||
index: offsetInChunk + end.length | ||
index: offsetInChunk + delimiter.length | ||
}; | ||
}; | ||
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) { | ||
errorToken = this.makeToken('', 'interpolation', start + tokens[0][1].length, 2); | ||
this.token('(', '(', 0, 0, errorToken); | ||
Lexer.prototype.mergeInterpolationTokens = function(tokens, options, fn) { | ||
var converted, firstEmptyStringIndex, firstIndex, i, j, lastToken, len, locationToken, lparen, plusToken, ref2, rparen, tag, token, tokensToPush, value; | ||
if (tokens.length > 1) { | ||
lparen = this.token('STRING_START', '(', 0, 0); | ||
} | ||
firstIndex = this.tokens.length; | ||
for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { | ||
for (i = j = 0, len = tokens.length; j < len; i = ++j) { | ||
token = tokens[i]; | ||
@@ -675,3 +710,3 @@ tag = token[0], value = token[1]; | ||
token[0] = 'STRING'; | ||
token[1] = this.makeString(converted, quote); | ||
token[1] = this.makeDelimitedLiteral(converted, options); | ||
locationToken = token; | ||
@@ -689,7 +724,21 @@ tokensToPush = [token]; | ||
} | ||
(_ref2 = this.tokens).push.apply(_ref2, tokensToPush); | ||
(ref2 = this.tokens).push.apply(ref2, tokensToPush); | ||
} | ||
if (interpolated) { | ||
rparen = this.token(')', ')', end, 0); | ||
return rparen.stringEnd = true; | ||
if (lparen) { | ||
lastToken = tokens[tokens.length - 1]; | ||
lparen.origin = [ | ||
'STRING', null, { | ||
first_line: lparen[2].first_line, | ||
first_column: lparen[2].first_column, | ||
last_line: lastToken[2].last_line, | ||
last_column: lastToken[2].last_column | ||
} | ||
]; | ||
rparen = this.token('STRING_END', ')'); | ||
return rparen[2] = { | ||
first_line: lastToken[2].last_line, | ||
first_column: lastToken[2].last_column, | ||
last_line: lastToken[2].last_line, | ||
last_column: lastToken[2].last_column | ||
}; | ||
} | ||
@@ -699,8 +748,10 @@ }; | ||
Lexer.prototype.pair = function(tag) { | ||
var wanted, _ref2; | ||
if (tag !== (wanted = (_ref2 = last(this.ends)) != null ? _ref2.tag : void 0)) { | ||
var lastIndent, prev, ref2, ref3, wanted; | ||
ref2 = this.ends, prev = ref2[ref2.length - 1]; | ||
if (tag !== (wanted = prev != null ? prev.tag : void 0)) { | ||
if ('OUTDENT' !== wanted) { | ||
this.error("unmatched " + tag); | ||
} | ||
this.outdentToken(last(this.indents), true); | ||
ref3 = this.indents, lastIndent = ref3[ref3.length - 1]; | ||
this.outdentToken(lastIndent, true); | ||
return this.pair(tag); | ||
@@ -712,3 +763,3 @@ } | ||
Lexer.prototype.getLineAndColumnFromChunk = function(offset) { | ||
var column, lineCount, lines, string; | ||
var column, lastLine, lineCount, ref2, string; | ||
if (offset === 0) { | ||
@@ -725,4 +776,4 @@ return [this.chunkLine, this.chunkColumn]; | ||
if (lineCount > 0) { | ||
lines = string.split('\n'); | ||
column = last(lines).length; | ||
ref2 = string.split('\n'), lastLine = ref2[ref2.length - 1]; | ||
column = lastLine.length; | ||
} else { | ||
@@ -735,3 +786,3 @@ column += string.length; | ||
Lexer.prototype.makeToken = function(tag, value, offsetInChunk, length) { | ||
var lastCharacter, locationData, token, _ref2, _ref3; | ||
var lastCharacter, locationData, ref2, ref3, token; | ||
if (offsetInChunk == null) { | ||
@@ -744,5 +795,5 @@ offsetInChunk = 0; | ||
locationData = {}; | ||
_ref2 = this.getLineAndColumnFromChunk(offsetInChunk), locationData.first_line = _ref2[0], locationData.first_column = _ref2[1]; | ||
ref2 = this.getLineAndColumnFromChunk(offsetInChunk), locationData.first_line = ref2[0], locationData.first_column = ref2[1]; | ||
lastCharacter = Math.max(0, length - 1); | ||
_ref3 = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1]; | ||
ref3 = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter), locationData.last_line = ref3[0], locationData.last_column = ref3[1]; | ||
token = [tag, value, locationData]; | ||
@@ -762,60 +813,99 @@ return token; | ||
Lexer.prototype.tag = function(index, tag) { | ||
var tok; | ||
return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]); | ||
Lexer.prototype.tag = function() { | ||
var ref2, token; | ||
ref2 = this.tokens, token = ref2[ref2.length - 1]; | ||
return token != null ? token[0] : void 0; | ||
}; | ||
Lexer.prototype.value = function(index, val) { | ||
var tok; | ||
return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]); | ||
Lexer.prototype.value = function() { | ||
var ref2, token; | ||
ref2 = this.tokens, token = ref2[ref2.length - 1]; | ||
return token != null ? token[1] : void 0; | ||
}; | ||
Lexer.prototype.unfinished = function() { | ||
var _ref2; | ||
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'); | ||
var ref2; | ||
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.formatString = function(str) { | ||
return str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) { | ||
if (character === '\n') { | ||
return ''; | ||
} else { | ||
return escaped; | ||
} | ||
}); | ||
return str.replace(STRING_OMIT, '$1'); | ||
}; | ||
Lexer.prototype.formatHeregex = function(str) { | ||
return str.replace(HEREGEX_OMIT, '$1$2').replace(MULTILINER, '\\n'); | ||
return str.replace(HEREGEX_OMIT, '$1$2'); | ||
}; | ||
Lexer.prototype.makeString = function(body, quote) { | ||
var match; | ||
if (!body) { | ||
return quote + quote; | ||
Lexer.prototype.validateEscapes = function(str, options) { | ||
var before, hex, invalidEscape, match, message, octal, ref2, unicode; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
body = body.replace(RegExp("\\\\(" + quote + "|\\\\)", "g"), function(match, contents) { | ||
if (contents === quote) { | ||
return contents; | ||
} else { | ||
return match; | ||
match = INVALID_ESCAPE.exec(str); | ||
if (!match) { | ||
return; | ||
} | ||
match[0], before = match[1], octal = match[2], hex = match[3], unicode = match[4]; | ||
if (options.isRegex && octal && octal.charAt(0) !== '0') { | ||
return; | ||
} | ||
message = octal ? "octal escape sequences are not allowed" : "invalid escape sequence"; | ||
invalidEscape = "\\" + (octal || hex || unicode); | ||
return this.error(message + " " + invalidEscape, { | ||
offset: ((ref2 = options.offsetInChunk) != null ? ref2 : 0) + match.index + before.length, | ||
length: invalidEscape.length | ||
}); | ||
}; | ||
Lexer.prototype.makeDelimitedLiteral = function(body, options) { | ||
var regex; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (body === '' && options.delimiter === '/') { | ||
body = '(?:)'; | ||
} | ||
regex = RegExp("(\\\\\\\\)|(\\\\0(?=[1-7]))|\\\\?(" + options.delimiter + ")|\\\\?(?:(\\n)|(\\r)|(\\u2028)|(\\u2029))|(\\\\.)", "g"); | ||
body = body.replace(regex, function(match, backslash, nul, delimiter, lf, cr, ls, ps, other) { | ||
switch (false) { | ||
case !backslash: | ||
if (options.double) { | ||
return backslash + backslash; | ||
} else { | ||
return backslash; | ||
} | ||
case !nul: | ||
return '\\x00'; | ||
case !delimiter: | ||
return "\\" + delimiter; | ||
case !lf: | ||
return '\\n'; | ||
case !cr: | ||
return '\\r'; | ||
case !ls: | ||
return '\\u2028'; | ||
case !ps: | ||
return '\\u2029'; | ||
case !other: | ||
if (options.double) { | ||
return "\\" + other; | ||
} else { | ||
return other; | ||
} | ||
} | ||
}); | ||
body = body.replace(RegExp("" + quote, "g"), '\\$&'); | ||
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; | ||
return "" + options.delimiter + body + options.delimiter; | ||
}; | ||
Lexer.prototype.error = function(message, offset) { | ||
var first_column, first_line, _ref2; | ||
if (offset == null) { | ||
offset = 0; | ||
Lexer.prototype.error = function(message, options) { | ||
var first_column, first_line, location, ref2, ref3, ref4; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
_ref2 = this.getLineAndColumnFromChunk(offset), first_line = _ref2[0], first_column = _ref2[1]; | ||
return throwSyntaxError(message, { | ||
location = 'first_line' in options ? options : ((ref3 = this.getLineAndColumnFromChunk((ref2 = options.offset) != null ? ref2 : 0), first_line = ref3[0], first_column = ref3[1], ref3), { | ||
first_line: first_line, | ||
first_column: first_column | ||
first_column: first_column, | ||
last_column: first_column + ((ref4 = options.length) != null ? ref4 : 1) - 1 | ||
}); | ||
return throwSyntaxError(message, location); | ||
}; | ||
@@ -844,8 +934,8 @@ | ||
COFFEE_ALIASES = (function() { | ||
var _results; | ||
_results = []; | ||
var results; | ||
results = []; | ||
for (key in COFFEE_ALIAS_MAP) { | ||
_results.push(key); | ||
results.push(key); | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -893,7 +983,9 @@ | ||
STRING_OMIT = /\s*\n\s*/g; | ||
STRING_OMIT = /((?:\\\\)+)|\\[^\S\n]*\n\s*/g; | ||
SIMPLE_STRING_OMIT = /\s*\n\s*/g; | ||
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g; | ||
REGEX = /^\/(?!\/)(?:[^[\/\n\\]|\\.|\[(?:\\.|[^\]\n\\])*])*(\/)?/; | ||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*])*)(\/)?/; | ||
@@ -906,3 +998,3 @@ REGEX_FLAGS = /^\w*/; | ||
HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g; | ||
HEREGEX_OMIT = /((?:\\\\)+)|\\(\s)|\s+(?:#.*)?/g; | ||
@@ -913,4 +1005,2 @@ REGEX_ILLEGAL = /^(\/|\/{3}\s*)(\*)/; | ||
MULTILINER = /\n/g; | ||
HERECOMMENT_ILLEGAL = /\*\//; | ||
@@ -920,3 +1010,3 @@ | ||
OCTAL_ESCAPE = /^((?:\\.|[^\\])*)(\\(?:0[0-7]|[1-7]))/; | ||
INVALID_ESCAPE = /((?:^|[^\\])(?:\\\\)*)\\(?:(0[0-7]|[1-7])|(x(?![\da-fA-F]{2}).{0,2})|(u(?![\da-fA-F]{4}).{0,4}))/; | ||
@@ -949,3 +1039,3 @@ LEADING_BLANK_LINE = /^[^\n\S]*\n/; | ||
INDEXABLE = CALLABLE.concat(['NUMBER', 'STRING', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '}', '::']); | ||
INDEXABLE = CALLABLE.concat(['NUMBER', 'STRING', 'STRING_END', 'REGEX', 'REGEX_END', 'BOOL', 'NULL', 'UNDEFINED', '}', '::']); | ||
@@ -952,0 +1042,0 @@ NOT_REGEX = INDEXABLE.concat(['++', '--']); |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(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, _at_banner) { | ||
this.banner = _at_banner; | ||
function OptionParser(rules, banner) { | ||
this.banner = banner; | ||
this.rules = buildRules(rules); | ||
@@ -15,3 +15,3 @@ } | ||
OptionParser.prototype.parse = function(args) { | ||
var arg, i, isOption, matchedRule, options, originalArgs, pos, rule, seenNonOptionArg, skippingArgument, value, _i, _j, _len, _len1, _ref; | ||
var arg, i, isOption, j, k, len, len1, matchedRule, options, originalArgs, pos, ref, rule, seenNonOptionArg, skippingArgument, value; | ||
options = { | ||
@@ -23,3 +23,3 @@ "arguments": [] | ||
args = normalizeArguments(args); | ||
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { | ||
for (i = j = 0, len = args.length; j < len; i = ++j) { | ||
arg = args[i]; | ||
@@ -39,5 +39,5 @@ if (skippingArgument) { | ||
matchedRule = false; | ||
_ref = this.rules; | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
rule = _ref[_j]; | ||
ref = this.rules; | ||
for (k = 0, len1 = ref.length; k < len1; k++) { | ||
rule = ref[k]; | ||
if (rule.shortFlag === arg || rule.longFlag === arg) { | ||
@@ -66,3 +66,3 @@ value = true; | ||
OptionParser.prototype.help = function() { | ||
var letPart, lines, rule, spaces, _i, _len, _ref; | ||
var j, len, letPart, lines, ref, rule, spaces; | ||
lines = []; | ||
@@ -72,5 +72,5 @@ if (this.banner) { | ||
} | ||
_ref = this.rules; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
rule = _ref[_i]; | ||
ref = this.rules; | ||
for (j = 0, len = ref.length; j < len; j++) { | ||
rule = ref[j]; | ||
spaces = 15 - rule.longFlag.length; | ||
@@ -97,12 +97,12 @@ spaces = spaces > 0 ? repeat(' ', spaces) : ''; | ||
buildRules = function(rules) { | ||
var tuple, _i, _len, _results; | ||
_results = []; | ||
for (_i = 0, _len = rules.length; _i < _len; _i++) { | ||
tuple = rules[_i]; | ||
var j, len, results, tuple; | ||
results = []; | ||
for (j = 0, len = rules.length; j < len; j++) { | ||
tuple = rules[j]; | ||
if (tuple.length < 3) { | ||
tuple.unshift(null); | ||
} | ||
_results.push(buildRule.apply(null, tuple)); | ||
results.push(buildRule.apply(null, tuple)); | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -128,11 +128,11 @@ | ||
normalizeArguments = function(args) { | ||
var arg, l, match, result, _i, _j, _len, _len1, _ref; | ||
var arg, j, k, l, len, len1, match, ref, result; | ||
args = args.slice(0); | ||
result = []; | ||
for (_i = 0, _len = args.length; _i < _len; _i++) { | ||
arg = args[_i]; | ||
for (j = 0, len = args.length; j < len; j++) { | ||
arg = args[j]; | ||
if (match = arg.match(MULTI_FLAG)) { | ||
_ref = match[1].split(''); | ||
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { | ||
l = _ref[_j]; | ||
ref = match[1].split(''); | ||
for (k = 0, len1 = ref.length; k < len1; k++) { | ||
l = ref[k]; | ||
result.push('-' + l); | ||
@@ -139,0 +139,0 @@ } |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, loadFile, path, _i, _len, _ref; | ||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref; | ||
@@ -20,5 +20,5 @@ CoffeeScript = require('./coffee-script'); | ||
if (require.extensions) { | ||
_ref = CoffeeScript.FILE_EXTENSIONS; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
ext = _ref[_i]; | ||
ref = CoffeeScript.FILE_EXTENSIONS; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
ext = ref[i]; | ||
require.extensions[ext] = loadFile; | ||
@@ -25,0 +25,0 @@ } |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, replDefaults, updateSyntaxError, vm, _ref; | ||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, updateSyntaxError, vm; | ||
@@ -15,3 +15,3 @@ fs = require('fs'); | ||
_ref = require('./helpers'), merge = _ref.merge, updateSyntaxError = _ref.updateSyntaxError; | ||
ref = require('./helpers'), merge = ref.merge, updateSyntaxError = ref.updateSyntaxError; | ||
@@ -23,18 +23,18 @@ replDefaults = { | ||
"eval": function(input, context, filename, cb) { | ||
var Assign, Block, Literal, Value, ast, err, js, referencedVars, result, token, tokens, _ref1; | ||
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, result, token, tokens; | ||
input = input.replace(/\uFF00/g, '\n'); | ||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1'); | ||
_ref1 = require('./nodes'), Block = _ref1.Block, Assign = _ref1.Assign, Value = _ref1.Value, Literal = _ref1.Literal; | ||
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal; | ||
try { | ||
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]); | ||
var i, len, results; | ||
results = []; | ||
for (i = 0, len = tokens.length; i < len; i++) { | ||
token = tokens[i]; | ||
if (token.variable) { | ||
results.push(token[1]); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
})(); | ||
@@ -59,5 +59,5 @@ ast = CoffeeScript.nodes(tokens); | ||
addMultilineHandler = function(repl) { | ||
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, rli, _ref1; | ||
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli; | ||
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream; | ||
origPrompt = (_ref1 = repl._prompt) != null ? _ref1 : repl.prompt; | ||
origPrompt = (ref1 = repl._prompt) != null ? ref1 : repl.prompt; | ||
multiline = { | ||
@@ -165,9 +165,9 @@ enabled: false, | ||
start: function(opts) { | ||
var build, major, minor, repl, _ref1; | ||
var build, major, minor, ref1, repl; | ||
if (opts == null) { | ||
opts = {}; | ||
} | ||
_ref1 = process.versions.node.split('.').map(function(n) { | ||
ref1 = process.versions.node.split('.').map(function(n) { | ||
return parseInt(n); | ||
}), major = _ref1[0], minor = _ref1[1], build = _ref1[2]; | ||
}), major = ref1[0], minor = ref1[1], build = ref1[2]; | ||
if (major === 0 && minor < 8) { | ||
@@ -174,0 +174,0 @@ console.warn("Node 0.8.0+ required for CoffeeScript REPL"); |
@@ -1,6 +0,6 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
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, | ||
__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; }, | ||
__slice = [].slice; | ||
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, k, left, len, ref, rite, | ||
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; }, | ||
slice = [].slice; | ||
@@ -20,4 +20,4 @@ generate = function(tag, value, origin) { | ||
Rewriter.prototype.rewrite = function(_at_tokens) { | ||
this.tokens = _at_tokens; | ||
Rewriter.prototype.rewrite = function(tokens1) { | ||
this.tokens = tokens1; | ||
this.removeLeadingNewlines(); | ||
@@ -44,3 +44,3 @@ this.closeOpenCalls(); | ||
Rewriter.prototype.detectEnd = function(i, condition, action) { | ||
var levels, token, tokens, _ref, _ref1; | ||
var levels, ref, ref1, token, tokens; | ||
tokens = this.tokens; | ||
@@ -55,5 +55,5 @@ levels = 0; | ||
} | ||
if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) { | ||
if (ref = token[0], indexOf.call(EXPRESSION_START, ref) >= 0) { | ||
levels += 1; | ||
} else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) { | ||
} else if (ref1 = token[0], indexOf.call(EXPRESSION_END, ref1) >= 0) { | ||
levels -= 1; | ||
@@ -67,6 +67,6 @@ } | ||
Rewriter.prototype.removeLeadingNewlines = function() { | ||
var i, tag, _i, _len, _ref; | ||
_ref = this.tokens; | ||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { | ||
tag = _ref[i][0]; | ||
var i, k, len, ref, tag; | ||
ref = this.tokens; | ||
for (i = k = 0, len = ref.length; k < len; i = ++k) { | ||
tag = ref[i][0]; | ||
if (tag !== 'TERMINATOR') { | ||
@@ -84,4 +84,4 @@ break; | ||
condition = function(token, i) { | ||
var _ref; | ||
return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; | ||
var ref; | ||
return ((ref = token[0]) === ')' || ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; | ||
}; | ||
@@ -102,4 +102,4 @@ action = function(token, i) { | ||
condition = function(token, i) { | ||
var _ref; | ||
return (_ref = token[0]) === ']' || _ref === 'INDEX_END'; | ||
var ref; | ||
return (ref = token[0]) === ']' || ref === 'INDEX_END'; | ||
}; | ||
@@ -117,7 +117,7 @@ action = function(token, i) { | ||
Rewriter.prototype.matchTags = function() { | ||
var fuzz, i, j, pattern, _i, _ref, _ref1; | ||
i = arguments[0], pattern = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
Rewriter.prototype.indexOfTag = function() { | ||
var fuzz, i, j, k, pattern, ref, ref1; | ||
i = arguments[0], pattern = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
fuzz = 0; | ||
for (j = _i = 0, _ref = pattern.length; 0 <= _ref ? _i < _ref : _i > _ref; j = 0 <= _ref ? ++_i : --_i) { | ||
for (j = k = 0, ref = pattern.length; 0 <= ref ? k < ref : k > ref; j = 0 <= ref ? ++k : --k) { | ||
while (this.tag(i + j + fuzz) === 'HERECOMMENT') { | ||
@@ -132,21 +132,38 @@ fuzz += 2; | ||
} | ||
if (_ref1 = this.tag(i + j + fuzz), __indexOf.call(pattern[j], _ref1) < 0) { | ||
return false; | ||
if (ref1 = this.tag(i + j + fuzz), indexOf.call(pattern[j], ref1) < 0) { | ||
return -1; | ||
} | ||
} | ||
return true; | ||
return i + j + fuzz - 1; | ||
}; | ||
Rewriter.prototype.looksObjectish = function(j) { | ||
return this.matchTags(j, '@', null, ':') || this.matchTags(j, null, ':'); | ||
var end, index; | ||
if (this.indexOfTag(j, '@', null, ':') > -1 || this.indexOfTag(j, null, ':') > -1) { | ||
return true; | ||
} | ||
index = this.indexOfTag(j, EXPRESSION_START); | ||
if (index > -1) { | ||
end = null; | ||
this.detectEnd(index + 1, (function(token) { | ||
var ref; | ||
return ref = token[0], indexOf.call(EXPRESSION_END, ref) >= 0; | ||
}), (function(token, i) { | ||
return end = i; | ||
})); | ||
if (this.tag(end + 1) === ':') { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; | ||
Rewriter.prototype.findTagsBackwards = function(i, tags) { | ||
var backStack, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
var backStack, ref, ref1, ref2, ref3, ref4, ref5; | ||
backStack = []; | ||
while (i >= 0 && (backStack.length || (_ref2 = this.tag(i), __indexOf.call(tags, _ref2) < 0) && ((_ref3 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref3) < 0) || this.tokens[i].generated) && (_ref4 = this.tag(i), __indexOf.call(LINEBREAKS, _ref4) < 0))) { | ||
if (_ref = this.tag(i), __indexOf.call(EXPRESSION_END, _ref) >= 0) { | ||
while (i >= 0 && (backStack.length || (ref2 = this.tag(i), indexOf.call(tags, ref2) < 0) && ((ref3 = this.tag(i), indexOf.call(EXPRESSION_START, ref3) < 0) || this.tokens[i].generated) && (ref4 = this.tag(i), indexOf.call(LINEBREAKS, ref4) < 0))) { | ||
if (ref = this.tag(i), indexOf.call(EXPRESSION_END, ref) >= 0) { | ||
backStack.push(this.tag(i)); | ||
} | ||
if ((_ref1 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref1) >= 0) && backStack.length) { | ||
if ((ref1 = this.tag(i), indexOf.call(EXPRESSION_START, ref1) >= 0) && backStack.length) { | ||
backStack.pop(); | ||
@@ -156,10 +173,11 @@ } | ||
} | ||
return _ref5 = this.tag(i), __indexOf.call(tags, _ref5) >= 0; | ||
return ref5 = this.tag(i), indexOf.call(tags, ref5) >= 0; | ||
}; | ||
Rewriter.prototype.addImplicitBracesAndParens = function() { | ||
var stack; | ||
var stack, start; | ||
stack = []; | ||
start = null; | ||
return this.scanTokens(function(token, i, tokens) { | ||
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, newLine, nextTag, offset, prevTag, prevToken, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, newLine, nextTag, offset, prevTag, prevToken, ref, ref1, ref2, ref3, ref4, ref5, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag; | ||
tag = token[0]; | ||
@@ -176,16 +194,16 @@ prevTag = (prevToken = i > 0 ? tokens[i - 1] : [])[0]; | ||
inImplicit = function() { | ||
var _ref, _ref1; | ||
return (_ref = stackTop()) != null ? (_ref1 = _ref[2]) != null ? _ref1.ours : void 0 : void 0; | ||
var ref, ref1; | ||
return (ref = stackTop()) != null ? (ref1 = ref[2]) != null ? ref1.ours : void 0 : void 0; | ||
}; | ||
inImplicitCall = function() { | ||
var _ref; | ||
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '('; | ||
var ref; | ||
return inImplicit() && ((ref = stackTop()) != null ? ref[0] : void 0) === '('; | ||
}; | ||
inImplicitObject = function() { | ||
var _ref; | ||
return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '{'; | ||
var ref; | ||
return inImplicit() && ((ref = stackTop()) != null ? ref[0] : void 0) === '{'; | ||
}; | ||
inImplicitControl = function() { | ||
var _ref; | ||
return inImplicit && ((_ref = stackTop()) != null ? _ref[0] : void 0) === 'CONTROL'; | ||
var ref; | ||
return inImplicit && ((ref = stackTop()) != null ? ref[0] : void 0) === 'CONTROL'; | ||
}; | ||
@@ -211,3 +229,3 @@ startImplicitCall = function(j) { | ||
startImplicitObject = function(j, startsLine) { | ||
var idx; | ||
var idx, val; | ||
if (startsLine == null) { | ||
@@ -224,3 +242,5 @@ startsLine = true; | ||
]); | ||
tokens.splice(idx, 0, generate('{', generate(new String('{')), token)); | ||
val = new String('{'); | ||
val.generated = true; | ||
tokens.splice(idx, 0, generate('{', val, token)); | ||
if (j == null) { | ||
@@ -256,7 +276,7 @@ return i += 1; | ||
} | ||
if (__indexOf.call(EXPRESSION_START, tag) >= 0) { | ||
if (indexOf.call(EXPRESSION_START, tag) >= 0) { | ||
stack.push([tag, i]); | ||
return forward(1); | ||
} | ||
if (__indexOf.call(EXPRESSION_END, tag) >= 0) { | ||
if (indexOf.call(EXPRESSION_END, tag) >= 0) { | ||
while (inImplicit()) { | ||
@@ -271,5 +291,5 @@ if (inImplicitCall()) { | ||
} | ||
stack.pop(); | ||
start = stack.pop(); | ||
} | ||
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 ((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 (tag === '?') { | ||
@@ -281,3 +301,3 @@ tag = token[0] = 'FUNC_EXIST'; | ||
} | ||
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'])) { | ||
if (indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.indexOfTag(i + 1, 'INDENT', null, ':') > -1 && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { | ||
startImplicitCall(i + 1); | ||
@@ -288,7 +308,13 @@ stack.push(['INDENT', i + 2]); | ||
if (tag === ':') { | ||
if (this.tag(i - 2) === '@') { | ||
s = i - 2; | ||
} else { | ||
s = i - 1; | ||
} | ||
s = (function() { | ||
var ref2; | ||
switch (false) { | ||
case ref2 = this.tag(i - 1), indexOf.call(EXPRESSION_END, ref2) < 0: | ||
return start[1]; | ||
case this.tag(i - 2) !== '@': | ||
return i - 2; | ||
default: | ||
return i - 1; | ||
} | ||
}).call(this); | ||
while (this.tag(s - 2) === 'HERECOMMENT') { | ||
@@ -298,5 +324,5 @@ s -= 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 || (ref2 = this.tag(s - 1), indexOf.call(LINEBREAKS, ref2) >= 0) || tokens[s - 1].newLine; | ||
if (stackTop()) { | ||
_ref3 = stackTop(), stackTag = _ref3[0], stackIdx = _ref3[1]; | ||
ref3 = stackTop(), stackTag = ref3[0], stackIdx = ref3[1]; | ||
if ((stackTag === '{' || stackTag === 'INDENT' && this.tag(stackIdx - 1) === '{') && (startsLine || this.tag(s - 1) === ',' || this.tag(s - 1) === '{')) { | ||
@@ -309,14 +335,17 @@ return forward(1); | ||
} | ||
if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) { | ||
if (inImplicitObject() && indexOf.call(LINEBREAKS, tag) >= 0) { | ||
stackTop()[2].sameLine = false; | ||
} | ||
newLine = prevTag === 'OUTDENT' || prevToken.newLine; | ||
if (__indexOf.call(IMPLICIT_END, tag) >= 0 || __indexOf.call(CALL_CLOSERS, tag) >= 0 && newLine) { | ||
if (indexOf.call(IMPLICIT_END, tag) >= 0 || indexOf.call(CALL_CLOSERS, tag) >= 0 && newLine) { | ||
while (inImplicit()) { | ||
_ref4 = stackTop(), stackTag = _ref4[0], stackIdx = _ref4[1], (_ref5 = _ref4[2], sameLine = _ref5.sameLine, startsLine = _ref5.startsLine); | ||
ref4 = stackTop(), stackTag = ref4[0], stackIdx = ref4[1], (ref5 = ref4[2], sameLine = ref5.sameLine, startsLine = ref5.startsLine); | ||
if (inImplicitCall() && prevTag !== ',') { | ||
endImplicitCall(); | ||
} else if (inImplicitObject() && !this.insideForDeclaration && sameLine && tag !== 'TERMINATOR' && prevTag !== ':' && endImplicitObject()) { | ||
} else if (inImplicitObject() && !this.insideForDeclaration && sameLine && tag !== 'TERMINATOR' && prevTag !== ':') { | ||
endImplicitObject(); | ||
} else if (inImplicitObject() && tag === 'TERMINATOR' && prevTag !== ',' && !(startsLine && this.looksObjectish(i + 1))) { | ||
if (nextTag === 'HERECOMMENT') { | ||
return forward(1); | ||
} | ||
endImplicitObject(); | ||
@@ -340,3 +369,3 @@ } else { | ||
return this.scanTokens(function(token, i, tokens) { | ||
var column, line, nextLocation, prevLocation, _ref, _ref1; | ||
var column, line, nextLocation, prevLocation, ref, ref1; | ||
if (token[2]) { | ||
@@ -348,5 +377,5 @@ return 1; | ||
} | ||
if (token[0] === '{' && (nextLocation = (_ref = tokens[i + 1]) != null ? _ref[2] : void 0)) { | ||
if (token[0] === '{' && (nextLocation = (ref = tokens[i + 1]) != null ? ref[2] : void 0)) { | ||
line = nextLocation.first_line, column = nextLocation.first_column; | ||
} else if (prevLocation = (_ref1 = tokens[i - 1]) != null ? _ref1[2] : void 0) { | ||
} else if (prevLocation = (ref1 = tokens[i - 1]) != null ? ref1[2] : void 0) { | ||
line = prevLocation.last_line, column = prevLocation.last_column; | ||
@@ -370,4 +399,4 @@ } else { | ||
condition = function(token, i) { | ||
var _ref, _ref1, _ref2, _ref3; | ||
return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'TERMINATOR' && (_ref1 = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref1) >= 0)) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref2 = token[0]) === 'CATCH' || _ref2 === 'FINALLY') && (starter === '->' || starter === '=>')) || (_ref3 = token[0], __indexOf.call(CALL_CLOSERS, _ref3) >= 0) && this.tokens[i - 1].newLine; | ||
var ref, ref1, ref2, ref3; | ||
return token[1] !== ';' && (ref = token[0], indexOf.call(SINGLE_CLOSERS, ref) >= 0) && !(token[0] === 'TERMINATOR' && (ref1 = this.tag(i + 1), indexOf.call(EXPRESSION_CLOSE, ref1) >= 0)) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((ref2 = token[0]) === 'CATCH' || ref2 === 'FINALLY') && (starter === '->' || starter === '=>')) || (ref3 = token[0], indexOf.call(CALL_CLOSERS, ref3) >= 0) && this.tokens[i - 1].newLine; | ||
}; | ||
@@ -378,10 +407,10 @@ action = function(token, i) { | ||
return this.scanTokens(function(token, i, tokens) { | ||
var j, tag, _i, _ref, _ref1, _ref2; | ||
var j, k, ref, ref1, ref2, tag; | ||
tag = token[0]; | ||
if (tag === 'TERMINATOR') { | ||
if (this.tag(i + 1) === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { | ||
tokens.splice.apply(tokens, [i, 1].concat(__slice.call(this.indentation()))); | ||
tokens.splice.apply(tokens, [i, 1].concat(slice.call(this.indentation()))); | ||
return 1; | ||
} | ||
if (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0) { | ||
if (ref = this.tag(i + 1), indexOf.call(EXPRESSION_CLOSE, ref) >= 0) { | ||
tokens.splice(i, 1); | ||
@@ -392,13 +421,13 @@ return 0; | ||
if (tag === 'CATCH') { | ||
for (j = _i = 1; _i <= 2; j = ++_i) { | ||
if (!((_ref1 = this.tag(i + j)) === 'OUTDENT' || _ref1 === 'TERMINATOR' || _ref1 === 'FINALLY')) { | ||
for (j = k = 1; k <= 2; j = ++k) { | ||
if (!((ref1 = this.tag(i + j)) === 'OUTDENT' || ref1 === 'TERMINATOR' || ref1 === 'FINALLY')) { | ||
continue; | ||
} | ||
tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation()))); | ||
tokens.splice.apply(tokens, [i + j, 0].concat(slice.call(this.indentation()))); | ||
return 2 + j; | ||
} | ||
} | ||
if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { | ||
if (indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { | ||
starter = tag; | ||
_ref2 = this.indentation(tokens[i]), indent = _ref2[0], outdent = _ref2[1]; | ||
ref2 = this.indentation(tokens[i]), indent = ref2[0], outdent = ref2[1]; | ||
if (starter === 'THEN') { | ||
@@ -425,3 +454,3 @@ indent.fromThen = true; | ||
prevTag = this.tokens[i - 1][0]; | ||
return tag === 'TERMINATOR' || (tag === 'INDENT' && __indexOf.call(SINGLE_LINERS, prevTag) < 0); | ||
return tag === 'TERMINATOR' || (tag === 'INDENT' && indexOf.call(SINGLE_LINERS, prevTag) < 0); | ||
}; | ||
@@ -459,4 +488,4 @@ action = function(token, i) { | ||
Rewriter.prototype.tag = function(i) { | ||
var _ref; | ||
return (_ref = this.tokens[i]) != null ? _ref[0] : void 0; | ||
var ref; | ||
return (ref = this.tokens[i]) != null ? ref[0] : void 0; | ||
}; | ||
@@ -468,3 +497,3 @@ | ||
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']]; | ||
BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END'], ['STRING_START', 'STRING_END'], ['REGEX_START', 'REGEX_END']]; | ||
@@ -477,4 +506,4 @@ exports.INVERSES = INVERSES = {}; | ||
for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) { | ||
_ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1]; | ||
for (k = 0, len = BALANCED_PAIRS.length; k < len; k++) { | ||
ref = BALANCED_PAIRS[k], left = ref[0], rite = ref[1]; | ||
EXPRESSION_START.push(INVERSES[rite] = left); | ||
@@ -488,3 +517,3 @@ EXPRESSION_END.push(INVERSES[left] = rite); | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'YIELD', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'STRING_START', 'JS', 'REGEX', 'REGEX_START', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'YIELD', 'UNARY_MATH', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; | ||
@@ -491,0 +520,0 @@ IMPLICIT_UNSPACED_CALL = ['+', '-']; |
@@ -1,15 +0,13 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
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; }; | ||
var Scope, | ||
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; }; | ||
_ref = require('./helpers'), extend = _ref.extend, last = _ref.last; | ||
exports.Scope = Scope = (function() { | ||
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; | ||
function Scope(parent, expressions, method, referencedVars) { | ||
var ref, ref1; | ||
this.parent = parent; | ||
this.expressions = expressions; | ||
this.method = method; | ||
this.referencedVars = referencedVars; | ||
this.variables = [ | ||
@@ -25,3 +23,3 @@ { | ||
} | ||
this.root = (_ref1 = (_ref2 = this.parent) != null ? _ref2.root : void 0) != null ? _ref1 : this; | ||
this.root = (ref = (ref1 = this.parent) != null ? ref1.root : void 0) != null ? ref : this; | ||
} | ||
@@ -44,4 +42,4 @@ | ||
Scope.prototype.namedMethod = function() { | ||
var _ref1; | ||
if (((_ref1 = this.method) != null ? _ref1.name : void 0) || !this.parent) { | ||
var ref; | ||
if (((ref = this.method) != null ? ref.name : void 0) || !this.parent) { | ||
return this.method; | ||
@@ -68,11 +66,14 @@ } | ||
Scope.prototype.check = function(name) { | ||
var _ref1; | ||
return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0)); | ||
var ref; | ||
return !!(this.type(name) || ((ref = this.parent) != null ? ref.check(name) : void 0)); | ||
}; | ||
Scope.prototype.temporary = function(name, index) { | ||
if (name.length > 1) { | ||
return '_' + name + (index > 1 ? index - 1 : ''); | ||
Scope.prototype.temporary = function(name, index, single) { | ||
if (single == null) { | ||
single = false; | ||
} | ||
if (single) { | ||
return (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a'); | ||
} else { | ||
return '_' + (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a'); | ||
return name + (index || ''); | ||
} | ||
@@ -82,6 +83,6 @@ }; | ||
Scope.prototype.type = function(name) { | ||
var v, _i, _len, _ref1; | ||
_ref1 = this.variables; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
v = _ref1[_i]; | ||
var i, len, ref, v; | ||
ref = this.variables; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
v = ref[i]; | ||
if (v.name === name) { | ||
@@ -94,11 +95,11 @@ return v.type; | ||
Scope.prototype.freeVariable = function(name, reserve) { | ||
var index, temp; | ||
if (reserve == null) { | ||
reserve = true; | ||
Scope.prototype.freeVariable = function(name, options) { | ||
var index, ref, temp; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
index = 0; | ||
while (true) { | ||
temp = this.temporary(name, index); | ||
if (!(this.check(temp) || __indexOf.call(this.root.referencedVars, temp) >= 0)) { | ||
temp = this.temporary(name, index, options.single); | ||
if (!(this.check(temp) || indexOf.call(this.root.referencedVars, temp) >= 0)) { | ||
break; | ||
@@ -108,3 +109,3 @@ } | ||
} | ||
if (reserve) { | ||
if ((ref = options.reserve) != null ? ref : true) { | ||
this.add(temp, 'var', true); | ||
@@ -128,26 +129,28 @@ } | ||
Scope.prototype.declaredVariables = function() { | ||
var realVars, tempVars, v, _i, _len, _ref1; | ||
realVars = []; | ||
tempVars = []; | ||
_ref1 = this.variables; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
v = _ref1[_i]; | ||
if (v.type === 'var') { | ||
(v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name); | ||
var v; | ||
return ((function() { | ||
var i, len, ref, results; | ||
ref = this.variables; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
v = ref[i]; | ||
if (v.type === 'var') { | ||
results.push(v.name); | ||
} | ||
} | ||
} | ||
return realVars.sort().concat(tempVars.sort()); | ||
return results; | ||
}).call(this)).sort(); | ||
}; | ||
Scope.prototype.assignedVariables = function() { | ||
var v, _i, _len, _ref1, _results; | ||
_ref1 = this.variables; | ||
_results = []; | ||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { | ||
v = _ref1[_i]; | ||
var i, len, ref, results, v; | ||
ref = this.variables; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
v = ref[i]; | ||
if (v.type.assigned) { | ||
_results.push(v.name + " = " + v.type.value); | ||
results.push(v.name + " = " + v.type.value); | ||
} | ||
} | ||
return _results; | ||
return results; | ||
}; | ||
@@ -154,0 +157,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.9.0 | ||
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
@@ -6,10 +6,10 @@ var LineMap, SourceMap; | ||
LineMap = (function() { | ||
function LineMap(_at_line) { | ||
this.line = _at_line; | ||
function LineMap(line1) { | ||
this.line = line1; | ||
this.columns = []; | ||
} | ||
LineMap.prototype.add = function(column, _arg, options) { | ||
LineMap.prototype.add = function(column, arg, options) { | ||
var sourceColumn, sourceLine; | ||
sourceLine = _arg[0], sourceColumn = _arg[1]; | ||
sourceLine = arg[0], sourceColumn = arg[1]; | ||
if (options == null) { | ||
@@ -49,3 +49,3 @@ options = {}; | ||
SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) { | ||
var column, line, lineMap, _base; | ||
var base, column, line, lineMap; | ||
if (options == null) { | ||
@@ -55,9 +55,9 @@ options = {}; | ||
line = generatedLocation[0], column = generatedLocation[1]; | ||
lineMap = ((_base = this.lines)[line] || (_base[line] = new LineMap(line))); | ||
lineMap = ((base = this.lines)[line] || (base[line] = new LineMap(line))); | ||
return lineMap.add(column, sourceLocation, options); | ||
}; | ||
SourceMap.prototype.sourceLocation = function(_arg) { | ||
SourceMap.prototype.sourceLocation = function(arg) { | ||
var column, line, lineMap; | ||
line = _arg[0], column = _arg[1]; | ||
line = arg[0], column = arg[1]; | ||
while (!((lineMap = this.lines[line]) || (line <= 0))) { | ||
@@ -70,3 +70,3 @@ line--; | ||
SourceMap.prototype.generate = function(options, code) { | ||
var buffer, lastColumn, lastSourceColumn, lastSourceLine, lineMap, lineNumber, mapping, needComma, v3, writingline, _i, _j, _len, _len1, _ref, _ref1; | ||
var buffer, i, j, lastColumn, lastSourceColumn, lastSourceLine, len, len1, lineMap, lineNumber, mapping, needComma, ref, ref1, v3, writingline; | ||
if (options == null) { | ||
@@ -84,9 +84,9 @@ options = {}; | ||
buffer = ""; | ||
_ref = this.lines; | ||
for (lineNumber = _i = 0, _len = _ref.length; _i < _len; lineNumber = ++_i) { | ||
lineMap = _ref[lineNumber]; | ||
ref = this.lines; | ||
for (lineNumber = i = 0, len = ref.length; i < len; lineNumber = ++i) { | ||
lineMap = ref[lineNumber]; | ||
if (lineMap) { | ||
_ref1 = lineMap.columns; | ||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { | ||
mapping = _ref1[_j]; | ||
ref1 = lineMap.columns; | ||
for (j = 0, len1 = ref1.length; j < len1; j++) { | ||
mapping = ref1[j]; | ||
if (!(mapping)) { | ||
@@ -93,0 +93,0 @@ continue; |
@@ -11,3 +11,3 @@ { | ||
"author": "Jeremy Ashkenas", | ||
"version": "1.9.0", | ||
"version": "1.9.1", | ||
"license": "MIT", | ||
@@ -41,4 +41,4 @@ "engines": { | ||
"underscore": "~1.5.2", | ||
"docco": "~0.6.2" | ||
"docco": "~0.7.0" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
333876
7867