2015-04-15 11:26:30 -04:00
|
|
|
// Generated by CoffeeScript 1.9.2
|
2010-07-24 11:31:43 -04:00
|
|
|
(function() {
|
2015-01-30 14:33:03 -05:00
|
|
|
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; };
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2010-10-24 14:19:47 -04:00
|
|
|
fs = require('fs');
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-03-17 23:46:54 -04:00
|
|
|
vm = require('vm');
|
|
|
|
|
2010-09-21 05:19:49 -04:00
|
|
|
path = require('path');
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2012-09-25 19:01:16 -04:00
|
|
|
Lexer = require('./lexer').Lexer;
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2010-09-28 16:47:12 -04:00
|
|
|
parser = require('./parser').parser;
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-02-27 21:54:17 -05:00
|
|
|
helpers = require('./helpers');
|
2013-02-28 15:51:29 -05:00
|
|
|
|
2013-03-18 07:23:05 -04:00
|
|
|
SourceMap = require('./sourcemap');
|
2012-09-25 19:01:16 -04:00
|
|
|
|
2015-04-15 11:26:30 -04:00
|
|
|
exports.VERSION = '1.9.2';
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-10-20 10:08:13 -04:00
|
|
|
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
2013-07-30 00:06:41 -04:00
|
|
|
|
2013-03-04 16:40:39 -05:00
|
|
|
exports.helpers = helpers;
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-07-31 07:27:49 -04:00
|
|
|
withPrettyErrors = function(fn) {
|
|
|
|
return function(code, options) {
|
|
|
|
var err;
|
|
|
|
if (options == null) {
|
|
|
|
options = {};
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return fn.call(this, code, options);
|
|
|
|
} catch (_error) {
|
|
|
|
err = _error;
|
2015-05-01 07:43:04 -04:00
|
|
|
if (typeof code !== 'string') {
|
|
|
|
throw err;
|
|
|
|
}
|
2013-08-02 00:52:36 -04:00
|
|
|
throw helpers.updateSyntaxError(err, code, options.filename);
|
2013-07-31 07:27:49 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.compile = compile = withPrettyErrors(function(code, options) {
|
2015-01-30 14:33:03 -05:00
|
|
|
var answer, currentColumn, currentLine, extend, fragment, fragments, header, i, js, len, map, merge, newLines, token, tokens;
|
2013-10-20 15:21:06 -04:00
|
|
|
merge = helpers.merge, extend = helpers.extend;
|
|
|
|
options = extend({}, options);
|
2013-03-04 21:37:36 -05:00
|
|
|
if (options.sourceMap) {
|
2013-03-18 07:23:05 -04:00
|
|
|
map = new SourceMap;
|
2013-03-04 21:37:36 -05:00
|
|
|
}
|
Fix #1500, #1574, #3318: Name generated vars uniquely
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500, #1574)
For example, `({a}, _arg) ->` now compiles correctly. (#1574)
As opposed to the somewhat complex implementations discussed in #1500, this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.
`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318)
`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)
Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.
Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 17:04:30 -05:00
|
|
|
tokens = lexer.tokenize(code, options);
|
|
|
|
options.referencedVars = (function() {
|
2015-01-30 14:33:03 -05:00
|
|
|
var i, len, results;
|
|
|
|
results = [];
|
|
|
|
for (i = 0, len = tokens.length; i < len; i++) {
|
|
|
|
token = tokens[i];
|
|
|
|
if (token.variable) {
|
|
|
|
results.push(token[1]);
|
Fix #1500, #1574, #3318: Name generated vars uniquely
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500, #1574)
For example, `({a}, _arg) ->` now compiles correctly. (#1574)
As opposed to the somewhat complex implementations discussed in #1500, this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.
`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318)
`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)
Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.
Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 17:04:30 -05:00
|
|
|
}
|
|
|
|
}
|
2015-01-30 14:33:03 -05:00
|
|
|
return results;
|
Fix #1500, #1574, #3318: Name generated vars uniquely
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500, #1574)
For example, `({a}, _arg) ->` now compiles correctly. (#1574)
As opposed to the somewhat complex implementations discussed in #1500, this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.
`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318)
`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)
Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.
Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 17:04:30 -05:00
|
|
|
})();
|
|
|
|
fragments = parser.parse(tokens).compileToFragments(options);
|
2013-03-04 21:37:36 -05:00
|
|
|
currentLine = 0;
|
2013-03-25 13:56:24 -04:00
|
|
|
if (options.header) {
|
|
|
|
currentLine += 1;
|
|
|
|
}
|
|
|
|
if (options.shiftLine) {
|
2013-03-04 21:37:36 -05:00
|
|
|
currentLine += 1;
|
|
|
|
}
|
|
|
|
currentColumn = 0;
|
|
|
|
js = "";
|
2015-01-30 14:33:03 -05:00
|
|
|
for (i = 0, len = fragments.length; i < len; i++) {
|
|
|
|
fragment = fragments[i];
|
2013-03-18 07:23:05 -04:00
|
|
|
if (options.sourceMap) {
|
2015-05-13 11:50:02 -04:00
|
|
|
if (fragment.locationData && !/^[;\s]*$/.test(fragment.code)) {
|
2013-03-18 07:23:05 -04:00
|
|
|
map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
|
2013-03-04 21:37:36 -05:00
|
|
|
noReplace: true
|
|
|
|
});
|
2013-02-28 15:51:29 -05:00
|
|
|
}
|
2013-03-04 21:37:36 -05:00
|
|
|
newLines = helpers.count(fragment.code, "\n");
|
|
|
|
currentLine += newLines;
|
2013-08-06 16:25:23 -04:00
|
|
|
if (newLines) {
|
|
|
|
currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1);
|
|
|
|
} else {
|
|
|
|
currentColumn += fragment.code.length;
|
|
|
|
}
|
2013-02-28 15:51:29 -05:00
|
|
|
}
|
2013-03-04 21:37:36 -05:00
|
|
|
js += fragment.code;
|
2010-03-07 22:08:24 -05:00
|
|
|
}
|
2013-02-25 17:20:37 -05:00
|
|
|
if (options.header) {
|
|
|
|
header = "Generated by CoffeeScript " + this.VERSION;
|
|
|
|
js = "// " + header + "\n" + js;
|
2010-03-07 22:08:24 -05:00
|
|
|
}
|
2013-03-04 16:19:21 -05:00
|
|
|
if (options.sourceMap) {
|
2013-03-04 09:45:25 -05:00
|
|
|
answer = {
|
|
|
|
js: js
|
2013-03-01 11:34:39 -05:00
|
|
|
};
|
2013-03-18 07:23:05 -04:00
|
|
|
answer.sourceMap = map;
|
|
|
|
answer.v3SourceMap = map.generate(options, code);
|
2013-03-04 09:45:25 -05:00
|
|
|
return answer;
|
|
|
|
} else {
|
|
|
|
return js;
|
2013-02-28 15:51:29 -05:00
|
|
|
}
|
2013-07-31 07:27:49 -04:00
|
|
|
});
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-07-31 07:27:49 -04:00
|
|
|
exports.tokens = withPrettyErrors(function(code, options) {
|
2010-10-08 15:27:05 -04:00
|
|
|
return lexer.tokenize(code, options);
|
2013-07-31 07:27:49 -04:00
|
|
|
});
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-07-31 07:27:49 -04:00
|
|
|
exports.nodes = withPrettyErrors(function(source, options) {
|
2010-11-17 11:34:23 -05:00
|
|
|
if (typeof source === 'string') {
|
2010-11-20 16:25:22 -05:00
|
|
|
return parser.parse(lexer.tokenize(source, options));
|
2010-11-17 11:34:23 -05:00
|
|
|
} else {
|
|
|
|
return parser.parse(source);
|
|
|
|
}
|
2013-07-31 07:27:49 -04:00
|
|
|
});
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2010-09-04 06:39:01 -04:00
|
|
|
exports.run = function(code, options) {
|
2015-01-30 14:33:03 -05:00
|
|
|
var answer, dir, mainModule, ref;
|
2012-04-10 14:57:45 -04:00
|
|
|
if (options == null) {
|
|
|
|
options = {};
|
|
|
|
}
|
2011-05-03 15:53:10 -04:00
|
|
|
mainModule = require.main;
|
|
|
|
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
|
2011-05-03 16:10:30 -04:00
|
|
|
mainModule.moduleCache && (mainModule.moduleCache = {});
|
2014-01-29 13:23:19 -05:00
|
|
|
dir = options.filename ? path.dirname(fs.realpathSync(options.filename)) : fs.realpathSync('.');
|
2013-10-20 16:50:13 -04:00
|
|
|
mainModule.paths = require('module')._nodeModulePaths(dir);
|
2013-02-27 21:54:17 -05:00
|
|
|
if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
|
2013-03-12 02:26:51 -04:00
|
|
|
answer = compile(code, options);
|
2015-01-30 14:33:03 -05:00
|
|
|
code = (ref = answer.js) != null ? ref : answer;
|
2010-11-08 23:07:51 -05:00
|
|
|
}
|
2013-07-30 00:06:41 -04:00
|
|
|
return mainModule._compile(code, mainModule.filename);
|
2010-09-04 06:39:01 -04:00
|
|
|
};
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2012-01-11 18:04:14 -05:00
|
|
|
exports["eval"] = function(code, options) {
|
2015-01-30 14:33:03 -05:00
|
|
|
var Module, _module, _require, createContext, i, isContext, js, k, len, o, r, ref, ref1, ref2, ref3, sandbox, v;
|
2012-04-10 14:57:45 -04:00
|
|
|
if (options == null) {
|
|
|
|
options = {};
|
|
|
|
}
|
|
|
|
if (!(code = code.trim())) {
|
|
|
|
return;
|
|
|
|
}
|
2015-01-30 14:33:03 -05:00
|
|
|
createContext = (ref = vm.Script.createContext) != null ? ref : vm.createContext;
|
|
|
|
isContext = (ref1 = vm.isContext) != null ? ref1 : function(ctx) {
|
2015-01-05 15:40:04 -05:00
|
|
|
return options.sandbox instanceof createContext().constructor;
|
|
|
|
};
|
|
|
|
if (createContext) {
|
2011-08-04 23:17:23 -04:00
|
|
|
if (options.sandbox != null) {
|
2015-01-05 15:40:04 -05:00
|
|
|
if (isContext(options.sandbox)) {
|
2011-08-04 23:17:23 -04:00
|
|
|
sandbox = options.sandbox;
|
|
|
|
} else {
|
2015-01-05 15:40:04 -05:00
|
|
|
sandbox = createContext();
|
2015-01-30 14:33:03 -05:00
|
|
|
ref2 = options.sandbox;
|
|
|
|
for (k in ref2) {
|
|
|
|
if (!hasProp.call(ref2, k)) continue;
|
|
|
|
v = ref2[k];
|
2011-08-04 23:17:23 -04:00
|
|
|
sandbox[k] = v;
|
|
|
|
}
|
2011-05-01 01:45:14 -04:00
|
|
|
}
|
2011-10-23 22:45:32 -04:00
|
|
|
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
|
|
|
|
} else {
|
|
|
|
sandbox = global;
|
2011-04-29 13:59:59 -04:00
|
|
|
}
|
2011-08-04 23:17:23 -04:00
|
|
|
sandbox.__filename = options.filename || 'eval';
|
|
|
|
sandbox.__dirname = path.dirname(sandbox.__filename);
|
2011-10-23 22:45:32 -04:00
|
|
|
if (!(sandbox !== global || sandbox.module || sandbox.require)) {
|
2011-08-04 23:17:23 -04:00
|
|
|
Module = require('module');
|
|
|
|
sandbox.module = _module = new Module(options.modulename || 'eval');
|
|
|
|
sandbox.require = _require = function(path) {
|
2011-10-23 22:45:32 -04:00
|
|
|
return Module._load(path, _module, true);
|
2011-08-04 23:17:23 -04:00
|
|
|
};
|
|
|
|
_module.filename = sandbox.__filename;
|
2015-01-30 14:33:03 -05:00
|
|
|
ref3 = Object.getOwnPropertyNames(require);
|
|
|
|
for (i = 0, len = ref3.length; i < len; i++) {
|
|
|
|
r = ref3[i];
|
2012-04-10 14:57:45 -04:00
|
|
|
if (r !== 'paths') {
|
|
|
|
_require[r] = require[r];
|
|
|
|
}
|
2011-08-04 23:17:23 -04:00
|
|
|
}
|
|
|
|
_require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
|
|
|
|
_require.resolve = function(request) {
|
|
|
|
return Module._resolveFilename(request, _module);
|
|
|
|
};
|
2011-07-06 03:54:36 -04:00
|
|
|
}
|
|
|
|
}
|
2011-05-25 03:53:51 -04:00
|
|
|
o = {};
|
|
|
|
for (k in options) {
|
2015-01-30 14:33:03 -05:00
|
|
|
if (!hasProp.call(options, k)) continue;
|
2011-05-25 03:53:51 -04:00
|
|
|
v = options[k];
|
|
|
|
o[k] = v;
|
|
|
|
}
|
|
|
|
o.bare = true;
|
2011-07-06 16:31:48 -04:00
|
|
|
js = compile(code, o);
|
2011-10-23 22:45:32 -04:00
|
|
|
if (sandbox === global) {
|
|
|
|
return vm.runInThisContext(js);
|
2011-08-04 23:17:23 -04:00
|
|
|
} else {
|
2011-10-23 22:45:32 -04:00
|
|
|
return vm.runInContext(js, sandbox);
|
2011-08-04 23:17:23 -04:00
|
|
|
}
|
2010-09-21 01:36:23 -04:00
|
|
|
};
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2013-12-08 15:21:18 -05:00
|
|
|
exports.register = function() {
|
|
|
|
return require('./register');
|
|
|
|
};
|
|
|
|
|
2014-02-22 21:40:19 -05:00
|
|
|
if (require.extensions) {
|
2015-01-30 14:33:03 -05:00
|
|
|
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() {
|
2014-02-22 23:02:52 -05:00
|
|
|
throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require " + ext + " files.");
|
2014-02-22 21:40:19 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-20 10:08:13 -04:00
|
|
|
exports._compileFile = function(filename, sourceMap) {
|
2013-06-09 01:54:34 -04:00
|
|
|
var answer, err, raw, stripped;
|
2013-10-20 10:08:13 -04:00
|
|
|
if (sourceMap == null) {
|
|
|
|
sourceMap = false;
|
|
|
|
}
|
2013-03-17 23:46:54 -04:00
|
|
|
raw = fs.readFileSync(filename, 'utf8');
|
|
|
|
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
|
2013-06-09 01:54:34 -04:00
|
|
|
try {
|
|
|
|
answer = compile(stripped, {
|
|
|
|
filename: filename,
|
2013-07-30 00:06:41 -04:00
|
|
|
sourceMap: sourceMap,
|
2013-06-09 01:54:34 -04:00
|
|
|
literate: helpers.isLiterate(filename)
|
|
|
|
});
|
|
|
|
} catch (_error) {
|
|
|
|
err = _error;
|
2013-08-02 00:52:36 -04:00
|
|
|
throw helpers.updateSyntaxError(err, stripped, filename);
|
2013-06-09 01:54:34 -04:00
|
|
|
}
|
2013-07-30 00:06:41 -04:00
|
|
|
return answer;
|
|
|
|
};
|
|
|
|
|
2010-09-25 04:39:19 -04:00
|
|
|
lexer = new Lexer;
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2010-02-11 01:57:33 -05:00
|
|
|
parser.lexer = {
|
2010-05-14 23:40:04 -04:00
|
|
|
lex: function() {
|
2012-11-21 16:57:30 -05:00
|
|
|
var tag, token;
|
2015-01-15 11:47:07 -05:00
|
|
|
token = parser.tokens[this.pos++];
|
2013-01-14 15:20:35 -05:00
|
|
|
if (token) {
|
|
|
|
tag = token[0], this.yytext = token[1], this.yylloc = token[2];
|
2015-01-15 11:47:07 -05:00
|
|
|
parser.errorToken = token.origin || token;
|
2013-01-14 15:20:35 -05:00
|
|
|
this.yylineno = this.yylloc.first_line;
|
|
|
|
} else {
|
|
|
|
tag = '';
|
|
|
|
}
|
2010-11-02 00:05:06 -04:00
|
|
|
return tag;
|
2010-02-11 01:57:33 -05:00
|
|
|
},
|
2015-01-15 11:47:07 -05:00
|
|
|
setInput: function(tokens) {
|
|
|
|
parser.tokens = tokens;
|
2010-10-20 18:19:08 -04:00
|
|
|
return this.pos = 0;
|
2010-02-11 01:57:33 -05:00
|
|
|
},
|
2010-05-14 23:40:04 -04:00
|
|
|
upcomingInput: function() {
|
2010-02-11 01:57:33 -05:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
};
|
2011-09-18 18:16:39 -04:00
|
|
|
|
2010-09-21 03:50:32 -04:00
|
|
|
parser.yy = require('./nodes');
|
2011-12-14 10:39:20 -05:00
|
|
|
|
2015-01-30 14:33:03 -05:00
|
|
|
parser.yy.parseError = function(message, arg) {
|
2015-01-15 11:47:07 -05:00
|
|
|
var errorLoc, errorTag, errorText, errorToken, token, tokens;
|
2015-01-30 14:33:03 -05:00
|
|
|
token = arg.token;
|
2015-01-15 11:47:07 -05:00
|
|
|
errorToken = parser.errorToken, tokens = parser.tokens;
|
2014-01-26 00:25:13 -05:00
|
|
|
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2];
|
Fix #3597: Allow interpolations in object keys
The following is now allowed:
o =
a: 1
b: 2
"#{'c'}": 3
"#{'d'}": 4
e: 5
"#{'f'}": 6
g: 7
It compiles to:
o = (
obj = {
a: 1,
b: 2
},
obj["" + 'c'] = 3,
obj["" + 'd'] = 4,
obj.e = 5,
obj["" + 'f'] = 6,
obj.g = 7,
obj
);
- Closes #3039. Empty interpolations in object keys are now _supposed_ to be
allowed.
- Closes #1131. No need to improve error messages for attempted key
interpolation anymore.
- Implementing this required fixing the following bug: `("" + a): 1` used to
error out on the colon, saying "unexpected colon". But really, it is the
attempted object key that is unexpected. Now the error is on the opening
parenthesis instead.
- However, the above fix broke some error message tests for regexes. The easiest
way to fix this was to make a seemingly unrelated change: The error messages
for unexpected identifiers, numbers, strings and regexes now say for example
'unexpected string' instead of 'unexpected """some #{really long} string"""'.
In other words, the tag _name_ is used instead of the tag _value_.
This was way easier to implement, and is more helpful to the user. Using the
tag value is good for operators, reserved words and the like, but not for
tokens which can contain any text. For example, 'unexpected identifier' is
better than 'unexpected expected' (if a variable called 'expected' was used
erraneously).
- While writing tests for the above point I found a few minor bugs with string
locations which have been fixed.
2015-02-07 14:16:59 -05:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
})();
|
2014-01-21 21:44:50 -05:00
|
|
|
return helpers.throwSyntaxError("unexpected " + errorText, errorLoc);
|
2013-02-25 13:09:42 -05:00
|
|
|
};
|
|
|
|
|
2013-03-12 02:26:51 -04:00
|
|
|
formatSourcePosition = function(frame, getSourceMapping) {
|
|
|
|
var as, column, fileLocation, fileName, functionName, isConstructor, isMethodCall, line, methodName, source, tp, typeName;
|
|
|
|
fileName = void 0;
|
|
|
|
fileLocation = '';
|
|
|
|
if (frame.isNative()) {
|
|
|
|
fileLocation = "native";
|
|
|
|
} else {
|
|
|
|
if (frame.isEval()) {
|
|
|
|
fileName = frame.getScriptNameOrSourceURL();
|
|
|
|
if (!fileName) {
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
fileLocation = (frame.getEvalOrigin()) + ", ";
|
2013-03-12 02:26:51 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fileName = frame.getFileName();
|
|
|
|
}
|
|
|
|
fileName || (fileName = "<anonymous>");
|
|
|
|
line = frame.getLineNumber();
|
|
|
|
column = frame.getColumnNumber();
|
|
|
|
source = getSourceMapping(fileName, line, column);
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
fileLocation = source ? fileName + ":" + source[0] + ":" + source[1] : fileName + ":" + line + ":" + column;
|
2013-03-12 02:26:51 -04:00
|
|
|
}
|
|
|
|
functionName = frame.getFunctionName();
|
|
|
|
isConstructor = frame.isConstructor();
|
|
|
|
isMethodCall = !(frame.isToplevel() || isConstructor);
|
|
|
|
if (isMethodCall) {
|
|
|
|
methodName = frame.getMethodName();
|
|
|
|
typeName = frame.getTypeName();
|
|
|
|
if (functionName) {
|
|
|
|
tp = as = '';
|
|
|
|
if (typeName && functionName.indexOf(typeName)) {
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
tp = typeName + ".";
|
2013-03-12 02:26:51 -04:00
|
|
|
}
|
|
|
|
if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) {
|
|
|
|
as = " [as " + methodName + "]";
|
|
|
|
}
|
|
|
|
return "" + tp + functionName + as + " (" + fileLocation + ")";
|
|
|
|
} else {
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
return typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")";
|
2013-03-12 02:26:51 -04:00
|
|
|
}
|
|
|
|
} else if (isConstructor) {
|
|
|
|
return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")";
|
|
|
|
} else if (functionName) {
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
return functionName + " (" + fileLocation + ")";
|
2013-03-12 02:26:51 -04:00
|
|
|
} else {
|
|
|
|
return fileLocation;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-30 00:06:41 -04:00
|
|
|
sourceMaps = {};
|
|
|
|
|
|
|
|
getSourceMap = function(filename) {
|
2015-01-30 14:33:03 -05:00
|
|
|
var answer, ref1;
|
2013-07-30 00:06:41 -04:00
|
|
|
if (sourceMaps[filename]) {
|
|
|
|
return sourceMaps[filename];
|
|
|
|
}
|
2015-01-30 14:33:03 -05:00
|
|
|
if (ref1 = path != null ? path.extname(filename) : void 0, indexOf.call(exports.FILE_EXTENSIONS, ref1) < 0) {
|
2013-07-30 00:06:41 -04:00
|
|
|
return;
|
|
|
|
}
|
2013-10-20 10:08:13 -04:00
|
|
|
answer = exports._compileFile(filename, true);
|
2013-07-30 00:06:41 -04:00
|
|
|
return sourceMaps[filename] = answer.sourceMap;
|
|
|
|
};
|
|
|
|
|
|
|
|
Error.prepareStackTrace = function(err, stack) {
|
2014-02-07 07:01:01 -05:00
|
|
|
var frame, frames, getSourceMapping;
|
2013-07-30 00:06:41 -04:00
|
|
|
getSourceMapping = function(filename, line, column) {
|
|
|
|
var answer, sourceMap;
|
|
|
|
sourceMap = getSourceMap(filename);
|
|
|
|
if (sourceMap) {
|
|
|
|
answer = sourceMap.sourceLocation([line - 1, column - 1]);
|
|
|
|
}
|
|
|
|
if (answer) {
|
|
|
|
return [answer[0] + 1, answer[1] + 1];
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
frames = (function() {
|
2015-01-30 14:33:03 -05:00
|
|
|
var j, len1, results;
|
|
|
|
results = [];
|
|
|
|
for (j = 0, len1 = stack.length; j < len1; j++) {
|
|
|
|
frame = stack[j];
|
2013-07-30 00:06:41 -04:00
|
|
|
if (frame.getFunction() === exports.run) {
|
|
|
|
break;
|
|
|
|
}
|
2015-01-30 14:33:03 -05:00
|
|
|
results.push(" at " + (formatSourcePosition(frame, getSourceMapping)));
|
2013-07-30 00:06:41 -04:00
|
|
|
}
|
2015-01-30 14:33:03 -05:00
|
|
|
return results;
|
2013-07-30 00:06:41 -04:00
|
|
|
})();
|
Refactor interpolation (and string and regex) handling in lexer
- Fix #3394: Unclosed single-quoted strings (both regular ones and heredocs)
used to pass through the lexer, causing a parsing error later, while
double-quoted strings caused an error already in the lexing phase. Now both
single and double-quoted unclosed strings error out in the lexer (which is the
more logical option) with consistent error messages. This also fixes the last
comment by @satyr in #3301.
- Similar to the above, unclosed heregexes also used to pass through the lexer
and not error until in the parsing phase, which resulted in confusing error
messages. This has been fixed, too.
- Fix #3348, by adding passing tests.
- Fix #3529: If a string starts with an interpolation, an empty string is no
longer emitted before the interpolation (unless it is needed to coerce the
interpolation into a string).
- Block comments cannot contain `*/`. Now the error message also shows exactly
where the offending `*/`. This improvement might seem unrelated, but I had to
touch that code anyway to refactor string and regex related code, and the
change was very trivial. Moreover, it's consistent with the next two points.
- Regexes cannot start with `*`. Now the error message also shows exactly where
the offending `*` is. (It might actually not be exatly at the start in
heregexes.) It is a very minor improvement, but it was trivial to add.
- Octal escapes in strings are forbidden in CoffeeScript (just like in
JavaScript strict mode). However, this used to be the case only for regular
strings. Now they are also forbidden in heredocs. Moreover, the errors now
point at the offending octal escape.
- Invalid regex flags are no longer allowed. This includes repeated modifiers
and unknown ones. Moreover, invalid modifiers do not stop a heregex from
being matched, which results in better error messages.
- Fix #3621: `///a#{1}///` compiles to `RegExp("a" + 1)`. So does
`RegExp("a#{1}")`. Still, those two code snippets used to generate different
tokens, which is a bit weird, but more importantly causes problems for
coffeelint (see clutchski/coffeelint#340). This required lots of tests in
test/location.coffee to be updated. Note that some updates to those tests are
unrelated to this point; some have been updated to be more consistent (I
discovered this because the refactored code happened to be seemingly more
correct).
- Regular regex literals used to erraneously allow newlines to be escaped,
causing invalid JavaScript output. This has been fixed.
- Heregexes may now be completely empty (`//////`), instead of erroring out with
a confusing message.
- Fix #2388: Heredocs and heregexes used to be lexed simply, which meant that
you couldn't nest a heredoc within a heredoc (double-quoted, that is) or a
heregex inside a heregex.
- Fix #2321: If you used division inside interpolation and then a slash later in
the string containing that interpolation, the division slash and the latter
slash was erraneously matched as a regex. This has been fixed.
- Indentation inside interpolations in heredocs no longer affect how much
indentation is removed from each line of the heredoc (which is more
intuitive).
- Whitespace is now correctly trimmed from the start and end of strings in a few
edge cases.
- Last but not least, the lexing of interpolated strings now seems to be more
efficient. For a regular double-quoted string, we used to use a custom
function to find the end of it (taking interpolations and interpolations
within interpolations etc. into account). Then we used to re-find the
interpolations and recursively lex their contents. In effect, the same string
was processed twice, or even more in the case of deeper nesting of
interpolations. Now the same string is processed just once.
- Code duplication between regular strings, heredocs, regular regexes and
heregexes has been reduced.
- The above two points should result in more easily read code, too.
2015-01-03 17:40:43 -05:00
|
|
|
return (err.toString()) + "\n" + (frames.join('\n')) + "\n";
|
2013-07-30 00:06:41 -04:00
|
|
|
};
|
|
|
|
|
2010-09-21 03:53:58 -04:00
|
|
|
}).call(this);
|