Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 8 commits
  • 1,037 files changed
  • 0 commit comments
  • 1 contributor
Showing with 6,272 additions and 3,400 deletions.
  1. +6 −0 CoffeeScript.lrplugin/manifest.json
  2. +2 −2 CoffeeScript.lrplugin/node_modules/coffee-script/LICENSE
  3. +1 −0 CoffeeScript.lrplugin/node_modules/coffee-script/Rakefile
  4. +46 −13 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/browser.js
  5. +8 −3 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/cake.js
  6. +221 −50 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/coffee-script.js
  7. +126 −70 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/command.js
  8. +34 −15 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/grammar.js
  9. +151 −3 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/helpers.js
  10. +1 −1 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/index.js
  11. +204 −78 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/lexer.js
  12. +830 −656 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/nodes.js
  13. +6 −2 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/optparse.js
  14. +273 −348 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/parser.js
  15. +90 −251 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/repl.js
  16. +267 −107 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/rewriter.js
  17. +9 −3 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/scope.js
  18. +248 −0 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/sourcemap.js
  19. +8 −6 CoffeeScript.lrplugin/node_modules/coffee-script/package.json
  20. +36 −3 CoffeeScript.lrplugin/scripts/compile-coffeescript.iced
  21. +65 −15 CoffeeScript.lrplugin/scripts/compile-coffeescript.js
  22. +2 −2 CoffeeScript.lrplugin/versions.json
  23. +19 −7 HAML.lrplugin/lib/haml/.yardopts
  24. +1,316 −0 HAML.lrplugin/lib/haml/CHANGELOG.md
  25. +0 −3 HAML.lrplugin/lib/haml/CONTRIBUTING
  26. +158 −0 HAML.lrplugin/lib/haml/FAQ.md
  27. +103 −63 HAML.lrplugin/lib/haml/README.md
  28. +1,250 −0 HAML.lrplugin/lib/haml/REFERENCE.md
  29. +0 −1 HAML.lrplugin/lib/haml/REVISION
  30. +56 −341 HAML.lrplugin/lib/haml/Rakefile
  31. +0 −1 HAML.lrplugin/lib/haml/VERSION
  32. +0 −1 HAML.lrplugin/lib/haml/VERSION_NAME
  33. +0 −7 HAML.lrplugin/lib/haml/bin/html2haml
  34. +0 −13 HAML.lrplugin/lib/haml/extra/update_watch.rb
  35. +0 −18 HAML.lrplugin/lib/haml/init.rb
  36. +9 −33 HAML.lrplugin/lib/haml/lib/haml.rb
  37. +66 −22 HAML.lrplugin/lib/haml/lib/haml/buffer.rb
  38. +126 −38 HAML.lrplugin/lib/haml/lib/haml/compiler.rb
  39. +47 −114 HAML.lrplugin/lib/haml/lib/haml/engine.rb
  40. +40 −1 HAML.lrplugin/lib/haml/lib/haml/error.rb
  41. +40 −73 HAML.lrplugin/lib/haml/lib/haml/exec.rb
  42. +188 −169 HAML.lrplugin/lib/haml/lib/haml/filters.rb
  43. +58 −23 HAML.lrplugin/lib/haml/lib/haml/helpers.rb
  44. +2 −1 HAML.lrplugin/lib/haml/lib/haml/helpers/action_view_extensions.rb
  45. +80 −186 HAML.lrplugin/lib/haml/lib/haml/helpers/action_view_mods.rb
  46. +58 −0 HAML.lrplugin/lib/haml/lib/haml/helpers/action_view_xss_mods.rb
  47. +0 −41 HAML.lrplugin/lib/haml/lib/haml/helpers/rails_323_textarea_fix.rb
  48. +20 −0 HAML.lrplugin/lib/haml/lib/haml/helpers/safe_erubis_template.rb
  49. +2 −63 HAML.lrplugin/lib/haml/lib/haml/helpers/xss_mods.rb
  50. +0 −412 HAML.lrplugin/lib/haml/lib/haml/html.rb
  51. +0 −141 HAML.lrplugin/lib/haml/lib/haml/html/erb.rb
