batman-rails-flo 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +29 -0
  3. data/Rakefile +2 -0
  4. data/lib/batman-rails-flo.rb +5 -0
  5. data/lib/batman_rails_flo/railtie.rb +9 -0
  6. data/lib/batman_rails_flo/tasks.rake +14 -0
  7. data/lib/batman_rails_flo/version.rb +3 -0
  8. data/vendor/assets/javascripts/batman_rails_flo/flo_server.js +67 -0
  9. data/vendor/assets/javascripts/batman_rails_flo/live_reload.js.coffee +129 -0
  10. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CNAME +1 -0
  11. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/CONTRIBUTING.md +9 -0
  12. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/LICENSE +22 -0
  13. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/README +50 -0
  14. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/cake +7 -0
  15. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/bin/coffee +7 -0
  16. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/browser.js +134 -0
  17. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/cake.js +112 -0
  18. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/coffee-script.js +335 -0
  19. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/command.js +569 -0
  20. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/grammar.js +631 -0
  21. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/helpers.js +252 -0
  22. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/index.js +11 -0
  23. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/lexer.js +926 -0
  24. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/nodes.js +3158 -0
  25. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/optparse.js +139 -0
  26. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/parser.js +724 -0
  27. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/register.js +66 -0
  28. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/repl.js +163 -0
  29. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/rewriter.js +475 -0
  30. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/scope.js +146 -0
  31. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/lib/coffee-script/sourcemap.js +161 -0
  32. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/LICENSE +21 -0
  33. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/examples/pow.js +6 -0
  34. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/index.js +82 -0
  35. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/package.json +34 -0
  36. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/readme.markdown +63 -0
  37. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/chmod.js +38 -0
  38. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/clobber.js +37 -0
  39. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/mkdirp.js +28 -0
  40. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm.js +32 -0
  41. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/perm_sync.js +39 -0
  42. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/race.js +41 -0
  43. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/rel.js +32 -0
  44. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return.js +25 -0
  45. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/return_sync.js +24 -0
  46. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/root.js +18 -0
  47. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/sync.js +32 -0
  48. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask.js +28 -0
  49. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/node_modules/mkdirp/test/umask_sync.js +32 -0
  50. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/package.json +50 -0
  51. data/vendor/assets/javascripts/batman_rails_flo/node_modules/coffee-script/register.js +1 -0
  52. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/LICENSE +30 -0
  53. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/PATENTS +23 -0
  54. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/README.md +124 -0
  55. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/bin/flo +26 -0
  56. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.html +57 -0
  57. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/configure.js +205 -0
  58. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/configure/style.css +334 -0
  59. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/connection.js +235 -0
  60. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/devtools.html +12 -0
  61. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/index.js +323 -0
  62. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logger.js +42 -0
  63. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/logo.png +0 -0
  64. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/manifest.json +13 -0
  65. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/client/session.js +305 -0
  66. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/index.js +10 -0
  67. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/flo.js +226 -0
  68. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/lib/server.js +94 -0
  69. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/README.md +66 -0
  70. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/index.js +437 -0
  71. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/LICENSE +23 -0
  72. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/README.md +218 -0
  73. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/minimatch.js +1055 -0
  74. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/CONTRIBUTORS +14 -0
  75. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/LICENSE +23 -0
  76. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/README.md +97 -0
  77. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +252 -0
  78. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/package.json +33 -0
  79. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/basic.js +369 -0
  80. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/foreach.js +52 -0
  81. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/lru-cache/test/memory-leak.js +50 -0
  82. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/LICENSE +27 -0
  83. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/README.md +53 -0
  84. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/bench.js +283 -0
  85. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/package.json +42 -0
  86. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/sigmund.js +39 -0
  87. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/node_modules/sigmund/test/basic.js +24 -0
  88. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/package.json +40 -0
  89. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/basic.js +399 -0
  90. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/brace-expand.js +33 -0
  91. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/caching.js +14 -0
  92. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/defaults.js +274 -0
  93. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
  94. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/lib/walker.js +111 -0
  95. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/license +13 -0
  96. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/lib/makeerror.js +87 -0
  97. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/lib/tmpl.js +17 -0
  98. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/package.json +31 -0
  99. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/node_modules/tmpl/readme.md +10 -0
  100. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/package.json +34 -0
  101. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/node_modules/makeerror/readme.md +77 -0
  102. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/package.json +36 -0
  103. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/walker/readme.md +52 -0
  104. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/LICENSE +55 -0
  105. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/main.js +128 -0
  106. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/package.json +34 -0
  107. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/readme.mkd +72 -0
  108. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/d/t +0 -0
  109. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/d/t +0 -0
  110. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitor.js +31 -0
  111. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_monitorRootDirectory.js +28 -0
  112. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/node_modules/watch/test/test_watchTree.js +20 -0
  113. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/package.json +45 -0
  114. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/sane/test/test.js +243 -0
  115. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/CHANGELOG.md +81 -0
  116. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/LICENSE +177 -0
  117. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/Makefile +11 -0
  118. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/README.md +245 -0
  119. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/binding.gyp +14 -0
  120. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Makefile +355 -0
  121. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/linker.lock +0 -0
  122. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/validation/src/validation.o +0 -0
  123. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/obj.target/xor/src/xor.o +0 -0
  124. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/validation.node +0 -0
  125. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/Release/xor.node +0 -0
  126. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/binding.Makefile +6 -0
  127. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/config.gypi +115 -0
  128. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/gyp-mac-tool +512 -0
  129. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/validation.target.mk +154 -0
  130. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/build/xor.target.mk +154 -0
  131. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/index.js +1 -0
  132. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/install.js +31 -0
  133. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Constants.js +23 -0
  134. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Deprecation.js +38 -0
  135. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.fallback.js +12 -0
  136. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/Validation.js +18 -0
  137. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketClient.js +359 -0
  138. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketConnection.js +717 -0
  139. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketFrame.js +282 -0
  140. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRequest.js +478 -0
  141. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouter.js +154 -0
  142. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketRouterRequest.js +59 -0
  143. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/WebSocketServer.js +216 -0
  144. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/utils.js +7 -0
  145. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/websocket.js +11 -0
  146. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.fallback.js +13 -0
  147. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/lib/xor.js +18 -0
  148. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/package.json +43 -0
  149. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/validation.cc +144 -0
  150. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/src/xor.cpp +86 -0
  151. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/FastBufferList.js +192 -0
  152. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/LICENSE +18 -0
  153. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/node_modules/websocket/vendor/node-ctype/ctio-faster.js +1126 -0
  154. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/package.json +25 -0
  155. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/browser_websocket.js +63 -0
  156. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/connection_test.js +57 -0
  157. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/logger_mock.js +15 -0
  158. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/client/session_test.js +194 -0
  159. data/vendor/assets/javascripts/batman_rails_flo/node_modules/fb-flo/test/server/flo_test.js +211 -0
  160. data/vendor/assets/javascripts/batman_rails_flo/package.json +15 -0
  161. data/vendor/assets/javascripts/batman_rails_flo/reload_event_handler.js.coffee +56 -0
  162. metadata +232 -0
