Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

built all the infrastructure for testing etc

  • Loading branch information...
commit fc0e2de7c041ca18c747542b7e486c9d0802a454 1 parent 220583d
@gnarmis authored
Showing with 59,115 additions and 0 deletions.
  1. 0  .gitignore
  2. +9 −0 README.md
  3. +417 −0 lib/edn.js
  4. +1 −0  node_modules/.bin/cake
  5. +1 −0  node_modules/.bin/coffee
  6. +1 −0  node_modules/.bin/jasmine-node
  7. +1 −0  node_modules/.bin/pegjs
  8. +11 −0 node_modules/coffee-script/.npmignore
  9. +1 −0  node_modules/coffee-script/CNAME
  10. +22 −0 node_modules/coffee-script/LICENSE
  11. +51 −0 node_modules/coffee-script/README
  12. +78 −0 node_modules/coffee-script/Rakefile
  13. +7 −0 node_modules/coffee-script/bin/cake
  14. +7 −0 node_modules/coffee-script/bin/coffee
  15. +44 −0 node_modules/coffee-script/extras/jsl.conf
  16. +92 −0 node_modules/coffee-script/lib/coffee-script/browser.js
  17. +111 −0 node_modules/coffee-script/lib/coffee-script/cake.js
  18. +167 −0 node_modules/coffee-script/lib/coffee-script/coffee-script.js
  19. +500 −0 node_modules/coffee-script/lib/coffee-script/command.js
  20. +606 −0 node_modules/coffee-script/lib/coffee-script/grammar.js
  21. +77 −0 node_modules/coffee-script/lib/coffee-script/helpers.js
  22. +11 −0 node_modules/coffee-script/lib/coffee-script/index.js
  23. +788 −0 node_modules/coffee-script/lib/coffee-script/lexer.js
  24. +2,986 −0 node_modules/coffee-script/lib/coffee-script/nodes.js
  25. +138 −0 node_modules/coffee-script/lib/coffee-script/optparse.js
  26. +683 −0 node_modules/coffee-script/lib/coffee-script/parser.js
  27. +261 −0 node_modules/coffee-script/lib/coffee-script/repl.js
  28. +349 −0 node_modules/coffee-script/lib/coffee-script/rewriter.js
  29. +146 −0 node_modules/coffee-script/lib/coffee-script/scope.js
  30. +44 −0 node_modules/coffee-script/package.json
  31. +12 −0 node_modules/jasmine-node/.npmignore
  32. +6 −0 node_modules/jasmine-node/.travis.yml
  33. +22 −0 node_modules/jasmine-node/LICENSE
  34. +83 −0 node_modules/jasmine-node/README.md
  35. +7 −0 node_modules/jasmine-node/bin/jasmine-node
  36. +54 −0 node_modules/jasmine-node/lib/jasmine-node/async-callback.js
  37. +90 −0 node_modules/jasmine-node/lib/jasmine-node/autotest.js
  38. +176 −0 node_modules/jasmine-node/lib/jasmine-node/cli.js
  39. +148 −0 node_modules/jasmine-node/lib/jasmine-node/index.js
  40. +2,479 −0 node_modules/jasmine-node/lib/jasmine-node/jasmine-2.0.0.rc1.js
  41. +275 −0 node_modules/jasmine-node/lib/jasmine-node/reporter.js
  42. +80 −0 node_modules/jasmine-node/lib/jasmine-node/requirejs-runner.js
  43. +48 −0 node_modules/jasmine-node/lib/jasmine-node/requirejs-spec-loader.js
  44. +65 −0 node_modules/jasmine-node/lib/jasmine-node/requirejs-wrapper-template.js
  45. +35 −0 node_modules/jasmine-node/lib/jasmine-node/spec-collection.js
  46. +1 −0  node_modules/jasmine-node/node_modules/.bin/r.js
  47. +2 −0  node_modules/jasmine-node/node_modules/jasmine-reporters/.npmignore
  48. +21 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/LICENSE
  49. +52 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/README.markdown
  50. +13,989 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/ext/env.rhino.1.2.js
  51. +182 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/ext/jasmine-html.js
  52. +166 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/ext/jasmine.css
  53. +2,421 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/ext/jasmine.js
  54. BIN  node_modules/jasmine-node/node_modules/jasmine-reporters/ext/jline.jar
  55. BIN  node_modules/jasmine-node/node_modules/jasmine-reporters/ext/js.jar
  56. +20 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/package.json
  57. +142 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/src/jasmine.console_reporter.js
  58. +200 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/src/jasmine.junit_reporter.js
  59. +139 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/src/jasmine.teamcity_reporter.js
  60. +3 −0  node_modules/jasmine-node/node_modules/jasmine-reporters/src/load_reporters.js
  61. +214 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/JUnitXmlReporterSpec.js
  62. +36 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/console_reporter.html
  63. +14 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/envjs.bootstrap.js
  64. +7 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/envjs.runner.sh
  65. +23 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/junit_xml_reporter.html
  66. +183 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/phantomjs-testrunner.js
  67. +36 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/phantomjs.runner.sh
  68. +36 −0 node_modules/jasmine-node/node_modules/jasmine-reporters/test/teamcity_reporter.html
  69. +9 −0 node_modules/jasmine-node/node_modules/requirejs/README.md
  70. +15,484 −0 node_modules/jasmine-node/node_modules/requirejs/bin/r.js
  71. +31 −0 node_modules/jasmine-node/node_modules/requirejs/package.json
  72. +2,041 −0 node_modules/jasmine-node/node_modules/requirejs/require.js
  73. +3 −0  node_modules/jasmine-node/node_modules/underscore/.npmignore
  74. +1 −0  node_modules/jasmine-node/node_modules/underscore/CNAME
  75. +22 −0 node_modules/jasmine-node/node_modules/underscore/LICENSE
  76. +19 −0 node_modules/jasmine-node/node_modules/underscore/README.md
  77. BIN  node_modules/jasmine-node/node_modules/underscore/favicon.ico
  78. +2,109 −0 node_modules/jasmine-node/node_modules/underscore/index.html
  79. +1 −0  node_modules/jasmine-node/node_modules/underscore/index.js
  80. +25 −0 node_modules/jasmine-node/node_modules/underscore/package.json
  81. BIN  node_modules/jasmine-node/node_modules/underscore/raw/underscore.psd
  82. +32 −0 node_modules/jasmine-node/node_modules/underscore/underscore-min.js
  83. +1,059 −0 node_modules/jasmine-node/node_modules/underscore/underscore.js
  84. +3 −0  node_modules/jasmine-node/node_modules/walkdir/.jshintignore
  85. +2 −0  node_modules/jasmine-node/node_modules/walkdir/.npmignore
  86. +3 −0  node_modules/jasmine-node/node_modules/walkdir/.travis.yml
  87. +10 −0 node_modules/jasmine-node/node_modules/walkdir/license
  88. +41 −0 node_modules/jasmine-node/node_modules/walkdir/package.json
  89. +160 −0 node_modules/jasmine-node/node_modules/walkdir/readme.md
  90. +19 −0 node_modules/jasmine-node/node_modules/walkdir/test.sh
  91. +62 −0 node_modules/jasmine-node/node_modules/walkdir/test/async.js
  92. +33 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/find.js
  93. +26 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/find.py
  94. +15 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/finditsynctest.js
  95. +14 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/findittest.js
  96. +24 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/fstream.js
  97. +1 −0  node_modules/jasmine-node/node_modules/walkdir/test/comparison/install_test_deps.sh
  98. +18 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/lsr.js
  99. +10 −0 node_modules/jasmine-node/node_modules/walkdir/test/comparison/package.json
  100. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/foo/a/b/c/w
  101. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/foo/a/b/z
  102. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/foo/a/y
  103. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/foo/x
  104. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/symlinks/dir1/file1
  105. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/symlinks/dir2/file2
  106. 0  node_modules/jasmine-node/node_modules/walkdir/test/dir/symlinks/file
  107. +19 −0 node_modules/jasmine-node/node_modules/walkdir/test/endearly.js
  108. +27 −0 node_modules/jasmine-node/node_modules/walkdir/test/max_depth.js
  109. +25 −0 node_modules/jasmine-node/node_modules/walkdir/test/no_recurse.js
  110. +34 −0 node_modules/jasmine-node/node_modules/walkdir/test/nofailemptydir.js
  111. +36 −0 node_modules/jasmine-node/node_modules/walkdir/test/pauseresume.js
  112. +37 −0 node_modules/jasmine-node/node_modules/walkdir/test/symlink.js
  113. +50 −0 node_modules/jasmine-node/node_modules/walkdir/test/sync.js
  114. +230 −0 node_modules/jasmine-node/node_modules/walkdir/walkdir.js
  115. +49 −0 node_modules/jasmine-node/package.json
  116. +37 −0 node_modules/jasmine-node/scripts/specs
  117. +8 −0 node_modules/jasmine-node/spec-requirejs/requirejs.spec.js
  118. +8 −0 node_modules/jasmine-node/spec-requirejs/requirejs.sut.js
  119. +7 −0 node_modules/jasmine-node/spec/AsyncSpec.coffee
  120. +4 −0 node_modules/jasmine-node/spec/CoffeeSpec.coffee
  121. +22 −0 node_modules/jasmine-node/spec/GrammarHelper.coffee
  122. +6 −0 node_modules/jasmine-node/spec/HelperSpec.coffee
  123. +25 −0 node_modules/jasmine-node/spec/SampleSpecs.js
  124. +5 −0 node_modules/jasmine-node/spec/TestSpec.js
  125. +150 −0 node_modules/jasmine-node/spec/async-callback_spec.js
  126. +7 −0 node_modules/jasmine-node/spec/helper_spec.js
  127. +5 −0 node_modules/jasmine-node/spec/nested.js/NestedSpec.js
  128. +5 −0 node_modules/jasmine-node/spec/nested/NestedSpec.js
  129. +11 −0 node_modules/jasmine-node/spec/nested/uber-nested/UberNestedSpec.js
  130. +432 −0 node_modules/jasmine-node/spec/reporter_spec.js
  131. +19 −0 node_modules/jasmine-node/spec/sample_helper.js
  132. +24 −0 node_modules/jasmine-node/specs.sh
  133. +201 −0 node_modules/pegjs/CHANGELOG
  134. +22 −0 node_modules/pegjs/LICENSE
  135. +252 −0 node_modules/pegjs/README.md
  136. +1 −0  node_modules/pegjs/VERSION
  137. +159 −0 node_modules/pegjs/bin/pegjs
  138. +22 −0 node_modules/pegjs/examples/arithmetics.pegjs
  139. +554 −0 node_modules/pegjs/examples/css.pegjs
  140. +1,530 −0 node_modules/pegjs/examples/javascript.pegjs
  141. +120 −0 node_modules/pegjs/examples/json.pegjs
  142. +4,528 −0 node_modules/pegjs/lib/peg.js
  143. +29 −0 node_modules/pegjs/package.json
  144. +15 −0 package.json
  145. +9 −0 spec/coffee/simple_spec.coffee
  146. +15 −0 spec/js/simple_spec.js
  147. +22 −0 src/edn.pegjs