Sorry, we could not display the entire diff because too many files (1,037) changed.
View
6 CoffeeScript.lrplugin/manifest.json
@@ -28,6 +28,12 @@
"Type": "checkbox",
"Title": "No wrapper (--bare)",
"OnArgument": "--bare"
+ },
+ {
+ "Id": "source-map",
+ "Type": "checkbox",
+ "Title": "Generate source map (--map)",
+ "OnArgument": "--map"
}
]
}
View
4 CoffeeScript.lrplugin/node_modules/coffee-script/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009-2012 Jeremy Ashkenas
+Copyright (c) 2009-2013 Jeremy Ashkenas
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@@ -19,4 +19,4 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
+OTHER DEALINGS IN THE SOFTWARE.
View
1 CoffeeScript.lrplugin/node_modules/coffee-script/Rakefile
@@ -49,6 +49,7 @@ task :gem do
s.authors = ['Jeremy Ashkenas']
s.email = 'jashkenas@gmail.com'
s.rubyforge_project = 'coffee-script-source'
+ s.license = "MIT"
end
file = File.open("coffee-script-source.gem", "w")
View
59 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/browser.js
@@ -1,46 +1,70 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
- var CoffeeScript, runScripts;
+ 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; };
CoffeeScript = require('./coffee-script');
CoffeeScript.require = require;
+ compile = CoffeeScript.compile;
+
CoffeeScript["eval"] = function(code, options) {
var _ref;
+
if (options == null) {
options = {};
}
if ((_ref = options.bare) == null) {
options.bare = true;
}
- return eval(CoffeeScript.compile(code, options));
+ return eval(compile(code, options));
};
CoffeeScript.run = function(code, options) {
if (options == null) {
options = {};
}
options.bare = true;
- return Function(CoffeeScript.compile(code, options))();
+ return Function(compile(code, options))();
};
if (typeof window === "undefined" || window === null) {
return;
}
- CoffeeScript.load = function(url, callback) {
+ if ((typeof btoa !== "undefined" && btoa !== null) && (typeof JSON !== "undefined" && JSON !== null)) {
+ compile = function(code, options) {
+ var js, v3SourceMap, _ref;
+
+ if (options == null) {
+ options = {};
+ }
+ options.sourceMap = true;
+ options.inline = true;
+ _ref = CoffeeScript.compile(code, options), js = _ref.js, v3SourceMap = _ref.v3SourceMap;
+ return "" + js + "\n//@ sourceMappingURL=data:application/json;base64," + (btoa(v3SourceMap)) + "\n//@ sourceURL=coffeescript";
+ };
+ }
+
+ CoffeeScript.load = function(url, callback, options) {
var xhr;
+
+ if (options == null) {
+ options = {};
+ }
+ options.sourceFiles = [url];
xhr = window.ActiveXObject ? new window.ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
xhr.open('GET', url, true);
if ('overrideMimeType' in xhr) {
xhr.overrideMimeType('text/plain');
}
xhr.onreadystatechange = function() {
var _ref;
+
if (xhr.readyState === 4) {
if ((_ref = xhr.status) === 0 || _ref === 200) {
- CoffeeScript.run(xhr.responseText);
+ CoffeeScript.run(xhr.responseText, options);
} else {
throw new Error("Could not load " + url);
}
@@ -53,14 +77,17 @@
};
runScripts = function() {
- var coffees, execute, index, length, s, scripts;
+ var coffees, coffeetypes, execute, index, length, s, scripts;
+
scripts = document.getElementsByTagName('script');
+ coffeetypes = ['text/coffeescript', 'text/literate-coffeescript'];
coffees = (function() {
- var _i, _len, _results;
+ var _i, _len, _ref, _results;
+
_results = [];
for (_i = 0, _len = scripts.length; _i < _len; _i++) {
s = scripts[_i];
- if (s.type === 'text/coffeescript') {
+ if (_ref = s.type, __indexOf.call(coffeetypes, _ref) >= 0) {
_results.push(s);
}
}
@@ -69,13 +96,19 @@
index = 0;
length = coffees.length;
(execute = function() {
- var script;
+ var mediatype, options, script;
+
script = coffees[index++];
- if ((script != null ? script.type : void 0) === 'text/coffeescript') {
+ mediatype = script != null ? script.type : void 0;
+ if (__indexOf.call(coffeetypes, mediatype) >= 0) {
+ options = {
+ literate: mediatype === 'text/literate-coffeescript'
+ };
if (script.src) {
- return CoffeeScript.load(script.src, execute);
+ return CoffeeScript.load(script.src, execute, options);
} else {
- CoffeeScript.run(script.innerHTML);
+ options.sourceFiles = ['embedded'];
+ CoffeeScript.run(script.innerHTML, options);
return execute();
}
}
View
11 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/cake.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
var CoffeeScript, cakefileDirectory, existsSync, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
@@ -25,6 +25,7 @@
helpers.extend(global, {
task: function(name, description, action) {
var _ref;
+
if (!action) {
_ref = [description, action], action = _ref[0], description = _ref[1];
}
@@ -46,7 +47,8 @@
});
exports.run = function() {
- var arg, args, _i, _len, _ref, _results;
+ var arg, args, e, _i, _len, _ref, _results;
+
global.__originalDirname = fs.realpathSync('.');
process.chdir(cakefileDirectory(__originalDirname));
args = process.argv.slice(2);
@@ -59,7 +61,8 @@
}
try {
options = oparse.parse(args);
- } catch (e) {
+ } catch (_error) {
+ e = _error;
return fatalError("" + e);
}
_ref = options["arguments"];
@@ -73,6 +76,7 @@
printTasks = function() {
var cakefilePath, desc, name, relative, spaces, task;
+
relative = path.relative || path.resolve;
cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
console.log("" + cakefilePath + " defines the following tasks:\n");
@@ -100,6 +104,7 @@
cakefileDirectory = function(dir) {
var parent;
+
if (existsSync(path.join(dir, 'Cakefile'))) {
return dir;
}
View
271 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/coffee-script.js
@@ -1,61 +1,75 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
- var Lexer, RESERVED, compile, fs, lexer, parser, path, stripBOM, vm, _ref,
+ var Lexer, child_process, compile, ext, fork, formatSourcePosition, fs, helpers, lexer, loadFile, parser, patchStackTrace, patched, path, sourcemap, vm, _i, _len, _ref,
__hasProp = {}.hasOwnProperty;
fs = require('fs');
+ vm = require('vm');
+
path = require('path');
- _ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
+ child_process = require('child_process');
+
+ Lexer = require('./lexer').Lexer;
parser = require('./parser').parser;
- vm = require('vm');
+ helpers = require('./helpers');
- stripBOM = function(content) {
- if (content.charCodeAt(0) === 0xFEFF) {
- return content.substring(1);
- } else {
- return content;
- }
- };
+ sourcemap = require('./sourcemap');
- if (require.extensions) {
- require.extensions['.coffee'] = function(module, filename) {
- var content;
- content = compile(stripBOM(fs.readFileSync(filename, 'utf8')), {
- filename: filename
- });
- return module._compile(content, filename);
- };
- }
+ exports.VERSION = '1.6.2';
- exports.VERSION = '1.4.0';
-
- exports.RESERVED = RESERVED;
-
- exports.helpers = require('./helpers');
+ exports.helpers = helpers;
exports.compile = compile = function(code, options) {
- var header, js, merge;
+ var answer, currentColumn, currentLine, fragment, fragments, header, js, merge, newLines, sourceMap, _i, _len;
+
if (options == null) {
options = {};
}
merge = exports.helpers.merge;
- try {
- js = (parser.parse(lexer.tokenize(code))).compile(options);
- if (!options.header) {
- return js;
+ if (options.sourceMap) {
+ sourceMap = new sourcemap.SourceMap();
+ }
+ fragments = (parser.parse(lexer.tokenize(code, options))).compileToFragments(options);
+ currentLine = 0;
+ if (options.header || options.inline) {
+ currentLine += 1;
+ }
+ currentColumn = 0;
+ js = "";
+ for (_i = 0, _len = fragments.length; _i < _len; _i++) {
+ fragment = fragments[_i];
+ if (sourceMap) {
+ if (fragment.locationData) {
+ sourceMap.addMapping([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
+ noReplace: true
+ });
+ }
+ newLines = helpers.count(fragment.code, "\n");
+ currentLine += newLines;
+ currentColumn = fragment.code.length - (newLines ? fragment.code.lastIndexOf("\n") : 0);
}
- } catch (err) {
- if (options.filename) {
- err.message = "In " + options.filename + ", " + err.message;
+ js += fragment.code;
+ }
+ if (options.header) {
+ header = "Generated by CoffeeScript " + this.VERSION;
+ js = "// " + header + "\n" + js;
+ }
+ if (options.sourceMap) {
+ answer = {
+ js: js
+ };
+ if (sourceMap) {
+ answer.sourceMap = sourceMap;
+ answer.v3SourceMap = sourcemap.generateV3SourceMap(sourceMap, options, code);
}
- throw err;
+ return answer;
+ } else {
+ return js;
}
- header = "Generated by CoffeeScript " + this.VERSION;
- return "// " + header + "\n" + js;
};
exports.tokens = function(code, options) {
@@ -71,23 +85,31 @@
};
exports.run = function(code, options) {
- var mainModule;
+ var answer, mainModule, _ref;
+
if (options == null) {
options = {};
}
mainModule = require.main;
+ if ((_ref = options.sourceMap) == null) {
+ options.sourceMap = true;
+ }
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
mainModule.moduleCache && (mainModule.moduleCache = {});
- mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename)));
- if (path.extname(mainModule.filename) !== '.coffee' || require.extensions) {
- return mainModule._compile(compile(code, options), mainModule.filename);
+ mainModule.paths = require('module')._nodeModulePaths(path.dirname(fs.realpathSync(options.filename || '.')));
+ if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
+ answer = compile(code, options);
+ patchStackTrace();
+ mainModule._sourceMaps[mainModule.filename] = answer.sourceMap;
+ return mainModule._compile(answer.js, mainModule.filename);
} else {
return mainModule._compile(code, mainModule.filename);
}
};
exports["eval"] = function(code, options) {
- var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref1, _ref2, _require;
+ var Module, Script, js, k, o, r, sandbox, v, _i, _len, _module, _ref, _ref1, _require;
+
if (options == null) {
options = {};
}
@@ -101,10 +123,10 @@
sandbox = options.sandbox;
} else {
sandbox = Script.createContext();
- _ref1 = options.sandbox;
- for (k in _ref1) {
- if (!__hasProp.call(_ref1, k)) continue;
- v = _ref1[k];
+ _ref = options.sandbox;
+ for (k in _ref) {
+ if (!__hasProp.call(_ref, k)) continue;
+ v = _ref[k];
sandbox[k] = v;
}
}
@@ -121,9 +143,9 @@
return Module._load(path, _module, true);
};
_module.filename = sandbox.__filename;
- _ref2 = Object.getOwnPropertyNames(require);
- for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
- r = _ref2[_i];
+ _ref1 = Object.getOwnPropertyNames(require);
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
+ r = _ref1[_i];
if (r !== 'paths') {
_require[r] = require[r];
}
@@ -149,12 +171,59 @@
}
};
+ loadFile = function(module, filename) {
+ var raw, stripped;
+
+ raw = fs.readFileSync(filename, 'utf8');
+ stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
+ return module._compile(compile(stripped, {
+ filename: filename,
+ literate: helpers.isLiterate(filename)
+ }), filename);
+ };
+
+ if (require.extensions) {
+ _ref = ['.coffee', '.litcoffee', '.coffee.md'];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ ext = _ref[_i];
+ require.extensions[ext] = loadFile;
+ }
+ }
+
+ if (child_process) {
+ fork = child_process.fork;
+ child_process.fork = function(path, args, options) {
+ var execPath;
+
+ if (args == null) {
+ args = [];
+ }
+ if (options == null) {
+ options = {};
+ }
+ execPath = helpers.isCoffee(path) ? 'coffee' : null;
+ if (!Array.isArray(args)) {
+ args = [];
+ options = args || {};
+ }
+ options.execPath || (options.execPath = execPath);
+ return fork(path, args, options);
+ };
+ }
+
lexer = new Lexer;
parser.lexer = {
lex: function() {
- var tag, _ref1;
- _ref1 = this.tokens[this.pos++] || [''], tag = _ref1[0], this.yytext = _ref1[1], this.yylineno = _ref1[2];
+ var tag, token;
+
+ token = this.tokens[this.pos++];
+ if (token) {
+ tag = token[0], this.yytext = token[1], this.yylloc = token[2];
+ this.yylineno = this.yylloc.first_line;
+ } else {
+ tag = '';
+ }
return tag;
},
setInput: function(tokens) {
@@ -168,4 +237,106 @@
parser.yy = require('./nodes');
+ parser.yy.parseError = function(message, _arg) {
+ var token;
+
+ token = _arg.token;
+ message = "unexpected " + (token === 1 ? 'end of input' : token);
+ return helpers.throwSyntaxError(message, parser.lexer.yylloc);
+ };
+
+ patched = false;
+
+ patchStackTrace = function() {
+ var mainModule;
+
+ if (patched) {
+ return;
+ }
+ patched = true;
+ mainModule = require.main;
+ mainModule._sourceMaps = {};
+ return Error.prepareStackTrace = function(err, stack) {
+ var frame, frames, getSourceMapping, sourceFiles, _ref1;
+
+ sourceFiles = {};
+ getSourceMapping = function(filename, line, column) {
+ var answer, sourceMap;
+
+ sourceMap = mainModule._sourceMaps[filename];
+ if (sourceMap) {
+ answer = sourceMap.getSourcePosition([line - 1, column - 1]);
+ }
+ if (answer) {
+ return [answer[0] + 1, answer[1] + 1];
+ } else {
+ return null;
+ }
+ };
+ frames = (function() {
+ 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)));
+ }
+ return _results;
+ })();
+ return "" + err.name + ": " + ((_ref1 = err.message) != null ? _ref1 : '') + "\n" + (frames.join('\n')) + "\n";
+ };
+ };
+
+ 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) {
+ fileLocation = "" + (frame.getEvalOrigin()) + ", ";
+ }
+ } else {
+ fileName = frame.getFileName();
+ }
+ fileName || (fileName = "<anonymous>");
+ line = frame.getLineNumber();
+ column = frame.getColumnNumber();
+ source = getSourceMapping(fileName, line, column);
+ fileLocation = source ? "" + fileName + ":" + source[0] + ":" + source[1] + ", <js>:" + line + ":" + column : "" + fileName + ":" + line + ":" + column;
+ }
+ 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)) {
+ tp = "" + typeName + ".";
+ }
+ if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) {
+ as = " [as " + methodName + "]";
+ }
+ return "" + tp + functionName + as + " (" + fileLocation + ")";
+ } else {
+ return "" + typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")";
+ }
+ } else if (isConstructor) {
+ return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")";
+ } else if (functionName) {
+ return "" + functionName + " (" + fileLocation + ")";
+ } else {
+ return fileLocation;
+ }
+ };
+
}).call(this);
View
196 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/command.js
@@ -1,6 +1,6 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
- var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, loadRequires, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
+ var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, exists, forkNode, fs, helpers, hidden, joinTimeout, lint, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, removeSource, sourceCode, sources, spawn, timeLog, unwatchDir, usage, version, wait, watch, watchDir, watchers, writeJs, _ref;
fs = require('fs');
@@ -34,7 +34,7 @@
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
- SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-r', '--require [FILE*]', 'require a library before executing your script'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
+ SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-l', '--lint', 'pipe the compiled JavaScript through JavaScript Lint'], ['-m', '--map', 'generate source map and save as .map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
opts = {};
@@ -50,6 +50,7 @@
exports.run = function() {
var literals, source, _i, _len, _results;
+
parseOptions();
if (opts.nodejs) {
return forkNode();
@@ -60,11 +61,8 @@
if (opts.version) {
return version();
}
- if (opts.require) {
- loadRequires();
- }
if (opts.interactive) {
- return require('./repl');
+ return require('./repl').start();
}
if (opts.watch && !fs.watch) {
return printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + ".");
@@ -76,12 +74,11 @@
return compileScript(null, sources[0]);
}
if (!sources.length) {
- return require('./repl');
+ return require('./repl').start();
}
literals = opts.run ? sources.splice(1) : [];
process.argv = process.argv.slice(0, 2).concat(literals);
process.argv[0] = 'coffee';
- process.execPath = require.main.filename;
_results = [];
for (_i = 0, _len = sources.length; _i < _len; _i++) {
source = sources[_i];
@@ -96,22 +93,16 @@
throw err;
}
if ((err != null ? err.code : void 0) === 'ENOENT') {
- if (topLevel && source.slice(-7) !== '.coffee') {
- source = sources[sources.indexOf(source)] = "" + source + ".coffee";
- return compilePath(source, topLevel, base);
- }
- if (topLevel) {
- console.error("File not found: " + source);
- process.exit(1);
- }
- return;
+ console.error("File not found: " + source);
+ process.exit(1);
}
- if (stats.isDirectory()) {
+ if (stats.isDirectory() && path.dirname(source) !== 'node_modules') {
if (opts.watch) {
watchDir(source, base);
}
return fs.readdir(source, function(err, files) {
var file, index, _ref1, _ref2;
+
if (err && err.code !== 'ENOENT') {
throw err;
}
@@ -124,6 +115,7 @@
});
[].splice.apply(sources, [index, index - index + 1].concat(_ref1 = (function() {
var _i, _len, _results;
+
_results = [];
for (_i = 0, _len = files.length; _i < _len; _i++) {
file = files[_i];
@@ -138,7 +130,7 @@
return compilePath(path.join(source, file), false, base);
});
});
- } else if (topLevel || path.extname(source) === '.coffee') {
+ } else if (topLevel || helpers.isCoffee(source)) {
if (opts.watch) {
watch(source, base);
}
@@ -159,9 +151,13 @@
};
compileScript = function(file, input, base) {
- var o, options, t, task;
+ var compiled, err, message, o, options, t, task, useColors;
+
+ if (base == null) {
+ base = null;
+ }
o = opts;
- options = compileOptions(file);
+ options = compileOptions(file, base);
try {
t = task = {
file: file,
@@ -170,40 +166,53 @@
};
CoffeeScript.emit('compile', task);
if (o.tokens) {
- return printTokens(CoffeeScript.tokens(t.input));
+ return printTokens(CoffeeScript.tokens(t.input, t.options));
} else if (o.nodes) {
- return printLine(CoffeeScript.nodes(t.input).toString().trim());
+ return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
} else if (o.run) {
return CoffeeScript.run(t.input, t.options);
} else if (o.join && t.file !== o.join) {
+ if (helpers.isLiterate(file)) {
+ t.input = helpers.invertLiterate(t.input);
+ }
sourceCode[sources.indexOf(t.file)] = t.input;
return compileJoin();
} else {
- t.output = CoffeeScript.compile(t.input, t.options);
+ compiled = CoffeeScript.compile(t.input, t.options);
+ t.output = compiled;
+ if (o.map) {
+ t.output = compiled.js;
+ t.sourceMap = compiled.v3SourceMap;
+ }
CoffeeScript.emit('success', task);
if (o.print) {
return printLine(t.output.trim());
- } else if (o.compile) {
- return writeJs(t.file, t.output, base);
+ } else if (o.compile || o.map) {
+ return writeJs(base, t.file, t.output, options.jsPath, t.sourceMap);
} else if (o.lint) {
return lint(t.file, t.output);
}
}
- } catch (err) {
+ } catch (_error) {
+ err = _error;
CoffeeScript.emit('failure', err, task);
if (CoffeeScript.listeners('failure').length) {
return;
}
+ useColors = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
+ message = helpers.prettyErrorMessage(err, file || '[stdin]', input, useColors);
if (o.watch) {
- return printLine(err.message + '\x07');
+ return printLine(message + '\x07');
+ } else {
+ printWarn(message);
+ return process.exit(1);
}
- printWarn(err instanceof Error && err.stack || ("ERROR: " + err));
- return process.exit(1);
}
};
compileStdio = function() {
var code, stdin;
+
code = '';
stdin = process.openStdin();
stdin.on('data', function(buffer) {
@@ -232,20 +241,9 @@
}
};
- loadRequires = function() {
- var realFilename, req, _i, _len, _ref1;
- realFilename = module.filename;
- module.filename = '.';
- _ref1 = opts.require;
- for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
- req = _ref1[_i];
- require(req);
- }
- return module.filename = realFilename;
- };
-
watch = function(source, base) {
- var compile, compileTimeout, prevStats, rewatch, watchErr, watcher;
+ var compile, compileTimeout, e, prevStats, rewatch, watchErr, watcher;
+
prevStats = null;
compileTimeout = null;
watchErr = function(e) {
@@ -256,7 +254,8 @@
try {
rewatch();
return compile();
- } catch (e) {
+ } catch (_error) {
+ e = _error;
removeSource(source, base, true);
return compileJoin();
}
@@ -287,7 +286,8 @@
};
try {
watcher = fs.watch(source, compile);
- } catch (e) {
+ } catch (_error) {
+ e = _error;
watchErr(e);
}
return rewatch = function() {
@@ -299,14 +299,16 @@
};
watchDir = function(source, base) {
- var readdirTimeout, watcher;
+ var e, readdirTimeout, watcher;
+
readdirTimeout = null;
try {
return watcher = fs.watch(source, function() {
clearTimeout(readdirTimeout);
return readdirTimeout = wait(25, function() {
return fs.readdir(source, function(err, files) {
var file, _i, _len, _results;
+
if (err) {
if (err.code !== 'ENOENT') {
throw err;
@@ -334,7 +336,8 @@
});
});
});
- } catch (e) {
+ } catch (_error) {
+ e = _error;
if (e.code !== 'ENOENT') {
throw e;
}
@@ -343,9 +346,11 @@
unwatchDir = function(source, base) {
var file, prevSources, toRemove, _i, _len;
+
prevSources = sources.slice(0);
toRemove = (function() {
var _i, _len, _results;
+
_results = [];
for (_i = 0, _len = sources.length; _i < _len; _i++) {
file = sources[_i];
@@ -369,6 +374,7 @@
removeSource = function(source, base, removeJs) {
var index, jsPath;
+
index = sources.indexOf(source);
sources.splice(index, 1);
sourceCode.splice(index, 1);
@@ -387,30 +393,50 @@
}
};
- outputPath = function(source, base) {
- var baseDir, dir, filename, srcDir;
- filename = path.basename(source, path.extname(source)) + '.js';
+ outputPath = function(source, base, extension) {
+ var baseDir, basename, dir, srcDir;
+
+ if (extension == null) {
+ extension = ".js";
+ }
+ basename = helpers.baseFileName(source, true, path.sep);
srcDir = path.dirname(source);
baseDir = base === '.' ? srcDir : srcDir.substring(base.length);
dir = opts.output ? path.join(opts.output, baseDir) : srcDir;
- return path.join(dir, filename);
+ return path.join(dir, basename + extension);
};
- writeJs = function(source, js, base) {
- var compile, jsDir, jsPath;
- jsPath = outputPath(source, base);
+ writeJs = function(base, sourcePath, js, jsPath, generatedSourceMap) {
+ var compile, jsDir, sourceMapPath;
+
+ if (generatedSourceMap == null) {
+ generatedSourceMap = null;
+ }
+ sourceMapPath = outputPath(sourcePath, base, ".map");
jsDir = path.dirname(jsPath);
compile = function() {
- if (js.length <= 0) {
- js = ' ';
- }
- return fs.writeFile(jsPath, js, function(err) {
- if (err) {
- return printLine(err.message);
- } else if (opts.compile && opts.watch) {
- return timeLog("compiled " + source);
+ if (opts.compile) {
+ if (js.length <= 0) {
+ js = ' ';
}
- });
+ if (generatedSourceMap) {
+ js = "" + js + "\n/*\n//@ sourceMappingURL=" + (helpers.baseFileName(sourceMapPath, false, path.sep)) + "\n*/\n";
+ }
+ fs.writeFile(jsPath, js, function(err) {
+ if (err) {
+ return printLine(err.message);
+ } else if (opts.compile && opts.watch) {
+ return timeLog("compiled " + sourcePath);
+ }
+ });
+ }
+ if (generatedSourceMap) {
+ return fs.writeFile(sourceMapPath, generatedSourceMap, function(err) {
+ if (err) {
+ return printLine("Could not write source map: " + err.message);
+ }
+ });
+ }
};
return exists(jsDir, function(itExists) {
if (itExists) {
@@ -431,6 +457,7 @@
lint = function(file, js) {
var conf, jsl, printIt;
+
printIt = function(buffer) {
return printLine(file + ':\t' + buffer.toString().trim());
};
@@ -444,12 +471,15 @@
printTokens = function(tokens) {
var strings, tag, token, value;
+
strings = (function() {
- var _i, _len, _ref1, _results;
+ var _i, _len, _results;
+
_results = [];
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
- _ref1 = [token[0], token[1].toString().replace(/\n/, '\\n')], tag = _ref1[0], value = _ref1[1];
+ tag = token[0];
+ value = token[1].toString().replace(/\n/, '\\n');
_results.push("[" + tag + " " + value + "]");
}
return _results;
@@ -459,10 +489,11 @@
parseOptions = function() {
var i, o, source, _i, _len;
+
optionParser = new optparse.OptionParser(SWITCHES, BANNER);
o = opts = optionParser.parse(process.argv.slice(2));
o.compile || (o.compile = !!o.output);
- o.run = !(o.compile || o.print || o.lint);
+ o.run = !(o.compile || o.print || o.lint || o.map);
o.print = !!(o.print || (o["eval"] || o.stdio && o.compile));
sources = o["arguments"];
for (i = _i = 0, _len = sources.length; _i < _len; i = ++_i) {
@@ -471,16 +502,41 @@
}
};
- compileOptions = function(filename) {
- return {
+ compileOptions = function(filename, base) {
+ var answer, cwd, jsDir, jsPath;
+
+ answer = {
filename: filename,
+ literate: helpers.isLiterate(filename),
bare: opts.bare,
- header: opts.compile
+ header: opts.compile,
+ sourceMap: opts.map
};
+ if (filename) {
+ if (base) {
+ cwd = process.cwd();
+ jsPath = outputPath(filename, base);
+ jsDir = path.dirname(jsPath);
+ answer = helpers.merge(answer, {
+ jsPath: jsPath,
+ sourceRoot: path.relative(jsDir, cwd),
+ sourceFiles: [path.relative(cwd, filename)],
+ generatedFile: helpers.baseFileName(jsPath, false, path.sep)
+ });
+ } else {
+ answer = helpers.merge(answer, {
+ sourceRoot: "",
+ sourceFiles: [helpers.baseFileName(filename, false, path.sep)],
+ generatedFile: helpers.baseFileName(filename, true, path.sep) + ".js"
+ });
+ }
+ }
+ return answer;
};
forkNode = function() {
var args, nodeArgs;
+
nodeArgs = opts.nodejs.split(/\s+/);
args = process.argv.slice(1);
args.splice(args.indexOf('--nodejs'), 2);
View
49 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/grammar.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
@@ -7,15 +7,26 @@
unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
o = function(patternString, action, options) {
- var match;
+ var addLocationDataFn, match, patternCount;
+
patternString = patternString.replace(/\s{2,}/g, ' ');
+ patternCount = patternString.split(' ').length;
if (!action) {
return [patternString, '$$ = $1;', options];
}
action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
action = action.replace(/\bnew /g, '$&yy.');
action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
- return [patternString, "$$ = " + action + ";", options];
+ addLocationDataFn = function(first, last) {
+ if (!last) {
+ return "yy.addLocationDataFn(@" + first + ")";
+ } else {
+ return "yy.addLocationDataFn(@" + first + ", @" + last + ")";
+ }
+ };
+ action = action.replace(/LOC\(([0-9]*)\)/g, addLocationDataFn('$1'));
+ action = action.replace(/LOC\(([0-9]*),\s*([0-9]*)\)/g, addLocationDataFn('$1', '$2'));
+ return [patternString, "$$ = " + (addLocationDataFn(1, patternCount)) + "(" + action + ");", options];
};
grammar = {
@@ -85,10 +96,10 @@
o('ObjAssignable', function() {
return new Value($1);
}), o('ObjAssignable : Expression', function() {
- return new Assign(new Value($1), $3, 'object');
+ return new Assign(LOC(1)(new Value($1)), $3, 'object');
}), o('ObjAssignable :\
INDENT Expression OUTDENT', function() {
- return new Assign(new Value($1), $4, 'object');
+ return new Assign(LOC(1)(new Value($1)), $4, 'object');
}), o('Comment')
],
ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
@@ -178,7 +189,9 @@
}), o('?. Identifier', function() {
return new Access($2, 'soak');
}), o(':: Identifier', function() {
- return [new Access(new Literal('prototype')), new Access($2)];
+ return [LOC(1)(new Access(new Literal('prototype'))), LOC(2)(new Access($2))];
+ }), o('?:: Identifier', function() {
+ return [LOC(1)(new Access(new Literal('prototype'), 'soak')), LOC(2)(new Access($2))];
}), o('::', function() {
return new Access(new Literal('prototype'));
}), o('Index')
@@ -270,7 +283,7 @@
],
ThisProperty: [
o('@ Identifier', function() {
- return new Value(new Literal('this'), [new Access($2)], 'this');
+ return new Value(LOC(1)(new Literal('this')), [LOC(2)(new Access($2))], 'this');
})
],
Array: [
@@ -336,6 +349,8 @@
Catch: [
o('CATCH Identifier Block', function() {
return [$2, $3];
+ }), o('CATCH Object Block', function() {
+ return [LOC(2)(new Value($2)), $3];
})
],
Throw: [
@@ -372,18 +387,18 @@
o('WhileSource Block', function() {
return $1.addBody($2);
}), o('Statement WhileSource', function() {
- return $2.addBody(Block.wrap([$1]));
+ return $2.addBody(LOC(1)(Block.wrap([$1])));
}), o('Expression WhileSource', function() {
- return $2.addBody(Block.wrap([$1]));
+ return $2.addBody(LOC(1)(Block.wrap([$1])));
}), o('Loop', function() {
return $1;
})
],
Loop: [
o('LOOP Block', function() {
- return new While(new Literal('true')).addBody($2);
+ return new While(LOC(1)(new Literal('true'))).addBody($2);
}), o('LOOP Expression', function() {
- return new While(new Literal('true')).addBody(Block.wrap([$2]));
+ return new While(LOC(1)(new Literal('true'))).addBody(LOC(2)(Block.wrap([$2])));
})
],
For: [
@@ -398,7 +413,7 @@
ForBody: [
o('FOR Range', function() {
return {
- source: new Value($2)
+ source: LOC(2)(new Value($2))
};
}), o('ForStart ForSource', function() {
$2.own = $1.own;
@@ -507,12 +522,12 @@
o('IfBlock'), o('IfBlock ELSE Block', function() {
return $1.addElse($3);
}), o('Statement POST_IF Expression', function() {
- return new If($3, Block.wrap([$1]), {
+ return new If($3, LOC(1)(Block.wrap([$1])), {
type: $2,
statement: true
});
}), o('Expression POST_IF Expression', function() {
- return new If($3, Block.wrap([$1]), {
+ return new If($3, LOC(1)(Block.wrap([$1])), {
type: $2,
statement: true
});
@@ -563,20 +578,24 @@
}), o('SimpleAssignable COMPOUND_ASSIGN\
INDENT Expression OUTDENT', function() {
return new Assign($1, $4, $2);
+ }), o('SimpleAssignable COMPOUND_ASSIGN TERMINATOR\
+ Expression', function() {
+ return new Assign($1, $4, $2);
}), o('SimpleAssignable EXTENDS Expression', function() {
return new Extends($1, $3);
})
]
};
- operators = [['left', '.', '?.', '::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];
+ operators = [['left', '.', '?.', '::', '?::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];
tokens = [];
for (name in grammar) {
alternatives = grammar[name];
grammar[name] = (function() {
var _i, _j, _len, _len1, _ref, _results;
+
_results = [];
for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
alt = alternatives[_i];
View
154 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/helpers.js
@@ -1,19 +1,35 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
- var extend, flatten, _ref;
+ var buildLocationData, extend, flatten, last, repeat, _ref;
exports.starts = function(string, literal, start) {
return literal === string.substr(start, literal.length);
};
exports.ends = function(string, literal, back) {
var len;
+
len = literal.length;
return literal === string.substr(string.length - len - (back || 0), len);
};
+ exports.repeat = repeat = function(str, n) {
+ var res;
+
+ res = '';
+ while (n > 0) {
+ if (n & 1) {
+ res += str;
+ }
+ n >>>= 1;
+ str += str;
+ }
+ return res;
+ };
+
exports.compact = function(array) {
var item, _i, _len, _results;
+
_results = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
item = array[_i];
@@ -26,6 +42,7 @@
exports.count = function(string, substr) {
var num, pos;
+
num = pos = 0;
if (!substr.length) {
return 1 / 0;
@@ -42,6 +59,7 @@
extend = exports.extend = function(object, properties) {
var key, val;
+
for (key in properties) {
val = properties[key];
object[key] = val;
@@ -51,6 +69,7 @@
exports.flatten = flatten = function(array) {
var element, flattened, _i, _len;
+
flattened = [];
for (_i = 0, _len = array.length; _i < _len; _i++) {
element = array[_i];
@@ -65,17 +84,19 @@
exports.del = function(obj, key) {
var val;
+
val = obj[key];
delete obj[key];
return val;
};
- exports.last = function(array, back) {
+ 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];
if (fn(e)) {
@@ -85,4 +106,131 @@
return false;
};
+ exports.invertLiterate = function(code) {
+ var line, lines, maybe_code;
+
+ maybe_code = 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];
+ if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
+ _results.push(line);
+ } else if (maybe_code = /^\s*$/.test(line)) {
+ _results.push(line);
+ } else {
+ _results.push('# ' + line);
+ }
+ }
+ return _results;
+ })();
+ return lines.join('\n');
+ };
+
+ buildLocationData = function(first, last) {
+ if (!last) {
+ return first;
+ } else {
+ return {
+ first_line: first.first_line,
+ first_column: first.first_column,
+ last_line: last.last_line,
+ last_column: last.last_column
+ };
+ }
+ };
+
+ exports.addLocationDataFn = function(first, last) {
+ return function(obj) {
+ if (((typeof obj) === 'object') && (!!obj['updateLocationDataIfMissing'])) {
+ obj.updateLocationDataIfMissing(buildLocationData(first, last));
+ }
+ return obj;
+ };
+ };
+
+ exports.locationDataToString = function(obj) {
+ var locationData;
+
+ if (("2" in obj) && ("first_line" in obj[2])) {
+ locationData = obj[2];
+ } else if ("first_line" in obj) {
+ locationData = obj;
+ }
+ if (locationData) {
+ return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1));
+ } else {
+ return "No location data";
+ }
+ };
+
+ exports.baseFileName = function(file, stripExt, pathSep) {
+ var parts;
+
+ if (stripExt == null) {
+ stripExt = false;
+ }
+ if (pathSep == null) {
+ pathSep = '/';
+ }
+ parts = file.split(pathSep);
+ file = parts[parts.length - 1];
+ if (!stripExt) {
+ return file;
+ }
+ parts = file.split('.');
+ parts.pop();
+ if (parts[parts.length - 1] === 'coffee' && parts.length > 1) {
+ parts.pop();
+ }
+ return parts.join('.');
+ };
+
+ exports.isCoffee = function(file) {
+ return /\.((lit)?coffee|coffee\.md)$/.test(file);
+ };
+
+ exports.isLiterate = function(file) {
+ return /\.(litcoffee|coffee\.md)$/.test(file);
+ };
+
+ exports.throwSyntaxError = function(message, location) {
+ var error, _ref1, _ref2;
+
+ if ((_ref1 = location.last_line) == null) {
+ location.last_line = location.first_line;
+ }
+ if ((_ref2 = location.last_column) == null) {
+ location.last_column = location.first_column;
+ }
+ error = new SyntaxError(message);
+ error.location = location;
+ throw error;
+ };
+
+ exports.prettyErrorMessage = function(error, fileName, code, useColors) {
+ var codeLine, colorize, end, first_column, first_line, last_column, last_line, marker, message, start, _ref1;
+
+ if (!error.location) {
+ return error.stack || ("" + error);
+ }
+ _ref1 = error.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column;
+ codeLine = code.split('\n')[first_line];
+ start = first_column;
+ end = first_line === last_line ? last_column + 1 : codeLine.length;
+ marker = repeat(' ', start) + repeat('^', end - start);
+ if (useColors) {
+ colorize = function(str) {
+ return "\x1B[1;31m" + str + "\x1B[0m";
+ };
+ codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
+ marker = colorize(marker);
+ }
+ message = "" + fileName + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + error.message + "\n" + codeLine + "\n" + marker;
+ return message;
+ };
+
}).call(this);
View
2 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/index.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
var key, val, _ref;
View
282 CoffeeScript.lrplugin/node_modules/coffee-script/lib/coffee-script/lexer.js
@@ -1,36 +1,36 @@
-// Generated by CoffeeScript 1.4.0
+// Generated by CoffeeScript 1.6.2
(function() {
- var BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, key, last, starts, _ref, _ref1,
+ var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, 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; };
_ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES;
- _ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last;
+ _ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
exports.Lexer = Lexer = (function() {
-
function Lexer() {}
Lexer.prototype.tokenize = function(code, opts) {
- var i, tag;
+ var consumed, i, tag, _ref2;
+
if (opts == null) {
opts = {};
}
- if (WHITESPACE.test(code)) {
- code = "\n" + code;
- }
- code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
- this.code = code;
- this.line = opts.line || 0;
+ this.literate = opts.literate;
this.indent = 0;
this.indebt = 0;
this.outdebt = 0;
this.indents = [];
this.ends = [];
this.tokens = [];
+ this.chunkLine = opts.line || 0;
+ this.chunkColumn = opts.column || 0;
+ code = this.clean(code);
i = 0;
while (this.chunk = code.slice(i)) {
- i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
+ consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
+ _ref2 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = _ref2[0], this.chunkColumn = _ref2[1];
+ i += consumed;
}
this.closeIndentation();
if (tag = this.ends.pop()) {
@@ -42,17 +42,35 @@
return (new Rewriter).rewrite(this.tokens);
};
+ Lexer.prototype.clean = function(code) {
+ if (code.charCodeAt(0) === BOM) {
+ code = code.slice(1);
+ }
+ code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
+ if (WHITESPACE.test(code)) {
+ code = "\n" + code;
+ this.chunkLine--;
+ }
+ if (this.literate) {
+ code = invertLiterate(code);
+ }
+ return code;
+ };
+
Lexer.prototype.identifierToken = function() {
- var colon, forcedIdentifier, id, input, match, prev, tag, _ref2, _ref3;
+ var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, tag, tagToken, _ref2, _ref3, _ref4;
+
if (!(match = IDENTIFIER.exec(this.chunk))) {
return 0;
}
input = match[0], id = match[1], colon = match[2];
+ idLength = id.length;
+ poppedToken = void 0;
if (id === 'own' && this.tag() === 'FOR') {
this.token('OWN', id);
return id.length;
}
- forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::') || !prev.spaced && prev[0] === '@');
+ forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::' || _ref2 === '?::') || !prev.spaced && prev[0] === '@');
tag = 'IDENTIFIER';
if (!forcedIdentifier && (__indexOf.call(JS_KEYWORDS, id) >= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) {
tag = id.toUpperCase();
@@ -71,7 +89,7 @@
} else {
tag = 'RELATION';
if (this.value() === '!') {
- this.tokens.pop();
+ poppedToken = this.tokens.pop();
id = '!' + id;
}
}
@@ -111,15 +129,20 @@
}
})();
}
- this.token(tag, id);
+ tagToken = this.token(tag, id, 0, idLength);
+ if (poppedToken) {
+ _ref4 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = _ref4[0], tagToken[2].first_column = _ref4[1];
+ }
if (colon) {
- this.token(':', ':');
+ colonOffset = input.lastIndexOf(':');
+ this.token(':', ':', colonOffset, colon.length);
}
return input.length;
};
Lexer.prototype.numberToken = function() {
var binaryLiteral, lexedLength, match, number, octalLiteral;
+
if (!(match = NUMBER.exec(this.chunk))) {
return 0;
}
@@ -140,27 +163,32 @@
if (binaryLiteral = /^0b([01]+)/.exec(number)) {
number = '0x' + (parseInt(binaryLiteral[1], 2)).toString(16);
}
- this.token('NUMBER', number);
+ this.token('NUMBER', number, 0, lexedLength);
return lexedLength;
};
Lexer.prototype.stringToken = function() {
var match, octalEsc, string;
+
switch (this.chunk.charAt(0)) {
case "'":
if (!(match = SIMPLESTR.exec(this.chunk))) {
return 0;
}
- this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
+ string = match[0];
+ this.token('STRING', string.replace(MULTILINER, '\\\n'), 0, string.length);
break;
case '"':
if (!(string = this.balancedString(this.chunk, '"'))) {
return 0;
}
if (0 < string.indexOf('#{', 1)) {
- this.interpolateString(string.slice(1, -1));
+ this.interpolateString(string.slice(1, -1), {
+ strOffset: 1,
+ lexedLength: string.length
+ });
} else {
- this.token('STRING', this.escapeLines(string));
+ this.token('STRING', this.escapeLines(string, 0, string.length));
}
break;
default:
@@ -169,12 +197,12 @@
if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
this.error("octal escape sequences " + string + " are not allowed");
}
- this.line += count(string, '\n');
return string.length;
};
Lexer.prototype.heredocToken = function() {
var doc, heredoc, match, quote;
+
if (!(match = HEREDOC.exec(this.chunk))) {
return 0;
}
@@ -186,17 +214,19 @@
});
if (quote === '"' && 0 <= doc.indexOf('#{')) {
this.interpolateString(doc, {
- heredoc: true
+ heredoc: true,
+ strOffset: 3,
+ lexedLength: heredoc.length
});
} else {
- this.token('STRING', this.makeString(doc, quote, true));
+ this.token('STRING', this.makeString(doc, quote, true), 0, heredoc.length);
}
- this.line += count(heredoc, '\n');
return heredoc.length;
};
Lexer.prototype.commentToken = function() {
var comment, here, match;
+
if (!(match = this.chunk.match(COMMENT))) {
return 0;
}
@@ -205,30 +235,29 @@
this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
herecomment: true,
indent: Array(this.indent + 1).join(' ')
- }));
+ }), 0, comment.length);
}
- this.line += count(comment, '\n');
return comment.length;
};
Lexer.prototype.jsToken = function() {
var match, script;
+
if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
return 0;
}
- this.token('JS', (script = match[0]).slice(1, -1));
- this.line += count(script, '\n');
+ this.token('JS', (script = match[0]).slice(1, -1), 0, script.length);
return script.length;
};
Lexer.prototype.regexToken = function() {
var flags, length, match, prev, regex, _ref2, _ref3;
+
if (this.chunk.charAt(0) !== '/') {
return 0;
}
if (match = HEREGEX.exec(this.chunk)) {
length = this.heregexToken(match);
- this.line += count(match[0], '\n');
return length;
}
prev = last(this.tokens);
@@ -245,67 +274,79 @@
if (regex === '//') {
regex = '/(?:)/';
}
- this.token('REGEX', "" + regex + flags);
+ this.token('REGEX', "" + regex + flags, 0, match.length);
return match.length;
};
Lexer.prototype.heregexToken = function(match) {
- var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref2, _ref3, _ref4, _ref5;
+ var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4;
+
heregex = match[0], body = match[1], flags = match[2];
if (0 > body.indexOf('#{')) {
re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
if (re.match(/^\*/)) {
this.error('regular expressions cannot begin with `*`');
}
- this.token('REGEX', "/" + (re || '(?:)') + "/" + flags);
+ this.token('REGEX', "/" + (re || '(?:)') + "/" + flags, 0, heregex.length);
return heregex.length;
}
- this.token('IDENTIFIER', 'RegExp');
- this.tokens.push(['CALL_START', '(']);
+ this.token('IDENTIFIER', 'RegExp', 0, 0);
+ this.token('CALL_START', '(', 0, 0);
tokens = [];
_ref2 = this.interpolateString(body, {
regex: true
});
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
- _ref3 = _ref2[_i], tag = _ref3[0], value = _ref3[1];
+ token = _ref2[_i];
+ tag = token[0], value = token[1];
if (tag === 'TOKENS') {
tokens.push.apply(tokens, value);
- } else {
+ } else if (tag === 'NEOSTRING') {
if (!(value = value.replace(HEREGEX_OMIT, ''))) {
continue;
}
value = value.replace(/\\/g, '\\\\');
- tokens.push(['STRING', this.makeString(value, '"', true)]);
+ token[0] = 'STRING';
+ token[1] = this.makeString(value, '"', true);
+ tokens.push(token);
+ } else {
+ this.error("Unexpected " + tag);
}
- tokens.push(['+', '+']);
+ prev = last(this.tokens);
+ plusToken = ['+', '+'];
+ plusToken[2] = prev[2];
+ tokens.push(plusToken);
}
tokens.pop();
- if (((_ref4 = tokens[0]) != null ? _ref4[0] : void 0) !== 'STRING') {
- this.tokens.push(['STRING', '""'], ['+', '+']);
+ if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') {
+ this.token('STRING', '""', 0, 0);
+ this.token('+', '+', 0, 0);
}
- (_ref5 = this.tokens).push.apply(_ref5, tokens);
+ (_ref4 = this.tokens).push.apply(_ref4, tokens);
if (flags) {
- this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
+ flagsOffset = heregex.lastIndexOf(flags);
+ this.token(',', ',', flagsOffset, 0);
+ this.token('STRING', '"' + flags + '"', flagsOffset, flags.length);
}
- this.token(')', ')');
+ this.token(')', ')', heregex.length - 1, 0);
return heregex.length;
};
Lexer.prototype.lineToken = function() {
var diff, indent, match, noNewlines, size;
+
if (!(match = MULTI_DENT.exec(this.chunk))) {
return 0;
}
indent = match[0];
- this.line += count(indent, '\n');
this.seenFor = false;
size = indent.length - 1 - indent.lastIndexOf('\n');
noNewlines = this.unfinished();