@@ -0,0 +1,252 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref;
4
+
5
+ exports.starts = function(string, literal, start) {
6
+ return literal === string.substr(start, literal.length);
7
+ };
8
+
9
+ exports.ends = function(string, literal, back) {
10
+ var len;
11
+ len = literal.length;
12
+ return literal === string.substr(string.length - len - (back || 0), len);
13
+ };
14
+
15
+ exports.repeat = repeat = function(str, n) {
16
+ var res;
17
+ res = '';
18
+ while (n > 0) {
19
+ if (n & 1) {
20
+ res += str;
21
+ }
22
+ n >>>= 1;
23
+ str += str;
24
+ }
25
+ return res;
26
+ };
27
+
28
+ exports.compact = function(array) {
29
+ var item, _i, _len, _results;
30
+ _results = [];
31
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
32
+ item = array[_i];
33
+ if (item) {
34
+ _results.push(item);
35
+ }
36
+ }
37
+ return _results;
38
+ };
39
+
40
+ exports.count = function(string, substr) {
41
+ var num, pos;
42
+ num = pos = 0;
43
+ if (!substr.length) {
44
+ return 1 / 0;
45
+ }
46
+ while (pos = 1 + string.indexOf(substr, pos)) {
47
+ num++;
48
+ }
49
+ return num;
50
+ };
51
+
52
+ exports.merge = function(options, overrides) {
53
+ return extend(extend({}, options), overrides);
54
+ };
55
+
56
+ extend = exports.extend = function(object, properties) {
57
+ var key, val;
58
+ for (key in properties) {
59
+ val = properties[key];
60
+ object[key] = val;
61
+ }
62
+ return object;
63
+ };
64
+
65
+ exports.flatten = flatten = function(array) {
66
+ var element, flattened, _i, _len;
67
+ flattened = [];
68
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
69
+ element = array[_i];
70
+ if (element instanceof Array) {
71
+ flattened = flattened.concat(flatten(element));
72
+ } else {
73
+ flattened.push(element);
74
+ }
75
+ }
76
+ return flattened;
77
+ };
78
+
79
+ exports.del = function(obj, key) {
80
+ var val;
81
+ val = obj[key];
82
+ delete obj[key];
83
+ return val;
84
+ };
85
+
86
+ exports.last = last = function(array, back) {
87
+ return array[array.length - (back || 0) - 1];
88
+ };
89
+
90
+ exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) {
91
+ var e, _i, _len;
92
+ for (_i = 0, _len = this.length; _i < _len; _i++) {
93
+ e = this[_i];
94
+ if (fn(e)) {
95
+ return true;
96
+ }
97
+ }
98
+ return false;
99
+ };
100
+
101
+ exports.invertLiterate = function(code) {
102
+ var line, lines, maybe_code;
103
+ maybe_code = true;
104
+ lines = (function() {
105
+ var _i, _len, _ref1, _results;
106
+ _ref1 = code.split('\n');
107
+ _results = [];
108
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
109
+ line = _ref1[_i];
110
+ if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
111
+ _results.push(line);
112
+ } else if (maybe_code = /^\s*$/.test(line)) {
113
+ _results.push(line);
114
+ } else {
115
+ _results.push('# ' + line);
116
+ }
117
+ }
118
+ return _results;
119
+ })();
120
+ return lines.join('\n');
121
+ };
122
+
123
+ buildLocationData = function(first, last) {
124
+ if (!last) {
125
+ return first;
126
+ } else {
127
+ return {
128
+ first_line: first.first_line,
129
+ first_column: first.first_column,
130
+ last_line: last.last_line,
131
+ last_column: last.last_column
132
+ };
133
+ }
134
+ };
135
+
136
+ exports.addLocationDataFn = function(first, last) {
137
+ return function(obj) {
138
+ if (((typeof obj) === 'object') && (!!obj['updateLocationDataIfMissing'])) {
139
+ obj.updateLocationDataIfMissing(buildLocationData(first, last));
140
+ }
141
+ return obj;
142
+ };
143
+ };
144
+
145
+ exports.locationDataToString = function(obj) {
146
+ var locationData;
147
+ if (("2" in obj) && ("first_line" in obj[2])) {
148
+ locationData = obj[2];
149
+ } else if ("first_line" in obj) {
150
+ locationData = obj;
151
+ }
152
+ if (locationData) {
153
+ return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1));
154
+ } else {
155
+ return "No location data";
156
+ }
157
+ };
158
+
159
+ exports.baseFileName = function(file, stripExt, useWinPathSep) {
160
+ var parts, pathSep;
161
+ if (stripExt == null) {
162
+ stripExt = false;
163
+ }
164
+ if (useWinPathSep == null) {
165
+ useWinPathSep = false;
166
+ }
167
+ pathSep = useWinPathSep ? /\\|\// : /\//;
168
+ parts = file.split(pathSep);
169
+ file = parts[parts.length - 1];
170
+ if (!(stripExt && file.indexOf('.') >= 0)) {
171
+ return file;
172
+ }
173
+ parts = file.split('.');
174
+ parts.pop();
175
+ if (parts[parts.length - 1] === 'coffee' && parts.length > 1) {
176
+ parts.pop();
177
+ }
178
+ return parts.join('.');
179
+ };
180
+
181
+ exports.isCoffee = function(file) {
182
+ return /\.((lit)?coffee|coffee\.md)$/.test(file);
183
+ };
184
+
185
+ exports.isLiterate = function(file) {
186
+ return /\.(litcoffee|coffee\.md)$/.test(file);
187
+ };
188
+
189
+ exports.throwSyntaxError = function(message, location) {
190
+ var error;
191
+ error = new SyntaxError(message);
192
+ error.location = location;
193
+ error.toString = syntaxErrorToString;
194
+ error.stack = error.toString();
195
+ throw error;
196
+ };
197
+
198
+ exports.updateSyntaxError = function(error, code, filename) {
199
+ if (error.toString === syntaxErrorToString) {
200
+ error.code || (error.code = code);
201
+ error.filename || (error.filename = filename);
202
+ error.stack = error.toString();
203
+ }
204
+ return error;
205
+ };
206
+
207
+ syntaxErrorToString = function() {
208
+ var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2;
209
+ if (!(this.code && this.location)) {
210
+ return Error.prototype.toString.call(this);
211
+ }
212
+ _ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column;
213
+ if (last_line == null) {
214
+ last_line = first_line;
215
+ }
216
+ if (last_column == null) {
217
+ last_column = first_column;
218
+ }
219
+ filename = this.filename || '[stdin]';
220
+ codeLine = this.code.split('\n')[first_line];
221
+ start = first_column;
222
+ end = first_line === last_line ? last_column + 1 : codeLine.length;
223
+ marker = repeat(' ', start) + repeat('^', end - start);
224
+ if (typeof process !== "undefined" && process !== null) {
225
+ colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
226
+ }
227
+ if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) {
228
+ colorize = function(str) {
229
+ return "\x1B[1;31m" + str + "\x1B[0m";
230
+ };
231
+ codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
232
+ marker = colorize(marker);
233
+ }
234
+ return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
235
+ };
236
+
237
+ exports.nameWhitespaceCharacter = function(string) {
238
+ switch (string) {
239
+ case ' ':
240
+ return 'space';
241
+ case '\n':
242
+ return 'newline';
243
+ case '\r':
244
+ return 'carriage return';
245
+ case '\t':
246
+ return 'tab';
247
+ default:
248
+ return string;
249
+ }
250
+ };
251
+
252
+ }).call(this);
@@ -0,0 +1,11 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ var key, val, _ref;
4
+
5
+ _ref = require('./coffee-script');
6
+ for (key in _ref) {
7
+ val = _ref[key];
8
+ exports[key] = val;
9
+ }
10
+
11
+ }).call(this);
@@ -0,0 +1,926 @@
1
+ // Generated by CoffeeScript 1.7.1
2
+ (function() {
3
+ var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_ILLEGAL, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, STRICT_PROSCRIBED, TRAILING_SPACES, UNARY, UNARY_MATH, WHITESPACE, compact, count, invertLiterate, key, last, locationDataToString, repeat, starts, throwSyntaxError, _ref, _ref1,
4
+ __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; };
5
+
6
+ _ref = require('./rewriter'), Rewriter = _ref.Rewriter, INVERSES = _ref.INVERSES;
7
+
8
+ _ref1 = require('./helpers'), count = _ref1.count, starts = _ref1.starts, compact = _ref1.compact, last = _ref1.last, repeat = _ref1.repeat, invertLiterate = _ref1.invertLiterate, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError;
9
+
10
+ exports.Lexer = Lexer = (function() {
11
+ function Lexer() {}
12
+
13
+ Lexer.prototype.tokenize = function(code, opts) {
14
+ var consumed, i, tag, _ref2;
15
+ if (opts == null) {
16
+ opts = {};
17
+ }
18
+ this.literate = opts.literate;
19
+ this.indent = 0;
20
+ this.baseIndent = 0;
21
+ this.indebt = 0;
22
+ this.outdebt = 0;
23
+ this.indents = [];
24
+ this.ends = [];
25
+ this.tokens = [];
26
+ this.chunkLine = opts.line || 0;
27
+ this.chunkColumn = opts.column || 0;
28
+ code = this.clean(code);
29
+ i = 0;
30
+ while (this.chunk = code.slice(i)) {
31
+ consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
32
+ _ref2 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = _ref2[0], this.chunkColumn = _ref2[1];
33
+ i += consumed;
34
+ }
35
+ this.closeIndentation();
36
+ if (tag = this.ends.pop()) {
37
+ this.error("missing " + tag);
38
+ }
39
+ if (opts.rewrite === false) {
40
+ return this.tokens;
41
+ }
42
+ return (new Rewriter).rewrite(this.tokens);
43
+ };
44
+
45
+ Lexer.prototype.clean = function(code) {
46
+ if (code.charCodeAt(0) === BOM) {
47
+ code = code.slice(1);
48
+ }
49
+ code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
50
+ if (WHITESPACE.test(code)) {
51
+ code = "\n" + code;
52
+ this.chunkLine--;
53
+ }
54
+ if (this.literate) {
55
+ code = invertLiterate(code);
56
+ }
57
+ return code;
58
+ };
59
+
60
+ Lexer.prototype.identifierToken = function() {
61
+ var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, tag, tagToken, _ref2, _ref3, _ref4;
62
+ if (!(match = IDENTIFIER.exec(this.chunk))) {
63
+ return 0;
64
+ }
65
+ input = match[0], id = match[1], colon = match[2];
66
+ idLength = id.length;
67
+ poppedToken = void 0;
68
+ if (id === 'own' && this.tag() === 'FOR') {
69
+ this.token('OWN', id);
70
+ return id.length;
71
+ }
72
+ forcedIdentifier = colon || (prev = last(this.tokens)) && (((_ref2 = prev[0]) === '.' || _ref2 === '?.' || _ref2 === '::' || _ref2 === '?::') || !prev.spaced && prev[0] === '@');
73
+ tag = 'IDENTIFIER';
74
+ if (!forcedIdentifier && (__indexOf.call(JS_KEYWORDS, id) >= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) {
75
+ tag = id.toUpperCase();
76
+ if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) {
77
+ tag = 'LEADING_WHEN';
78
+ } else if (tag === 'FOR') {
79
+ this.seenFor = true;
80
+ } else if (tag === 'UNLESS') {
81
+ tag = 'IF';
82
+ } else if (__indexOf.call(UNARY, tag) >= 0) {
83
+ tag = 'UNARY';
84
+ } else if (__indexOf.call(RELATION, tag) >= 0) {
85
+ if (tag !== 'INSTANCEOF' && this.seenFor) {
86
+ tag = 'FOR' + tag;
87
+ this.seenFor = false;
88
+ } else {
89
+ tag = 'RELATION';
90
+ if (this.value() === '!') {
91
+ poppedToken = this.tokens.pop();
92
+ id = '!' + id;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ if (__indexOf.call(JS_FORBIDDEN, id) >= 0) {
98
+ if (forcedIdentifier) {
99
+ tag = 'IDENTIFIER';
100
+ id = new String(id);
101
+ id.reserved = true;
102
+ } else if (__indexOf.call(RESERVED, id) >= 0) {
103
+ this.error("reserved word \"" + id + "\"");
104
+ }
105
+ }
106
+ if (!forcedIdentifier) {
107
+ if (__indexOf.call(COFFEE_ALIASES, id) >= 0) {
108
+ id = COFFEE_ALIAS_MAP[id];
109
+ }
110
+ tag = (function() {
111
+ switch (id) {
112
+ case '!':
113
+ return 'UNARY';
114
+ case '==':
115
+ case '!=':
116
+ return 'COMPARE';
117
+ case '&&':
118
+ case '||':
119
+ return 'LOGIC';
120
+ case 'true':
121
+ case 'false':
122
+ return 'BOOL';
123
+ case 'break':
124
+ case 'continue':
125
+ return 'STATEMENT';
126
+ default:
127
+ return tag;
128
+ }
129
+ })();
130
+ }
131
+ tagToken = this.token(tag, id, 0, idLength);
132
+ if (poppedToken) {
133
+ _ref4 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = _ref4[0], tagToken[2].first_column = _ref4[1];
134
+ }
135
+ if (colon) {
136
+ colonOffset = input.lastIndexOf(':');
137
+ this.token(':', ':', colonOffset, colon.length);
138
+ }
139
+ return input.length;
140
+ };
141
+
142
+ Lexer.prototype.numberToken = function() {
143
+ var binaryLiteral, lexedLength, match, number, octalLiteral;
144
+ if (!(match = NUMBER.exec(this.chunk))) {
145
+ return 0;
146
+ }
147
+ number = match[0];
148
+ if (/^0[BOX]/.test(number)) {
149
+ this.error("radix prefix '" + number + "' must be lowercase");
150
+ } else if (/E/.test(number) && !/^0x/.test(number)) {
151
+ this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'");
152
+ } else if (/^0\d*[89]/.test(number)) {
153
+ this.error("decimal literal '" + number + "' must not be prefixed with '0'");
154
+ } else if (/^0\d+/.test(number)) {
155
+ this.error("octal literal '" + number + "' must be prefixed with '0o'");
156
+ }
157
+ lexedLength = number.length;
158
+ if (octalLiteral = /^0o([0-7]+)/.exec(number)) {
159
+ number = '0x' + parseInt(octalLiteral[1], 8).toString(16);
160
+ }
161
+ if (binaryLiteral = /^0b([01]+)/.exec(number)) {
162
+ number = '0x' + parseInt(binaryLiteral[1], 2).toString(16);
163
+ }
164
+ this.token('NUMBER', number, 0, lexedLength);
165
+ return lexedLength;
166
+ };
167
+
168
+ Lexer.prototype.stringToken = function() {
169
+ var octalEsc, quote, string, trimmed;
170
+ switch (quote = this.chunk.charAt(0)) {
171
+ case "'":
172
+ string = SIMPLESTR.exec(this.chunk)[0];
173
+ break;
174
+ case '"':
175
+ string = this.balancedString(this.chunk, '"');
176
+ }
177
+ if (!string) {
178
+ return 0;
179
+ }
180
+ trimmed = this.removeNewlines(string.slice(1, -1));
181
+ if (quote === '"' && 0 < string.indexOf('#{', 1)) {
182
+ this.interpolateString(trimmed, {
183
+ strOffset: 1,
184
+ lexedLength: string.length
185
+ });
186
+ } else {
187
+ this.token('STRING', quote + this.escapeLines(trimmed) + quote, 0, string.length);
188
+ }
189
+ if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) {
190
+ this.error("octal escape sequences " + string + " are not allowed");
191
+ }
192
+ return string.length;
193
+ };
194
+
195
+ Lexer.prototype.heredocToken = function() {
196
+ var doc, heredoc, match, quote;
197
+ if (!(match = HEREDOC.exec(this.chunk))) {
198
+ return 0;
199
+ }
200
+ heredoc = match[0];
201
+ quote = heredoc.charAt(0);
202
+ doc = this.sanitizeHeredoc(match[2], {
203
+ quote: quote,
204
+ indent: null
205
+ });
206
+ if (quote === '"' && 0 <= doc.indexOf('#{')) {
207
+ this.interpolateString(doc, {
208
+ heredoc: true,
209
+ strOffset: 3,
210
+ lexedLength: heredoc.length
211
+ });
212
+ } else {
213
+ this.token('STRING', this.makeString(doc, quote, true), 0, heredoc.length);
214
+ }
215
+ return heredoc.length;
216
+ };
217
+
218
+ Lexer.prototype.commentToken = function() {
219
+ var comment, here, match;
220
+ if (!(match = this.chunk.match(COMMENT))) {
221
+ return 0;
222
+ }
223
+ comment = match[0], here = match[1];
224
+ if (here) {
225
+ this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
226
+ herecomment: true,
227
+ indent: repeat(' ', this.indent)
228
+ }), 0, comment.length);
229
+ }
230
+ return comment.length;
231
+ };
232
+
233
+ Lexer.prototype.jsToken = function() {
234
+ var match, script;
235
+ if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
236
+ return 0;
237
+ }
238
+ this.token('JS', (script = match[0]).slice(1, -1), 0, script.length);
239
+ return script.length;
240
+ };
241
+
242
+ Lexer.prototype.regexToken = function() {
243
+ var flags, length, match, prev, regex, _ref2, _ref3;
244
+ if (this.chunk.charAt(0) !== '/') {
245
+ return 0;
246
+ }
247
+ if (length = this.heregexToken()) {
248
+ return length;
249
+ }
250
+ prev = last(this.tokens);
251
+ if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) {
252
+ return 0;
253
+ }
254
+ if (!(match = REGEX.exec(this.chunk))) {
255
+ return 0;
256
+ }
257
+ _ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2];
258
+ if (regex === '//') {
259
+ return 0;
260
+ }
261
+ if (regex.slice(0, 2) === '/*') {
262
+ this.error('regular expressions cannot begin with `*`');
263
+ }
264
+ this.token('REGEX', "" + regex + flags, 0, match.length);
265
+ return match.length;
266
+ };
267
+
268
+ Lexer.prototype.heregexToken = function() {
269
+ var body, flags, flagsOffset, heregex, match, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4;
270
+ if (!(match = HEREGEX.exec(this.chunk))) {
271
+ return 0;
272
+ }
273
+ heregex = match[0], body = match[1], flags = match[2];
274
+ if (0 > body.indexOf('#{')) {
275
+ re = this.escapeLines(body.replace(HEREGEX_OMIT, '$1$2').replace(/\//g, '\\/'), true);
276
+ if (re.match(/^\*/)) {
277
+ this.error('regular expressions cannot begin with `*`');
278
+ }
279
+ this.token('REGEX', "/" + (re || '(?:)') + "/" + flags, 0, heregex.length);
280
+ return heregex.length;
281
+ }
282
+ this.token('IDENTIFIER', 'RegExp', 0, 0);
283
+ this.token('CALL_START', '(', 0, 0);
284
+ tokens = [];
285
+ _ref2 = this.interpolateString(body, {
286
+ regex: true
287
+ });
288
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
289
+ token = _ref2[_i];
290
+ tag = token[0], value = token[1];
291
+ if (tag === 'TOKENS') {
292
+ tokens.push.apply(tokens, value);
293
+ } else if (tag === 'NEOSTRING') {
294
+ if (!(value = value.replace(HEREGEX_OMIT, '$1$2'))) {
295
+ continue;
296
+ }
297
+ value = value.replace(/\\/g, '\\\\');
298
+ token[0] = 'STRING';
299
+ token[1] = this.makeString(value, '"', true);
300
+ tokens.push(token);
301
+ } else {
302
+ this.error("Unexpected " + tag);
303
+ }
304
+ prev = last(this.tokens);
305
+ plusToken = ['+', '+'];
306
+ plusToken[2] = prev[2];
307
+ tokens.push(plusToken);
308
+ }
309
+ tokens.pop();
310
+ if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') {
311
+ this.token('STRING', '""', 0, 0);
312
+ this.token('+', '+', 0, 0);
313
+ }
314
+ (_ref4 = this.tokens).push.apply(_ref4, tokens);
315
+ if (flags) {
316
+ flagsOffset = heregex.lastIndexOf(flags);
317
+ this.token(',', ',', flagsOffset, 0);
318
+ this.token('STRING', '"' + flags + '"', flagsOffset, flags.length);
319
+ }
320
+ this.token(')', ')', heregex.length - 1, 0);
321
+ return heregex.length;
322
+ };
323
+
324
+ Lexer.prototype.lineToken = function() {
325
+ var diff, indent, match, noNewlines, size;
326
+ if (!(match = MULTI_DENT.exec(this.chunk))) {
327
+ return 0;
328
+ }
329
+ indent = match[0];
330
+ this.seenFor = false;
331
+ size = indent.length - 1 - indent.lastIndexOf('\n');
332
+ noNewlines = this.unfinished();
333
+ if (size - this.indebt === this.indent) {
334
+ if (noNewlines) {
335
+ this.suppressNewlines();
336
+ } else {
337
+ this.newlineToken(0);
338
+ }
339
+ return indent.length;
340
+ }
341
+ if (size > this.indent) {
342
+ if (noNewlines) {
343
+ this.indebt = size - this.indent;
344
+ this.suppressNewlines();
345
+ return indent.length;
346
+ }
347
+ if (!this.tokens.length) {
348
+ this.baseIndent = this.indent = size;
349
+ return indent.length;
350
+ }
351
+ diff = size - this.indent + this.outdebt;
352
+ this.token('INDENT', diff, indent.length - size, size);
353
+ this.indents.push(diff);
354
+ this.ends.push('OUTDENT');
355
+ this.outdebt = this.indebt = 0;
356
+ this.indent = size;
357
+ } else if (size < this.baseIndent) {
358
+ this.error('missing indentation', indent.length);
359
+ } else {
360
+ this.indebt = 0;
361
+ this.outdentToken(this.indent - size, noNewlines, indent.length);
362
+ }
363
+ return indent.length;
364
+ };
365
+
366
+ Lexer.prototype.outdentToken = function(moveOut, noNewlines, outdentLength) {
367
+ var decreasedIndent, dent, lastIndent, _ref2;
368
+ decreasedIndent = this.indent - moveOut;
369
+ while (moveOut > 0) {
370
+ lastIndent = this.indents[this.indents.length - 1];
371
+ if (!lastIndent) {
372
+ moveOut = 0;
373
+ } else if (lastIndent === this.outdebt) {
374
+ moveOut -= this.outdebt;
375
+ this.outdebt = 0;
376
+ } else if (lastIndent < this.outdebt) {
377
+ this.outdebt -= lastIndent;
378
+ moveOut -= lastIndent;
379
+ } else {
380
+ dent = this.indents.pop() + this.outdebt;
381
+ if (outdentLength && (_ref2 = this.chunk[outdentLength], __indexOf.call(INDENTABLE_CLOSERS, _ref2) >= 0)) {
382
+ decreasedIndent -= dent - moveOut;
383
+ moveOut = dent;
384
+ }
385
+ this.outdebt = 0;
386
+ this.pair('OUTDENT');
387
+ this.token('OUTDENT', moveOut, 0, outdentLength);
388
+ moveOut -= dent;
389
+ }
390
+ }
391
+ if (dent) {
392
+ this.outdebt -= moveOut;
393
+ }
394
+ while (this.value() === ';') {
395
+ this.tokens.pop();
396
+ }
397
+ if (!(this.tag() === 'TERMINATOR' || noNewlines)) {
398
+ this.token('TERMINATOR', '\n', outdentLength, 0);
399
+ }
400
+ this.indent = decreasedIndent;
401
+ return this;
402
+ };
403
+
404
+ Lexer.prototype.whitespaceToken = function() {
405
+ var match, nline, prev;
406
+ if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) {
407
+ return 0;
408
+ }
409
+ prev = last(this.tokens);
410
+ if (prev) {
411
+ prev[match ? 'spaced' : 'newLine'] = true;
412
+ }
413
+ if (match) {
414
+ return match[0].length;
415
+ } else {
416
+ return 0;
417
+ }
418
+ };
419
+
420
+ Lexer.prototype.newlineToken = function(offset) {
421
+ while (this.value() === ';') {
422
+ this.tokens.pop();
423
+ }
424
+ if (this.tag() !== 'TERMINATOR') {
425
+ this.token('TERMINATOR', '\n', offset, 0);
426
+ }
427
+ return this;
428
+ };
429
+
430
+ Lexer.prototype.suppressNewlines = function() {
431
+ if (this.value() === '\\') {
432
+ this.tokens.pop();
433
+ }
434
+ return this;
435
+ };
436
+
437
+ Lexer.prototype.literalToken = function() {
438
+ var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5;
439
+ if (match = OPERATOR.exec(this.chunk)) {
440
+ value = match[0];
441
+ if (CODE.test(value)) {
442
+ this.tagParameters();
443
+ }
444
+ } else {
445
+ value = this.chunk.charAt(0);
446
+ }
447
+ tag = value;
448
+ prev = last(this.tokens);
449
+ if (value === '=' && prev) {
450
+ if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) {
451
+ this.error("reserved word \"" + (this.value()) + "\" can't be assigned");
452
+ }
453
+ if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') {
454
+ prev[0] = 'COMPOUND_ASSIGN';
455
+ prev[1] += '=';
456
+ return value.length;
457
+ }
458
+ }
459
+ if (value === ';') {
460
+ this.seenFor = false;
461
+ tag = 'TERMINATOR';
462
+ } else if (__indexOf.call(MATH, value) >= 0) {
463
+ tag = 'MATH';
464
+ } else if (__indexOf.call(COMPARE, value) >= 0) {
465
+ tag = 'COMPARE';
466
+ } else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) {
467
+ tag = 'COMPOUND_ASSIGN';
468
+ } else if (__indexOf.call(UNARY, value) >= 0) {
469
+ tag = 'UNARY';
470
+ } else if (__indexOf.call(UNARY_MATH, value) >= 0) {
471
+ tag = 'UNARY_MATH';
472
+ } else if (__indexOf.call(SHIFT, value) >= 0) {
473
+ tag = 'SHIFT';
474
+ } else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) {
475
+ tag = 'LOGIC';
476
+ } else if (prev && !prev.spaced) {
477
+ if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) {
478
+ if (prev[0] === '?') {
479
+ prev[0] = 'FUNC_EXIST';
480
+ }
481
+ tag = 'CALL_START';
482
+ } else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) {
483
+ tag = 'INDEX_START';
484
+ switch (prev[0]) {
485
+ case '?':
486
+ prev[0] = 'INDEX_SOAK';
487
+ }
488
+ }
489
+ }
490
+ switch (value) {
491
+ case '(':
492
+ case '{':
493
+ case '[':
494
+ this.ends.push(INVERSES[value]);
495
+ break;
496
+ case ')':
497
+ case '}':
498
+ case ']':
499
+ this.pair(value);
500
+ }
501
+ this.token(tag, value);
502
+ return value.length;
503
+ };
504
+
505
+ Lexer.prototype.sanitizeHeredoc = function(doc, options) {
506
+ var attempt, herecomment, indent, match, _ref2;
507
+ indent = options.indent, herecomment = options.herecomment;
508
+ if (herecomment) {
509
+ if (HEREDOC_ILLEGAL.test(doc)) {
510
+ this.error("block comment cannot contain \"*/\", starting");
511
+ }
512
+ if (doc.indexOf('\n') < 0) {
513
+ return doc;
514
+ }
515
+ } else {
516
+ while (match = HEREDOC_INDENT.exec(doc)) {
517
+ attempt = match[1];
518
+ if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) {
519
+ indent = attempt;
520
+ }
521
+ }
522
+ }
523
+ if (indent) {
524
+ doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
525
+ }
526
+ if (!herecomment) {
527
+ doc = doc.replace(/^\n/, '');
528
+ }
529
+ return doc;
530
+ };
531
+
532
+ Lexer.prototype.tagParameters = function() {
533
+ var i, stack, tok, tokens;
534
+ if (this.tag() !== ')') {
535
+ return this;
536
+ }
537
+ stack = [];
538
+ tokens = this.tokens;
539
+ i = tokens.length;
540
+ tokens[--i][0] = 'PARAM_END';
541
+ while (tok = tokens[--i]) {
542
+ switch (tok[0]) {
543
+ case ')':
544
+ stack.push(tok);
545
+ break;
546
+ case '(':
547
+ case 'CALL_START':
548
+ if (stack.length) {
549
+ stack.pop();
550
+ } else if (tok[0] === '(') {
551
+ tok[0] = 'PARAM_START';
552
+ return this;
553
+ } else {
554
+ return this;
555
+ }
556
+ }
557
+ }
558
+ return this;
559
+ };
560
+
561
+ Lexer.prototype.closeIndentation = function() {
562
+ return this.outdentToken(this.indent);
563
+ };
564
+
565
+ Lexer.prototype.balancedString = function(str, end) {
566
+ var continueCount, i, letter, match, prev, stack, _i, _ref2;
567
+ continueCount = 0;
568
+ stack = [end];
569
+ for (i = _i = 1, _ref2 = str.length; 1 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 1 <= _ref2 ? ++_i : --_i) {
570
+ if (continueCount) {
571
+ --continueCount;
572
+ continue;
573
+ }
574
+ switch (letter = str.charAt(i)) {
575
+ case '\\':
576
+ ++continueCount;
577
+ continue;
578
+ case end:
579
+ stack.pop();
580
+ if (!stack.length) {
581
+ return str.slice(0, +i + 1 || 9e9);
582
+ }
583
+ end = stack[stack.length - 1];
584
+ continue;
585
+ }
586
+ if (end === '}' && (letter === '"' || letter === "'")) {
587
+ stack.push(end = letter);
588
+ } else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) {
589
+ continueCount += match[0].length - 1;
590
+ } else if (end === '}' && letter === '{') {
591
+ stack.push(end = '}');
592
+ } else if (end === '"' && prev === '#' && letter === '{') {
593
+ stack.push(end = '}');
594
+ }
595
+ prev = letter;
596
+ }
597
+ return this.error("missing " + (stack.pop()) + ", starting");
598
+ };
599
+
600
+ Lexer.prototype.interpolateString = function(str, options) {
601
+ var column, errorToken, expr, heredoc, i, inner, interpolated, len, letter, lexedLength, line, locationToken, nested, offsetInChunk, pi, plusToken, popped, regex, rparen, strOffset, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4;
602
+ if (options == null) {
603
+ options = {};
604
+ }
605
+ heredoc = options.heredoc, regex = options.regex, offsetInChunk = options.offsetInChunk, strOffset = options.strOffset, lexedLength = options.lexedLength;
606
+ offsetInChunk || (offsetInChunk = 0);
607
+ strOffset || (strOffset = 0);
608
+ lexedLength || (lexedLength = str.length);
609
+ tokens = [];
610
+ pi = 0;
611
+ i = -1;
612
+ while (letter = str.charAt(i += 1)) {
613
+ if (letter === '\\') {
614
+ i += 1;
615
+ continue;
616
+ }
617
+ if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
618
+ continue;
619
+ }
620
+ if (pi < i) {
621
+ tokens.push(this.makeToken('NEOSTRING', str.slice(pi, i), strOffset + pi));
622
+ }
623
+ if (!errorToken) {
624
+ errorToken = this.makeToken('', 'string interpolation', offsetInChunk + i + 1, 2);
625
+ }
626
+ inner = expr.slice(1, -1);
627
+ if (inner.length) {
628
+ _ref2 = this.getLineAndColumnFromChunk(strOffset + i + 1), line = _ref2[0], column = _ref2[1];
629
+ nested = new Lexer().tokenize(inner, {
630
+ line: line,
631
+ column: column,
632
+ rewrite: false
633
+ });
634
+ popped = nested.pop();
635
+ if (((_ref3 = nested[0]) != null ? _ref3[0] : void 0) === 'TERMINATOR') {
636
+ popped = nested.shift();
637
+ }
638
+ if (len = nested.length) {
639
+ if (len > 1) {
640
+ nested.unshift(this.makeToken('(', '(', strOffset + i + 1, 0));
641
+ nested.push(this.makeToken(')', ')', strOffset + i + 1 + inner.length, 0));
642
+ }
643
+ tokens.push(['TOKENS', nested]);
644
+ }
645
+ }
646
+ i += expr.length;
647
+ pi = i + 1;
648
+ }
649
+ if ((i > pi && pi < str.length)) {
650
+ tokens.push(this.makeToken('NEOSTRING', str.slice(pi), strOffset + pi));
651
+ }
652
+ if (regex) {
653
+ return tokens;
654
+ }
655
+ if (!tokens.length) {
656
+ return this.token('STRING', '""', offsetInChunk, lexedLength);
657
+ }
658
+ if (tokens[0][0] !== 'NEOSTRING') {
659
+ tokens.unshift(this.makeToken('NEOSTRING', '', offsetInChunk));
660
+ }
661
+ if (interpolated = tokens.length > 1) {
662
+ this.token('(', '(', offsetInChunk, 0, errorToken);
663
+ }
664
+ for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) {
665
+ token = tokens[i];
666
+ tag = token[0], value = token[1];
667
+ if (i) {
668
+ if (i) {
669
+ plusToken = this.token('+', '+');
670
+ }
671
+ locationToken = tag === 'TOKENS' ? value[0] : token;
672
+ plusToken[2] = {
673
+ first_line: locationToken[2].first_line,
674
+ first_column: locationToken[2].first_column,
675
+ last_line: locationToken[2].first_line,
676
+ last_column: locationToken[2].first_column
677
+ };
678
+ }
679
+ if (tag === 'TOKENS') {
680
+ (_ref4 = this.tokens).push.apply(_ref4, value);
681
+ } else if (tag === 'NEOSTRING') {
682
+ token[0] = 'STRING';
683
+ token[1] = this.makeString(value, '"', heredoc);
684
+ this.tokens.push(token);
685
+ } else {
686
+ this.error("Unexpected " + tag);
687
+ }
688
+ }
689
+ if (interpolated) {
690
+ rparen = this.makeToken(')', ')', offsetInChunk + lexedLength, 0);
691
+ rparen.stringEnd = true;
692
+ this.tokens.push(rparen);
693
+ }
694
+ return tokens;
695
+ };
696
+
697
+ Lexer.prototype.pair = function(tag) {
698
+ var wanted;
699
+ if (tag !== (wanted = last(this.ends))) {
700
+ if ('OUTDENT' !== wanted) {
701
+ this.error("unmatched " + tag);
702
+ }
703
+ this.outdentToken(last(this.indents), true);
704
+ return this.pair(tag);
705
+ }
706
+ return this.ends.pop();
707
+ };
708
+
709
+ Lexer.prototype.getLineAndColumnFromChunk = function(offset) {
710
+ var column, lineCount, lines, string;
711
+ if (offset === 0) {
712
+ return [this.chunkLine, this.chunkColumn];
713
+ }
714
+ if (offset >= this.chunk.length) {
715
+ string = this.chunk;
716
+ } else {
717
+ string = this.chunk.slice(0, +(offset - 1) + 1 || 9e9);
718
+ }
719
+ lineCount = count(string, '\n');
720
+ column = this.chunkColumn;
721
+ if (lineCount > 0) {
722
+ lines = string.split('\n');
723
+ column = last(lines).length;
724
+ } else {
725
+ column += string.length;
726
+ }
727
+ return [this.chunkLine + lineCount, column];
728
+ };
729
+
730
+ Lexer.prototype.makeToken = function(tag, value, offsetInChunk, length) {
731
+ var lastCharacter, locationData, token, _ref2, _ref3;
732
+ if (offsetInChunk == null) {
733
+ offsetInChunk = 0;
734
+ }
735
+ if (length == null) {
736
+ length = value.length;
737
+ }
738
+ locationData = {};
739
+ _ref2 = this.getLineAndColumnFromChunk(offsetInChunk), locationData.first_line = _ref2[0], locationData.first_column = _ref2[1];
740
+ lastCharacter = Math.max(0, length - 1);
741
+ _ref3 = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1];
742
+ token = [tag, value, locationData];
743
+ return token;
744
+ };
745
+
746
+ Lexer.prototype.token = function(tag, value, offsetInChunk, length, origin) {
747
+ var token;
748
+ token = this.makeToken(tag, value, offsetInChunk, length);
749
+ if (origin) {
750
+ token.origin = origin;
751
+ }
752
+ this.tokens.push(token);
753
+ return token;
754
+ };
755
+
756
+ Lexer.prototype.tag = function(index, tag) {
757
+ var tok;
758
+ return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]);
759
+ };
760
+
761
+ Lexer.prototype.value = function(index, val) {
762
+ var tok;
763
+ return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]);
764
+ };
765
+
766
+ Lexer.prototype.unfinished = function() {
767
+ var _ref2;
768
+ return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === 'UNARY_MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === '**' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS');
769
+ };
770
+
771
+ Lexer.prototype.removeNewlines = function(str) {
772
+ return str.replace(/^\s*\n\s*/, '').replace(/([^\\]|\\\\)\s*\n\s*$/, '$1');
773
+ };
774
+
775
+ Lexer.prototype.escapeLines = function(str, heredoc) {
776
+ str = str.replace(/\\[^\S\n]*(\n|\\)\s*/g, function(escaped, character) {
777
+ if (character === '\n') {
778
+ return '';
779
+ } else {
780
+ return escaped;
781
+ }
782
+ });
783
+ if (heredoc) {
784
+ return str.replace(MULTILINER, '\\n');
785
+ } else {
786
+ return str.replace(/\s*\n\s*/g, ' ');
787
+ }
788
+ };
789
+
790
+ Lexer.prototype.makeString = function(body, quote, heredoc) {
791
+ if (!body) {
792
+ return quote + quote;
793
+ }
794
+ body = body.replace(RegExp("\\\\(" + quote + "|\\\\)", "g"), function(match, contents) {
795
+ if (contents === quote) {
796
+ return contents;
797
+ } else {
798
+ return match;
799
+ }
800
+ });
801
+ body = body.replace(RegExp("" + quote, "g"), '\\$&');
802
+ return quote + this.escapeLines(body, heredoc) + quote;
803
+ };
804
+
805
+ Lexer.prototype.error = function(message, offset) {
806
+ var first_column, first_line, _ref2;
807
+ if (offset == null) {
808
+ offset = 0;
809
+ }
810
+ _ref2 = this.getLineAndColumnFromChunk(offset), first_line = _ref2[0], first_column = _ref2[1];
811
+ return throwSyntaxError(message, {
812
+ first_line: first_line,
813
+ first_column: first_column
814
+ });
815
+ };
816
+
817
+ return Lexer;
818
+
819
+ })();
820
+
821
+ JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super'];
822
+
823
+ COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'];
824
+
825
+ COFFEE_ALIAS_MAP = {
826
+ and: '&&',
827
+ or: '||',
828
+ is: '==',
829
+ isnt: '!=',
830
+ not: '!',
831
+ yes: 'true',
832
+ no: 'false',
833
+ on: 'true',
834
+ off: 'false'
835
+ };
836
+
837
+ COFFEE_ALIASES = (function() {
838
+ var _results;
839
+ _results = [];
840
+ for (key in COFFEE_ALIAS_MAP) {
841
+ _results.push(key);
842
+ }
843
+ return _results;
844
+ })();
845
+
846
+ COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES);
847
+
848
+ RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield'];
849
+
850
+ STRICT_PROSCRIBED = ['arguments', 'eval'];
851
+
852
+ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED);
853
+
854
+ exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED);
855
+
856
+ exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED;
857
+
858
+ BOM = 65279;
859
+
860
+ IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/;
861
+
862
+ NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i;
863
+
864
+ HEREDOC = /^("""|''')((?:\\[\s\S]|[^\\])*?)(?:\n[^\n\S]*)?\1/;
865
+
866
+ OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>*\/%])\2=?|\?(\.|::)|\.{2,3})/;
867
+
868
+ WHITESPACE = /^[^\n\S]+/;
869
+
870
+ COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|###$)|^(?:\s*#(?!##[^#]).*)+/;
871
+
872
+ CODE = /^[-=]>/;
873
+
874
+ MULTI_DENT = /^(?:\n[^\n\S]*)+/;
875
+
876
+ SIMPLESTR = /^'[^\\']*(?:\\[\s\S][^\\']*)*'/;
877
+
878
+ JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
879
+
880
+ REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/;
881
+
882
+ HEREGEX = /^\/{3}((?:\\?[\s\S])+?)\/{3}([imgy]{0,4})(?!\w)/;
883
+
884
+ HEREGEX_OMIT = /((?:\\\\)+)|\\(\s|\/)|\s+(?:#.*)?/g;
885
+
886
+ MULTILINER = /\n/g;
887
+
888
+ HEREDOC_INDENT = /\n+([^\n\S]*)/g;
889
+
890
+ HEREDOC_ILLEGAL = /\*\//;
891
+
892
+ LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/;
893
+
894
+ TRAILING_SPACES = /\s+$/;
895
+
896
+ COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|=', '**=', '//=', '%%='];
897
+
898
+ UNARY = ['NEW', 'TYPEOF', 'DELETE', 'DO'];
899
+
900
+ UNARY_MATH = ['!', '~'];
901
+
902
+ LOGIC = ['&&', '||', '&', '|', '^'];
903
+
904
+ SHIFT = ['<<', '>>', '>>>'];
905
+
906
+ COMPARE = ['==', '!=', '<', '>', '<=', '>='];
907
+
908
+ MATH = ['*', '/', '%', '//', '%%'];
909
+
910
+ RELATION = ['IN', 'OF', 'INSTANCEOF'];
911
+
912
+ BOOL = ['TRUE', 'FALSE'];
913
+
914
+ NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--'];
915
+
916
+ NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']');
917
+
918
+ CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
919
+
920
+ INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED');
921
+
922
+ LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
923
+
924
+ INDENTABLE_CLOSERS = [')', '}', ']'];
925
+
926
+ }).call(this);