View
0  .gitignore
No changes.
View
9 README.md
@@ -0,0 +1,9 @@
+# edn-js
+
+A [PEG.js](https://github.com/dmajda/pegjs) generated [edn](https://github.com/edn-format/edn) parser in JavaScript.
+
+Right now, there's not much to see! I've setup the infrastructure and written a simple spec using the pegjs standard example.
+
+## Testing
+
+- I'm writing specs in CoffeeScript, and using the following to auto-compile them: `coffee -o spec/js -cw spec/coffee/*`
View
417 lib/edn.js
@@ -0,0 +1,417 @@
+module.exports = (function(){
+ /*
+ * Generated by PEG.js 0.7.0.
+ *
+ * http://pegjs.majda.cz/
+ */
+
+ function quote(s) {
+ /*
+ * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
+ * string literal except for the closing quote character, backslash,
+ * carriage return, line separator, paragraph separator, and line feed.
+ * Any character may appear in the form of an escape sequence.
+ *
+ * For portability, we also escape escape all control and non-ASCII
+ * characters. Note that "\0" and "\v" escape sequences are not used
+ * because JSHint does not like the first and IE the second.
+ */
+ return '"' + s
+ .replace(/\\/g, '\\\\') // backslash
+ .replace(/"/g, '\\"') // closing quote character
+ .replace(/\x08/g, '\\b') // backspace
+ .replace(/\t/g, '\\t') // horizontal tab
+ .replace(/\n/g, '\\n') // line feed
+ .replace(/\f/g, '\\f') // form feed
+ .replace(/\r/g, '\\r') // carriage return
+ .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape)
+ + '"';
+ }
+
+ var result = {
+ /*
+ * Parses the input with a generated parser. If the parsing is successfull,
+ * returns a value explicitly or implicitly specified by the grammar from
+ * which the parser was generated (see |PEG.buildParser|). If the parsing is
+ * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
+ */
+ parse: function(input, startRule) {
+ var parseFunctions = {
+ "additive": parse_additive,
+ "multiplicative": parse_multiplicative,
+ "primary": parse_primary,
+ "integer": parse_integer
+ };
+
+ if (startRule !== undefined) {
+ if (parseFunctions[startRule] === undefined) {
+ throw new Error("Invalid rule name: " + quote(startRule) + ".");
+ }
+ } else {
+ startRule = "additive";
+ }
+
+ var pos = 0;
+ var reportFailures = 0;
+ var rightmostFailuresPos = 0;
+ var rightmostFailuresExpected = [];
+
+ function padLeft(input, padding, length) {
+ var result = input;
+
+ var padLength = length - input.length;
+ for (var i = 0; i < padLength; i++) {
+ result = padding + result;
+ }
+
+ return result;
+ }
+
+ function escape(ch) {
+ var charCode = ch.charCodeAt(0);
+ var escapeChar;
+ var length;
+
+ if (charCode <= 0xFF) {
+ escapeChar = 'x';
+ length = 2;
+ } else {
+ escapeChar = 'u';
+ length = 4;
+ }
+
+ return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
+ }
+
+ function matchFailed(failure) {
+ if (pos < rightmostFailuresPos) {
+ return;
+ }
+
+ if (pos > rightmostFailuresPos) {
+ rightmostFailuresPos = pos;
+ rightmostFailuresExpected = [];
+ }
+
+ rightmostFailuresExpected.push(failure);
+ }
+
+ function parse_additive() {
+ var result0, result1, result2;
+ var pos0, pos1;
+
+ pos0 = pos;
+ pos1 = pos;
+ result0 = parse_multiplicative();
+ if (result0 !== null) {
+ if (input.charCodeAt(pos) === 43) {
+ result1 = "+";
+ pos++;
+ } else {
+ result1 = null;
+ if (reportFailures === 0) {
+ matchFailed("\"+\"");
+ }
+ }
+ if (result1 !== null) {
+ result2 = parse_additive();
+ if (result2 !== null) {
+ result0 = [result0, result1, result2];
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ if (result0 !== null) {
+ result0 = (function(offset, left, right) { return left + right; })(pos0, result0[0], result0[2]);
+ }
+ if (result0 === null) {
+ pos = pos0;
+ }
+ if (result0 === null) {
+ result0 = parse_multiplicative();
+ }
+ return result0;
+ }
+
+ function parse_multiplicative() {
+ var result0, result1, result2;
+ var pos0, pos1;
+
+ pos0 = pos;
+ pos1 = pos;
+ result0 = parse_primary();
+ if (result0 !== null) {
+ if (input.charCodeAt(pos) === 42) {
+ result1 = "*";
+ pos++;
+ } else {
+ result1 = null;
+ if (reportFailures === 0) {
+ matchFailed("\"*\"");
+ }
+ }
+ if (result1 !== null) {
+ result2 = parse_multiplicative();
+ if (result2 !== null) {
+ result0 = [result0, result1, result2];
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ if (result0 !== null) {
+ result0 = (function(offset, left, right) { return left * right; })(pos0, result0[0], result0[2]);
+ }
+ if (result0 === null) {
+ pos = pos0;
+ }
+ if (result0 === null) {
+ result0 = parse_primary();
+ }
+ return result0;
+ }
+
+ function parse_primary() {
+ var result0, result1, result2;
+ var pos0, pos1;
+
+ result0 = parse_integer();
+ if (result0 === null) {
+ pos0 = pos;
+ pos1 = pos;
+ if (input.charCodeAt(pos) === 40) {
+ result0 = "(";
+ pos++;
+ } else {
+ result0 = null;
+ if (reportFailures === 0) {
+ matchFailed("\"(\"");
+ }
+ }
+ if (result0 !== null) {
+ result1 = parse_additive();
+ if (result1 !== null) {
+ if (input.charCodeAt(pos) === 41) {
+ result2 = ")";
+ pos++;
+ } else {
+ result2 = null;
+ if (reportFailures === 0) {
+ matchFailed("\")\"");
+ }
+ }
+ if (result2 !== null) {
+ result0 = [result0, result1, result2];
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ } else {
+ result0 = null;
+ pos = pos1;
+ }
+ if (result0 !== null) {
+ result0 = (function(offset, additive) { return additive; })(pos0, result0[1]);
+ }
+ if (result0 === null) {
+ pos = pos0;
+ }
+ }
+ return result0;
+ }
+
+ function parse_integer() {
+ var result0, result1;
+ var pos0;
+
+ reportFailures++;
+ pos0 = pos;
+ if (/^[0-9]/.test(input.charAt(pos))) {
+ result1 = input.charAt(pos);
+ pos++;
+ } else {
+ result1 = null;
+ if (reportFailures === 0) {
+ matchFailed("[0-9]");
+ }
+ }
+ if (result1 !== null) {
+ result0 = [];
+ while (result1 !== null) {
+ result0.push(result1);
+ if (/^[0-9]/.test(input.charAt(pos))) {
+ result1 = input.charAt(pos);
+ pos++;
+ } else {
+ result1 = null;
+ if (reportFailures === 0) {
+ matchFailed("[0-9]");
+ }
+ }
+ }
+ } else {
+ result0 = null;
+ }
+ if (result0 !== null) {
+ result0 = (function(offset, digits) { return parseInt(digits.join(""), 10); })(pos0, result0);
+ }
+ if (result0 === null) {
+ pos = pos0;
+ }
+ reportFailures--;
+ if (reportFailures === 0 && result0 === null) {
+ matchFailed("integer");
+ }
+ return result0;
+ }
+
+
+ function cleanupExpected(expected) {
+ expected.sort();
+
+ var lastExpected = null;
+ var cleanExpected = [];
+ for (var i = 0; i < expected.length; i++) {
+ if (expected[i] !== lastExpected) {
+ cleanExpected.push(expected[i]);
+ lastExpected = expected[i];
+ }
+ }
+ return cleanExpected;
+ }
+
+ function computeErrorPosition() {
+ /*
+ * The first idea was to use |String.split| to break the input up to the
+ * error position along newlines and derive the line and column from
+ * there. However IE's |split| implementation is so broken that it was
+ * enough to prevent it.
+ */
+
+ var line = 1;
+ var column = 1;
+ var seenCR = false;
+
+ for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
+ var ch = input.charAt(i);
+ if (ch === "\n") {
+ if (!seenCR) { line++; }
+ column = 1;
+ seenCR = false;
+ } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
+ line++;
+ column = 1;
+ seenCR = true;
+ } else {
+ column++;
+ seenCR = false;
+ }
+ }
+
+ return { line: line, column: column };
+ }
+
+
+ var result = parseFunctions[startRule]();
+
+ /*
+ * The parser is now in one of the following three states:
+ *
+ * 1. The parser successfully parsed the whole input.
+ *
+ * - |result !== null|
+ * - |pos === input.length|
+ * - |rightmostFailuresExpected| may or may not contain something
+ *
+ * 2. The parser successfully parsed only a part of the input.
+ *
+ * - |result !== null|
+ * - |pos < input.length|
+ * - |rightmostFailuresExpected| may or may not contain something
+ *
+ * 3. The parser did not successfully parse any part of the input.
+ *
+ * - |result === null|
+ * - |pos === 0|
+ * - |rightmostFailuresExpected| contains at least one failure
+ *
+ * All code following this comment (including called functions) must
+ * handle these states.
+ */
+ if (result === null || pos !== input.length) {
+ var offset = Math.max(pos, rightmostFailuresPos);
+ var found = offset < input.length ? input.charAt(offset) : null;
+ var errorPosition = computeErrorPosition();
+
+ throw new this.SyntaxError(
+ cleanupExpected(rightmostFailuresExpected),
+ found,
+ offset,
+ errorPosition.line,
+ errorPosition.column
+ );
+ }
+
+ return result;
+ },
+
+ /* Returns the parser source code. */
+ toSource: function() { return this._source; }
+ };
+
+ /* Thrown when a parser encounters a syntax error. */
+
+ result.SyntaxError = function(expected, found, offset, line, column) {
+ function buildMessage(expected, found) {
+ var expectedHumanized, foundHumanized;
+
+ switch (expected.length) {
+ case 0:
+ expectedHumanized = "end of input";
+ break;
+ case 1:
+ expectedHumanized = expected[0];
+ break;
+ default:
+ expectedHumanized = expected.slice(0, expected.length - 1).join(", ")
+ + " or "
+ + expected[expected.length - 1];
+ }
+
+ foundHumanized = found ? quote(found) : "end of input";
+
+ return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
+ }
+
+ this.name = "SyntaxError";
+ this.expected = expected;
+ this.found = found;
+ this.message = buildMessage(expected, found);
+ this.offset = offset;
+ this.line = line;
+ this.column = column;
+ };
+
+ result.SyntaxError.prototype = Error.prototype;
+
+ return result;
+})();
View
1  node_modules/.bin/cake
View
1  node_modules/.bin/coffee
View
1  node_modules/.bin/jasmine-node
View
1  node_modules/.bin/pegjs
View
11 node_modules/coffee-script/.npmignore
@@ -0,0 +1,11 @@
+*.coffee
+*.html
+.DS_Store
+.git*
+Cakefile
+documentation/
+examples/
+extras/coffee-script.js
+raw/
+src/
+test/
View
1  node_modules/coffee-script/CNAME
@@ -0,0 +1 @@
+coffeescript.org
View
22 node_modules/coffee-script/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2009-2012 Jeremy Ashkenas
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+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.
View
51 node_modules/coffee-script/README
@@ -0,0 +1,51 @@
+
+ {
+ } } {
+ { { } }
+ } }{ {
+ { }{ } } _____ __ __
+ ( }{ }{ { ) / ____| / _|/ _|
+ .- { { } { }} -. | | ___ | |_| |_ ___ ___
+ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
+ |`-..________ ..-'| | |___| (_) | | | || __/ __/
+ | | \_____\___/|_| |_| \___|\___|
+ | ;--.
+ | (__ \ _____ _ _
+ | | ) ) / ____| (_) | |
+ | |/ / | (___ ___ _ __ _ _ __ | |_
+ | ( / \___ \ / __| '__| | '_ \| __|
+ | |/ ____) | (__| | | | |_) | |_
+ | | |_____/ \___|_| |_| .__/ \__|
+ `-.._________..-' | |
+ |_|
+
+
+ CoffeeScript is a little language that compiles into JavaScript.
+
+ Install Node.js, and then the CoffeeScript compiler:
+ sudo bin/cake install
+
+ Or, if you have the Node Package Manager installed:
+ npm install -g coffee-script
+ (Leave off the -g if you don't wish to install globally.)
+
+ Execute a script:
+ coffee /path/to/script.coffee
+
+ Compile a script:
+ coffee -c /path/to/script.coffee
+
+ For documentation, usage, and examples, see:
+ http://coffeescript.org/
+
+ To suggest a feature, report a bug, or general discussion:
+ http://github.com/jashkenas/coffee-script/issues/
+
+ If you'd like to chat, drop by #coffeescript on Freenode IRC,
+ or on webchat.freenode.net.
+
+ The source repository:
+ git://github.com/jashkenas/coffee-script.git
+
+ All contributors are listed here:
+ http://github.com/jashkenas/coffee-script/contributors
View
78 node_modules/coffee-script/Rakefile
@@ -0,0 +1,78 @@
+require 'rubygems'
+require 'erb'
+require 'fileutils'
+require 'rake/testtask'
+require 'json'
+
+desc "Build the documentation page"
+task :doc do
+ source = 'documentation/index.html.erb'
+ child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
+ at_exit { Process.kill("INT", child) }
+ Signal.trap("INT") { exit }
+ loop do
+ mtime = File.stat(source).mtime
+ if !@mtime || mtime > @mtime
+ rendered = ERB.new(File.read(source)).result(binding)
+ File.open('index.html', 'w+') {|f| f.write(rendered) }
+ end
+ @mtime = mtime
+ sleep 1
+ end
+end
+
+desc "Build coffee-script-source gem"
+task :gem do
+ require 'rubygems'
+ require 'rubygems/package'
+
+ gemspec = Gem::Specification.new do |s|
+ s.name = 'coffee-script-source'
+ s.version = JSON.parse(File.read('package.json'))["version"]
+ s.date = Time.now.strftime("%Y-%m-%d")
+
+ s.homepage = "http://jashkenas.github.com/coffee-script/"
+ s.summary = "The CoffeeScript Compiler"
+ s.description = <<-EOS
+ CoffeeScript is a little language that compiles into JavaScript.
+ Underneath all of those embarrassing braces and semicolons,
+ JavaScript has always had a gorgeous object model at its heart.
+ CoffeeScript is an attempt to expose the good parts of JavaScript
+ in a simple way.
+ EOS
+
+ s.files = [
+ 'lib/coffee_script/coffee-script.js',
+ 'lib/coffee_script/source.rb'
+ ]
+
+ s.authors = ['Jeremy Ashkenas']
+ s.email = 'jashkenas@gmail.com'
+ s.rubyforge_project = 'coffee-script-source'
+ end
+
+ file = File.open("coffee-script-source.gem", "w")
+ Gem::Package.open(file, 'w') do |pkg|
+ pkg.metadata = gemspec.to_yaml
+
+ path = "lib/coffee_script/source.rb"
+ contents = <<-ERUBY
+module CoffeeScript
+ module Source
+ def self.bundled_path
+ File.expand_path("../coffee-script.js", __FILE__)
+ end
+ end
+end
+ ERUBY
+ pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
+ tar_io.write(contents)
+ end
+
+ contents = File.read("extras/coffee-script.js")
+ path = "lib/coffee_script/coffee-script.js"
+ pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
+ tar_io.write(contents)
+ end
+ end
+end
View
7 node_modules/coffee-script/bin/cake
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
+
+require(lib + '/coffee-script/cake').run();
View
7 node_modules/coffee-script/bin/coffee
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
+
+require(lib + '/coffee-script/command').run();
View
44 node_modules/coffee-script/extras/jsl.conf
@@ -0,0 +1,44 @@
+# JavaScriptLint configuration file for CoffeeScript.
+
++no_return_value # function {0} does not always return a value
++duplicate_formal # duplicate formal argument {0}
+-equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
++var_hides_arg # variable {0} hides argument
++redeclared_var # redeclaration of {0} {1}
+-anon_no_return_value # anonymous function does not always return a value
++missing_semicolon # missing semicolon
++meaningless_block # meaningless block; curly braces have no impact
+-comma_separated_stmts # multiple statements separated by commas (use semicolons?)
++unreachable_code # unreachable code
++missing_break # missing break statement
+-missing_break_for_last_case # missing break statement for last case in switch
+-comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
+-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
+-useless_void # use of the void type may be unnecessary (void is always undefined)
++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
++use_of_label # use of label
+-block_without_braces # block statement without curly braces
++leading_decimal_point # leading decimal point may indicate a number or an object member
++trailing_decimal_point # trailing decimal point may indicate a number or an object member
++octal_number # leading zeros make an octal number
++nested_comment # nested comment
++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
++empty_statement # empty statement or extra semicolon
+-missing_option_explicit # the "option explicit" control comment is missing
++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
++dup_option_explicit # duplicate "option explicit" control comment
++useless_assign # useless assignment
++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
+-missing_default_case # missing default case in switch statement
++duplicate_case_in_switch # duplicate case in switch statements
++default_not_at_end # the default case is not at the end of the switch statement
++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
++useless_comparison # useless comparison; comparing identical expressions
++with_statement # with statement hides undeclared variables; use temporary variable instead
++trailing_comma_in_array # extra comma is not recommended in array initializers
++assign_to_function_call # assignment to a function call
++parseint_missing_radix # parseInt missing radix parameter
++lambda_assign_requires_semicolon
View
92 node_modules/coffee-script/lib/coffee-script/browser.js
@@ -0,0 +1,92 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var CoffeeScript, runScripts;
+
+ CoffeeScript = require('./coffee-script');
+
+ CoffeeScript.require = require;
+
+ 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));
+ };
+
+ CoffeeScript.run = function(code, options) {
+ if (options == null) {
+ options = {};
+ }
+ options.bare = true;
+ return Function(CoffeeScript.compile(code, options))();
+ };
+
+ if (typeof window === "undefined" || window === null) {
+ return;
+ }
+
+ CoffeeScript.load = function(url, callback) {
+ var xhr;
+ xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
+ 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);
+ } else {
+ throw new Error("Could not load " + url);
+ }
+ if (callback) {
+ return callback();
+ }
+ }
+ };
+ return xhr.send(null);
+ };
+
+ runScripts = function() {
+ var coffees, execute, index, length, s, scripts;
+ scripts = document.getElementsByTagName('script');
+ coffees = (function() {
+ var _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = scripts.length; _i < _len; _i++) {
+ s = scripts[_i];
+ if (s.type === 'text/coffeescript') {
+ _results.push(s);
+ }
+ }
+ return _results;
+ })();
+ index = 0;
+ length = coffees.length;
+ (execute = function() {
+ var script;
+ script = coffees[index++];
+ if ((script != null ? script.type : void 0) === 'text/coffeescript') {
+ if (script.src) {
+ return CoffeeScript.load(script.src, execute);
+ } else {
+ CoffeeScript.run(script.innerHTML);
+ return execute();
+ }
+ }
+ })();
+ return null;
+ };
+
+ if (window.addEventListener) {
+ addEventListener('DOMContentLoaded', runScripts, false);
+ } else {
+ attachEvent('onload', runScripts);
+ }
+
+}).call(this);
View
111 node_modules/coffee-script/lib/coffee-script/cake.js
@@ -0,0 +1,111 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
+
+ fs = require('fs');
+
+ path = require('path');
+
+ helpers = require('./helpers');
+
+ optparse = require('./optparse');
+
+ CoffeeScript = require('./coffee-script');
+
+ tasks = {};
+
+ options = {};
+
+ switches = [];
+
+ oparse = null;
+
+ helpers.extend(global, {
+ task: function(name, description, action) {
+ var _ref;
+ if (!action) {
+ _ref = [description, action], action = _ref[0], description = _ref[1];
+ }
+ return tasks[name] = {
+ name: name,
+ description: description,
+ action: action
+ };
+ },
+ option: function(letter, flag, description) {
+ return switches.push([letter, flag, description]);
+ },
+ invoke: function(name) {
+ if (!tasks[name]) {
+ missingTask(name);
+ }
+ return tasks[name].action(options);
+ }
+ });
+
+ exports.run = function() {
+ var arg, args, _i, _len, _ref, _results;
+ global.__originalDirname = fs.realpathSync('.');
+ process.chdir(cakefileDirectory(__originalDirname));
+ args = process.argv.slice(2);
+ CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
+ filename: 'Cakefile'
+ });
+ oparse = new optparse.OptionParser(switches);
+ if (!args.length) {
+ return printTasks();
+ }
+ try {
+ options = oparse.parse(args);
+ } catch (e) {
+ return fatalError("" + e);
+ }
+ _ref = options["arguments"];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ arg = _ref[_i];
+ _results.push(invoke(arg));
+ }
+ return _results;
+ };
+
+ 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");
+ for (name in tasks) {
+ task = tasks[name];
+ spaces = 20 - name.length;
+ spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
+ desc = task.description ? "# " + task.description : '';
+ console.log("cake " + name + spaces + " " + desc);
+ }
+ if (switches.length) {
+ return console.log(oparse.help());
+ }
+ };
+
+ fatalError = function(message) {
+ console.error(message + '\n');
+ console.log('To see a list of all tasks/options, run "cake"');
+ return process.exit(1);
+ };
+
+ missingTask = function(task) {
+ return fatalError("No such task: " + task);
+ };
+
+ cakefileDirectory = function(dir) {
+ var parent;
+ if (path.existsSync(path.join(dir, 'Cakefile'))) {
+ return dir;
+ }
+ parent = path.normalize(path.join(dir, '..'));
+ if (parent !== dir) {
+ return cakefileDirectory(parent);
+ }
+ throw new Error("Cakefile not found in " + (process.cwd()));
+ };
+
+}).call(this);
View
167 node_modules/coffee-script/lib/coffee-script/coffee-script.js
@@ -0,0 +1,167 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var Lexer, RESERVED, compile, fs, lexer, parser, path, vm, _ref,
+ __hasProp = {}.hasOwnProperty;
+
+ fs = require('fs');
+
+ path = require('path');
+
+ _ref = require('./lexer'), Lexer = _ref.Lexer, RESERVED = _ref.RESERVED;
+
+ parser = require('./parser').parser;
+
+ vm = require('vm');
+
+ if (require.extensions) {
+ require.extensions['.coffee'] = function(module, filename) {
+ var content;
+ content = compile(fs.readFileSync(filename, 'utf8'), {
+ filename: filename
+ });
+ return module._compile(content, filename);
+ };
+ } else if (require.registerExtension) {
+ require.registerExtension('.coffee', function(content) {
+ return compile(content);
+ });
+ }
+
+ exports.VERSION = '1.3.3';
+
+ exports.RESERVED = RESERVED;
+
+ exports.helpers = require('./helpers');
+
+ exports.compile = compile = function(code, options) {
+ var header, js, merge;
+ if (options == null) {
+ options = {};
+ }
+ merge = exports.helpers.merge;
+ try {
+ js = (parser.parse(lexer.tokenize(code))).compile(options);
+ if (!options.header) {
+ return js;
+ }
+ } catch (err) {
+ if (options.filename) {
+ err.message = "In " + options.filename + ", " + err.message;
+ }
+ throw err;
+ }
+ header = "Generated by CoffeeScript " + this.VERSION;
+ return "// " + header + "\n" + js;
+ };
+
+ exports.tokens = function(code, options) {
+ return lexer.tokenize(code, options);
+ };
+
+ exports.nodes = function(source, options) {
+ if (typeof source === 'string') {
+ return parser.parse(lexer.tokenize(source, options));
+ } else {
+ return parser.parse(source);
+ }
+ };
+
+ exports.run = function(code, options) {
+ var mainModule;
+ if (options == null) {
+ options = {};
+ }
+ mainModule = require.main;
+ 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);
+ } 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;
+ if (options == null) {
+ options = {};
+ }
+ if (!(code = code.trim())) {
+ return;
+ }
+ Script = vm.Script;
+ if (Script) {
+ if (options.sandbox != null) {
+ if (options.sandbox instanceof Script.createContext().constructor) {
+ sandbox = options.sandbox;
+ } else {
+ sandbox = Script.createContext();
+ _ref1 = options.sandbox;
+ for (k in _ref1) {
+ if (!__hasProp.call(_ref1, k)) continue;
+ v = _ref1[k];
+ sandbox[k] = v;
+ }
+ }
+ sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
+ } else {
+ sandbox = global;
+ }
+ sandbox.__filename = options.filename || 'eval';
+ sandbox.__dirname = path.dirname(sandbox.__filename);
+ if (!(sandbox !== global || sandbox.module || sandbox.require)) {
+ Module = require('module');
+ sandbox.module = _module = new Module(options.modulename || 'eval');
+ sandbox.require = _require = function(path) {
+ 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];
+ if (r !== 'paths') {
+ _require[r] = require[r];
+ }
+ }
+ _require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
+ _require.resolve = function(request) {
+ return Module._resolveFilename(request, _module);
+ };
+ }
+ }
+ o = {};
+ for (k in options) {
+ if (!__hasProp.call(options, k)) continue;
+ v = options[k];
+ o[k] = v;
+ }
+ o.bare = true;
+ js = compile(code, o);
+ if (sandbox === global) {
+ return vm.runInThisContext(js);
+ } else {
+ return vm.runInContext(js, sandbox);
+ }
+ };
+
+ 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];
+ return tag;
+ },
+ setInput: function(tokens) {
+ this.tokens = tokens;
+ return this.pos = 0;
+ },
+ upcomingInput: function() {
+ return "";
+ }
+ };
+
+ parser.yy = require('./nodes');
+
+}).call(this);
View
500 node_modules/coffee-script/lib/coffee-script/command.js
@@ -0,0 +1,500 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, 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;
+
+ fs = require('fs');
+
+ path = require('path');
+
+ helpers = require('./helpers');
+
+ optparse = require('./optparse');
+
+ CoffeeScript = require('./coffee-script');
+
+ _ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec;
+
+ EventEmitter = require('events').EventEmitter;
+
+ helpers.extend(CoffeeScript, new EventEmitter);
+
+ printLine = function(line) {
+ return process.stdout.write(line + '\n');
+ };
+
+ printWarn = function(line) {
+ return process.stderr.write(line + '\n');
+ };
+
+ hidden = function(file) {
+ return /^\.|~$/.test(file);
+ };
+
+ 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']];
+
+ opts = {};
+
+ sources = [];
+
+ sourceCode = [];
+
+ notSources = {};
+
+ watchers = {};
+
+ optionParser = null;
+
+ exports.run = function() {
+ var literals, source, _i, _len, _results;
+ parseOptions();
+ if (opts.nodejs) {
+ return forkNode();
+ }
+ if (opts.help) {
+ return usage();
+ }
+ if (opts.version) {
+ return version();
+ }
+ if (opts.require) {
+ loadRequires();
+ }
+ if (opts.interactive) {
+ return require('./repl');
+ }
+ if (opts.watch && !fs.watch) {
+ return printWarn("The --watch feature depends on Node v0.6.0+. You are running " + process.version + ".");
+ }
+ if (opts.stdio) {
+ return compileStdio();
+ }
+ if (opts["eval"]) {
+ return compileScript(null, sources[0]);
+ }
+ if (!sources.length) {
+ return require('./repl');
+ }
+ 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];
+ _results.push(compilePath(source, true, path.normalize(source)));
+ }
+ return _results;
+ };
+
+ compilePath = function(source, topLevel, base) {
+ return fs.stat(source, function(err, stats) {
+ if (err && err.code !== 'ENOENT') {
+ 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;
+ }
+ if (stats.isDirectory()) {
+ 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;
+ }
+ if ((err != null ? err.code : void 0) === 'ENOENT') {
+ return;
+ }
+ index = sources.indexOf(source);
+ files = files.filter(function(file) {
+ return !hidden(file);
+ });
+ [].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];
+ _results.push(path.join(source, file));
+ }
+ return _results;
+ })())), _ref1;
+ [].splice.apply(sourceCode, [index, index - index + 1].concat(_ref2 = files.map(function() {
+ return null;
+ }))), _ref2;
+ return files.forEach(function(file) {
+ return compilePath(path.join(source, file), false, base);
+ });
+ });
+ } else if (topLevel || path.extname(source) === '.coffee') {
+ if (opts.watch) {
+ watch(source, base);
+ }
+ return fs.readFile(source, function(err, code) {
+ if (err && err.code !== 'ENOENT') {
+ throw err;
+ }
+ if ((err != null ? err.code : void 0) === 'ENOENT') {
+ return;
+ }
+ return compileScript(source, code.toString(), base);
+ });
+ } else {
+ notSources[source] = true;
+ return removeSource(source, base);
+ }
+ });
+ };
+
+ compileScript = function(file, input, base) {
+ var o, options, t, task;
+ o = opts;
+ options = compileOptions(file);
+ try {
+ t = task = {
+ file: file,
+ input: input,
+ options: options
+ };
+ CoffeeScript.emit('compile', task);
+ if (o.tokens) {
+ return printTokens(CoffeeScript.tokens(t.input));
+ } else if (o.nodes) {
+ return printLine(CoffeeScript.nodes(t.input).toString().trim());
+ } else if (o.run) {
+ return CoffeeScript.run(t.input, t.options);
+ } else if (o.join && t.file !== o.join) {
+ sourceCode[sources.indexOf(t.file)] = t.input;
+ return compileJoin();
+ } else {
+ t.output = CoffeeScript.compile(t.input, t.options);
+ 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.lint) {
+ return lint(t.file, t.output);
+ }
+ }
+ } catch (err) {
+ CoffeeScript.emit('failure', err, task);
+ if (CoffeeScript.listeners('failure').length) {
+ return;
+ }
+ if (o.watch) {
+ return printLine(err.message + '\x07');
+ }
+ 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) {
+ if (buffer) {
+ return code += buffer.toString();
+ }
+ });
+ return stdin.on('end', function() {
+ return compileScript(null, code);
+ });
+ };
+
+ joinTimeout = null;
+
+ compileJoin = function() {
+ if (!opts.join) {
+ return;
+ }
+ if (!sourceCode.some(function(code) {
+ return code === null;
+ })) {
+ clearTimeout(joinTimeout);
+ return joinTimeout = wait(100, function() {
+ return compileScript(opts.join, sourceCode.join('\n'), opts.join);
+ });
+ }
+ };
+
+ 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;
+ prevStats = null;
+ compileTimeout = null;
+ watchErr = function(e) {
+ if (e.code === 'ENOENT') {
+ if (sources.indexOf(source) === -1) {
+ return;
+ }
+ try {
+ rewatch();
+ return compile();
+ } catch (e) {
+ removeSource(source, base, true);
+ return compileJoin();
+ }
+ } else {
+ throw e;
+ }
+ };
+ compile = function() {
+ clearTimeout(compileTimeout);
+ return compileTimeout = wait(25, function() {
+ return fs.stat(source, function(err, stats) {
+ if (err) {
+ return watchErr(err);
+ }
+ if (prevStats && stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime()) {
+ return rewatch();
+ }
+ prevStats = stats;
+ return fs.readFile(source, function(err, code) {
+ if (err) {
+ return watchErr(err);
+ }
+ compileScript(source, code.toString(), base);
+ return rewatch();
+ });
+ });
+ });
+ };
+ try {
+ watcher = fs.watch(source, compile);
+ } catch (e) {
+ watchErr(e);
+ }
+ return rewatch = function() {
+ if (watcher != null) {
+ watcher.close();
+ }
+ return watcher = fs.watch(source, compile);
+ };
+ };
+
+ watchDir = function(source, base) {
+ var 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;
+ }
+ watcher.close();
+ return unwatchDir(source, base);
+ }
+ _results = [];
+ for (_i = 0, _len = files.length; _i < _len; _i++) {
+ file = files[_i];
+ if (!(!hidden(file) && !notSources[file])) {
+ continue;
+ }
+ file = path.join(source, file);
+ if (sources.some(function(s) {
+ return s.indexOf(file) >= 0;
+ })) {
+ continue;
+ }
+ sources.push(file);
+ sourceCode.push(null);
+ _results.push(compilePath(file, false, base));
+ }
+ return _results;
+ });
+ });
+ });
+ } catch (e) {
+ if (e.code !== 'ENOENT') {
+ throw e;
+ }
+ }
+ };
+
+ 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];
+ if (file.indexOf(source) >= 0) {
+ _results.push(file);
+ }
+ }
+ return _results;
+ })();
+ for (_i = 0, _len = toRemove.length; _i < _len; _i++) {
+ file = toRemove[_i];
+ removeSource(file, base, true);
+ }
+ if (!sources.some(function(s, i) {
+ return prevSources[i] !== s;
+ })) {
+ return;
+ }
+ return compileJoin();
+ };
+
+ removeSource = function(source, base, removeJs) {
+ var index, jsPath;
+ index = sources.indexOf(source);
+ sources.splice(index, 1);
+ sourceCode.splice(index, 1);
+ if (removeJs && !opts.join) {
+ jsPath = outputPath(source, base);
+ return path.exists(jsPath, function(exists) {
+ if (exists) {
+ return fs.unlink(jsPath, function(err) {
+ if (err && err.code !== 'ENOENT') {
+ throw err;
+ }
+ return timeLog("removed " + source);
+ });
+ }
+ });
+ }
+ };
+
+ outputPath = function(source, base) {
+ var baseDir, dir, filename, srcDir;
+ filename = path.basename(source, path.extname(source)) + '.js';
+ 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);
+ };
+
+ writeJs = function(source, js, base) {
+ var compile, jsDir, jsPath;
+ jsPath = outputPath(source, base);
+ 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);
+ }
+ });
+ };
+ return path.exists(jsDir, function(exists) {
+ if (exists) {
+ return compile();
+ } else {
+ return exec("mkdir -p " + jsDir, compile);
+ }
+ });
+ };
+
+ wait = function(milliseconds, func) {
+ return setTimeout(func, milliseconds);
+ };
+
+ timeLog = function(message) {
+ return console.log("" + ((new Date).toLocaleTimeString()) + " - " + message);
+ };
+
+ lint = function(file, js) {
+ var conf, jsl, printIt;
+ printIt = function(buffer) {
+ return printLine(file + ':\t' + buffer.toString().trim());
+ };
+ conf = __dirname + '/../../extras/jsl.conf';
+ jsl = spawn('jsl', ['-nologo', '-stdin', '-conf', conf]);
+ jsl.stdout.on('data', printIt);
+ jsl.stderr.on('data', printIt);
+ jsl.stdin.write(js);
+ return jsl.stdin.end();
+ };
+
+ printTokens = function(tokens) {
+ var strings, tag, token, value;
+ strings = (function() {
+ var _i, _len, _ref1, _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];
+ _results.push("[" + tag + " " + value + "]");
+ }
+ return _results;
+ })();
+ return printLine(strings.join(' '));
+ };
+
+ 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.print = !!(o.print || (o["eval"] || o.stdio && o.compile));
+ sources = o["arguments"];
+ for (i = _i = 0, _len = sources.length; _i < _len; i = ++_i) {
+ source = sources[i];
+ sourceCode[i] = null;
+ }
+ };
+
+ compileOptions = function(filename) {
+ return {
+ filename: filename,
+ bare: opts.bare,
+ header: opts.compile
+ };
+ };
+
+ forkNode = function() {
+ var args, nodeArgs;
+ nodeArgs = opts.nodejs.split(/\s+/);
+ args = process.argv.slice(1);
+ args.splice(args.indexOf('--nodejs'), 2);
+ return spawn(process.execPath, nodeArgs.concat(args), {
+ cwd: process.cwd(),
+ env: process.env,
+ customFds: [0, 1, 2]
+ });
+ };
+
+ usage = function() {
+ return printLine((new optparse.OptionParser(SWITCHES, BANNER)).help());
+ };
+
+ version = function() {
+ return printLine("CoffeeScript version " + CoffeeScript.VERSION);
+ };
+
+}).call(this);
View
606 node_modules/coffee-script/lib/coffee-script/grammar.js
@@ -0,0 +1,606 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
+
+ Parser = require('jison').Parser;
+
+ unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
+
+ o = function(patternString, action, options) {
+ var match;
+ patternString = patternString.replace(/\s{2,}/g, ' ');
+ 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];
+ };
+
+ grammar = {
+ Root: [
+ o('', function() {
+ return new Block;
+ }), o('Body'), o('Block TERMINATOR')
+ ],
+ Body: [
+ o('Line', function() {
+ return Block.wrap([$1]);
+ }), o('Body TERMINATOR Line', function() {
+ return $1.push($3);
+ }), o('Body TERMINATOR')
+ ],
+ Line: [o('Expression'), o('Statement')],
+ Statement: [
+ o('Return'), o('Comment'), o('STATEMENT', function() {
+ return new Literal($1);
+ })
+ ],
+ Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class'), o('Throw')],
+ Block: [
+ o('INDENT OUTDENT', function() {
+ return new Block;
+ }), o('INDENT Body OUTDENT', function() {
+ return $2;
+ })
+ ],
+ Identifier: [
+ o('IDENTIFIER', function() {
+ return new Literal($1);
+ })
+ ],
+ AlphaNumeric: [
+ o('NUMBER', function() {
+ return new Literal($1);
+ }), o('STRING', function() {
+ return new Literal($1);
+ })
+ ],
+ Literal: [
+ o('AlphaNumeric'), o('JS', function() {
+ return new Literal($1);
+ }), o('REGEX', function() {
+ return new Literal($1);
+ }), o('DEBUGGER', function() {
+ return new Literal($1);
+ }), o('UNDEFINED', function() {
+ return new Undefined;
+ }), o('NULL', function() {
+ return new Null;
+ }), o('BOOL', function() {
+ return new Bool($1);
+ })
+ ],
+ Assign: [
+ o('Assignable = Expression', function() {
+ return new Assign($1, $3);
+ }), o('Assignable = TERMINATOR Expression', function() {
+ return new Assign($1, $4);
+ }), o('Assignable = INDENT Expression OUTDENT', function() {
+ return new Assign($1, $4);
+ })
+ ],
+ AssignObj: [
+ o('ObjAssignable', function() {
+ return new Value($1);
+ }), o('ObjAssignable : Expression', function() {
+ return new Assign(new Value($1), $3, 'object');
+ }), o('ObjAssignable :\
+ INDENT Expression OUTDENT', function() {
+ return new Assign(new Value($1), $4, 'object');
+ }), o('Comment')
+ ],
+ ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
+ Return: [
+ o('RETURN Expression', function() {
+ return new Return($2);
+ }), o('RETURN', function() {
+ return new Return;
+ })
+ ],
+ Comment: [
+ o('HERECOMMENT', function() {
+ return new Comment($1);
+ })
+ ],
+ Code: [
+ o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
+ return new Code($2, $5, $4);
+ }), o('FuncGlyph Block', function() {
+ return new Code([], $2, $1);
+ })
+ ],
+ FuncGlyph: [
+ o('->', function() {
+ return 'func';
+ }), o('=>', function() {
+ return 'boundfunc';
+ })
+ ],
+ OptComma: [o(''), o(',')],
+ ParamList: [
+ o('', function() {
+ return [];
+ }), o('Param', function() {
+ return [$1];
+ }), o('ParamList , Param', function() {
+ return $1.concat($3);
+ }), o('ParamList OptComma TERMINATOR Param', function() {
+ return $1.concat($4);
+ }), o('ParamList OptComma INDENT ParamList OptComma OUTDENT', function() {
+ return $1.concat($4);
+ })
+ ],
+ Param: [
+ o('ParamVar', function() {
+ return new Param($1);
+ }), o('ParamVar ...', function() {
+ return new Param($1, null, true);
+ }), o('ParamVar = Expression', function() {
+ return new Param($1, $3);
+ })
+ ],
+ ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
+ Splat: [
+ o('Expression ...', function() {
+ return new Splat($1);
+ })
+ ],
+ SimpleAssignable: [
+ o('Identifier', function() {
+ return new Value($1);
+ }), o('Value Accessor', function() {
+ return $1.add($2);
+ }), o('Invocation Accessor', function() {
+ return new Value($1, [].concat($2));
+ }), o('ThisProperty')
+ ],
+ Assignable: [
+ o('SimpleAssignable'), o('Array', function() {
+ return new Value($1);
+ }), o('Object', function() {
+ return new Value($1);
+ })
+ ],
+ Value: [
+ o('Assignable'), o('Literal', function() {
+ return new Value($1);
+ }), o('Parenthetical', function() {
+ return new Value($1);
+ }), o('Range', function() {
+ return new Value($1);
+ }), o('This')
+ ],
+ Accessor: [
+ o('. Identifier', function() {
+ return new Access($2);
+ }), o('?. Identifier', function() {
+ return new Access($2, 'soak');
+ }), o(':: Identifier', function() {
+ return [new Access(new Literal('prototype')), new Access($2)];
+ }), o('::', function() {
+ return new Access(new Literal('prototype'));
+ }), o('Index')
+ ],
+ Index: [
+ o('INDEX_START IndexValue INDEX_END', function() {
+ return $2;
+ }), o('INDEX_SOAK Index', function() {
+ return extend($2, {
+ soak: true
+ });
+ })
+ ],
+ IndexValue: [
+ o('Expression', function() {
+ return new Index($1);
+ }), o('Slice', function() {
+ return new Slice($1);
+ })
+ ],
+ Object: [
+ o('{ AssignList OptComma }', function() {
+ return new Obj($2, $1.generated);
+ })
+ ],
+ AssignList: [
+ o('', function() {
+ return [];
+ }), o('AssignObj', function() {
+ return [$1];
+ }), o('AssignList , AssignObj', function() {
+ return $1.concat($3);
+ }), o('AssignList OptComma TERMINATOR AssignObj', function() {
+ return $1.concat($4);
+ }), o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function() {
+ return $1.concat($4);
+ })
+ ],
+ Class: [
+ o('CLASS', function() {
+ return new Class;
+ }), o('CLASS Block', function() {
+ return new Class(null, null, $2);
+ }), o('CLASS EXTENDS Expression', function() {
+ return new Class(null, $3);
+ }), o('CLASS EXTENDS Expression Block', function() {
+ return new Class(null, $3, $4);
+ }), o('CLASS SimpleAssignable', function() {
+ return new Class($2);
+ }), o('CLASS SimpleAssignable Block', function() {
+ return new Class($2, null, $3);
+ }), o('CLASS SimpleAssignable EXTENDS Expression', function() {
+ return new Class($2, $4);
+ }), o('CLASS SimpleAssignable EXTENDS Expression Block', function() {
+ return new Class($2, $4, $5);
+ })
+ ],
+ Invocation: [
+ o('Value OptFuncExist Arguments', function() {
+ return new Call($1, $3, $2);
+ }), o('Invocation OptFuncExist Arguments', function() {
+ return new Call($1, $3, $2);
+ }), o('SUPER', function() {
+ return new Call('super', [new Splat(new Literal('arguments'))]);
+ }), o('SUPER Arguments', function() {
+ return new Call('super', $2);
+ })
+ ],
+ OptFuncExist: [
+ o('', function() {
+ return false;
+ }), o('FUNC_EXIST', function() {
+ return true;
+ })
+ ],
+ Arguments: [
+ o('CALL_START CALL_END', function() {
+ return [];
+ }), o('CALL_START ArgList OptComma CALL_END', function() {
+ return $2;
+ })
+ ],
+ This: [
+ o('THIS', function() {
+ return new Value(new Literal('this'));
+ }), o('@', function() {
+ return new Value(new Literal('this'));
+ })
+ ],
+ ThisProperty: [
+ o('@ Identifier', function() {
+ return new Value(new Literal('this'), [new Access($2)], 'this');
+ })
+ ],
+ Array: [
+ o('[ ]', function() {
+ return new Arr([]);
+ }), o('[ ArgList OptComma ]', function() {
+ return new Arr($2);
+ })
+ ],
+ RangeDots: [
+ o('..', function() {
+ return 'inclusive';
+ }), o('...', function() {
+ return 'exclusive';
+ })
+ ],
+ Range: [
+ o('[ Expression RangeDots Expression ]', function() {
+ return new Range($2, $4, $3);
+ })
+ ],
+ Slice: [
+ o('Expression RangeDots Expression', function() {
+ return new Range($1, $3, $2);
+ }), o('Expression RangeDots', function() {
+ return new Range($1, null, $2);
+ }), o('RangeDots Expression', function() {
+ return new Range(null, $2, $1);
+ }), o('RangeDots', function() {
+ return new Range(null, null, $1);
+ })
+ ],
+ ArgList: [
+ o('Arg', function() {
+ return [$1];
+ }), o('ArgList , Arg', function() {
+ return $1.concat($3);
+ }), o('ArgList OptComma TERMINATOR Arg', function() {
+ return $1.concat($4);
+ }), o('INDENT ArgList OptComma OUTDENT', function() {
+ return $2;
+ }), o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function() {
+ return $1.concat($4);
+ })
+ ],
+ Arg: [o('Expression'), o('Splat')],
+ SimpleArgs: [
+ o('Expression'), o('SimpleArgs , Expression', function() {
+ return [].concat($1, $3);
+ })
+ ],
+ Try: [
+ o('TRY Block', function() {
+ return new Try($2);
+ }), o('TRY Block Catch', function() {
+ return new Try($2, $3[0], $3[1]);
+ }), o('TRY Block FINALLY Block', function() {
+ return new Try($2, null, null, $4);
+ }), o('TRY Block Catch FINALLY Block', function() {
+ return new Try($2, $3[0], $3[1], $5);
+ })
+ ],
+ Catch: [
+ o('CATCH Identifier Block', function() {
+ return [$2, $3];
+ })
+ ],
+ Throw: [
+ o('THROW Expression', function() {
+ return new Throw($2);
+ })
+ ],
+ Parenthetical: [
+ o('( Body )', function() {
+ return new Parens($2);
+ }), o('( INDENT Body OUTDENT )', function() {
+ return new Parens($3);
+ })
+ ],
+ WhileSource: [
+ o('WHILE Expression', function() {
+ return new While($2);
+ }), o('WHILE Expression WHEN Expression', function() {
+ return new While($2, {
+ guard: $4
+ });
+ }), o('UNTIL Expression', function() {
+ return new While($2, {
+ invert: true
+ });
+ }), o('UNTIL Expression WHEN Expression', function() {
+ return new While($2, {
+ invert: true,
+ guard: $4
+ });
+ })
+ ],
+ While: [
+ o('WhileSource Block', function() {
+ return $1.addBody($2);
+ }), o('Statement WhileSource', function() {
+ return $2.addBody(Block.wrap([$1]));
+ }), o('Expression WhileSource', function() {
+ return $2.addBody(Block.wrap([$1]));
+ }), o('Loop', function() {
+ return $1;
+ })
+ ],
+ Loop: [
+ o('LOOP Block', function() {
+ return new While(new Literal('true')).addBody($2);
+ }), o('LOOP Expression', function() {
+ return new While(new Literal('true')).addBody(Block.wrap([$2]));
+ })
+ ],
+ For: [
+ o('Statement ForBody', function() {
+ return new For($1, $2);
+ }), o('Expression ForBody', function() {
+ return new For($1, $2);
+ }), o('ForBody Block', function() {
+ return new For($2, $1);
+ })
+ ],
+ ForBody: [
+ o('FOR Range', function() {
+ return {
+ source: new Value($2)
+ };
+ }), o('ForStart ForSource', function() {
+ $2.own = $1.own;
+ $2.name = $1[0];
+ $2.index = $1[1];
+ return $2;
+ })
+ ],
+ ForStart: [
+ o('FOR ForVariables', function() {
+ return $2;
+ }), o('FOR OWN ForVariables', function() {
+ $3.own = true;
+ return $3;
+ })
+ ],
+ ForValue: [
+ o('Identifier'), o('ThisProperty'), o('Array', function() {
+ return new Value($1);
+ }), o('Object', function() {
+ return new Value($1);
+ })
+ ],
+ ForVariables: [
+ o('ForValue', function() {
+ return [$1];
+ }), o('ForValue , ForValue', function() {
+ return [$1, $3];
+ })
+ ],
+ ForSource: [
+ o('FORIN Expression', function() {
+ return {
+ source: $2
+ };
+ }), o('FOROF Expression', function() {
+ return {
+ source: $2,
+ object: true
+ };
+ }), o('FORIN Expression WHEN Expression', function() {
+ return {
+ source: $2,
+ guard: $4
+ };
+ }), o('FOROF Expression WHEN Expression', function() {
+ return {
+ source: $2,
+ guard: $4,
+ object: true
+ };
+ }), o('FORIN Expression BY Expression', function() {
+ return {
+ source: $2,
+ step: $4
+ };
+ }), o('FORIN Expression WHEN Expression BY Expression', function() {
+ return {
+ source: $2,
+ guard: $4,
+ step: $6
+ };
+ }), o('FORIN Expression BY Expression WHEN Expression', function() {
+ return {
+ source: $2,
+ step: $4,
+ guard: $6
+ };
+ })
+ ],
+ Switch: [
+ o('SWITCH Expression INDENT Whens OUTDENT', function() {
+ return new Switch($2, $4);
+ }), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
+ return new Switch($2, $4, $6);
+ }), o('SWITCH INDENT Whens OUTDENT', function() {
+ return new Switch(null, $3);
+ }), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
+ return new Switch(null, $3, $5);
+ })
+ ],
+ Whens: [
+ o('When'), o('Whens When', function() {
+ return $1.concat($2);
+ })
+ ],
+ When: [
+ o('LEADING_WHEN SimpleArgs Block', function() {
+ return [[$2, $3]];
+ }), o('LEADING_WHEN SimpleArgs Block TERMINATOR', function() {
+ return [[$2, $3]];
+ })
+ ],
+ IfBlock: [
+ o('IF Expression Block', function() {
+ return new If($2, $3, {
+ type: $1
+ });
+ }), o('IfBlock ELSE IF Expression Block', function() {
+ return $1.addElse(new If($4, $5, {
+ type: $3
+ }));
+ })
+ ],
+ If: [
+ o('IfBlock'), o('IfBlock ELSE Block', function() {
+ return $1.addElse($3);
+ }), o('Statement POST_IF Expression', function() {
+ return new If($3, Block.wrap([$1]), {
+ type: $2,
+ statement: true
+ });
+ }), o('Expression POST_IF Expression', function() {
+ return new If($3, Block.wrap([$1]), {
+ type: $2,
+ statement: true
+ });
+ })
+ ],
+ Operation: [
+ o('UNARY Expression', function() {
+ return new Op($1, $2);
+ }), o('- Expression', (function() {
+ return new Op('-', $2);
+ }), {
+ prec: 'UNARY'
+ }), o('+ Expression', (function() {
+ return new Op('+', $2);
+ }), {
+ prec: 'UNARY'
+ }), o('-- SimpleAssignable', function() {
+ return new Op('--', $2);
+ }), o('++ SimpleAssignable', function() {
+ return new Op('++', $2);
+ }), o('SimpleAssignable --', function() {
+ return new Op('--', $1, null, true);
+ }), o('SimpleAssignable ++', function() {
+ return new Op('++', $1, null, true);
+ }), o('Expression ?', function() {
+ return new Existence($1);
+ }), o('Expression + Expression', function() {
+ return new Op('+', $1, $3);
+ }), o('Expression - Expression', function() {
+ return new Op('-', $1, $3);
+ }), o('Expression MATH Expression', function() {
+ return new Op($2, $1, $3);