spade-packager 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. data/.gitignore +2 -0
  2. data/.gitmodules +6 -0
  3. data/bin/spadepkg +8 -0
  4. data/lib/libgems_ext.rb +8 -0
  5. data/lib/libgems_ext/config_file.rb +33 -0
  6. data/lib/libgems_ext/dependency_installer.rb +150 -0
  7. data/lib/libgems_ext/installer.rb +39 -0
  8. data/lib/libgems_ext/libgems.rb +39 -0
  9. data/lib/libgems_ext/spec_fetcher.rb +11 -0
  10. data/lib/spade-packager.rb +1 -0
  11. data/lib/spade/packager.rb +18 -0
  12. data/lib/spade/packager/cli.rb +9 -0
  13. data/lib/spade/packager/cli/base.rb +196 -0
  14. data/lib/spade/packager/cli/owner.rb +46 -0
  15. data/lib/spade/packager/cli/project_generator.rb +117 -0
  16. data/lib/spade/packager/credentials.rb +38 -0
  17. data/lib/spade/packager/local.rb +50 -0
  18. data/lib/spade/packager/package.rb +160 -0
  19. data/lib/spade/packager/remote.rb +98 -0
  20. data/lib/spade/packager/repository.rb +18 -0
  21. data/lib/spade/packager/version.rb +5 -0
  22. data/packages/coffee-script/.gitignore +8 -0
  23. data/packages/coffee-script/.npmignore +11 -0
  24. data/packages/coffee-script/Cakefile +229 -0
  25. data/packages/coffee-script/LICENSE +22 -0
  26. data/packages/coffee-script/README +47 -0
  27. data/packages/coffee-script/Rakefile +78 -0
  28. data/packages/coffee-script/bin/cake +7 -0
  29. data/packages/coffee-script/bin/coffee +7 -0
  30. data/packages/coffee-script/documentation/coffee/aliases.coffee +11 -0
  31. data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +2 -0
  32. data/packages/coffee-script/documentation/coffee/block_comment.coffee +6 -0
  33. data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +9 -0
  34. data/packages/coffee-script/documentation/coffee/classes.coffee +25 -0
  35. data/packages/coffee-script/documentation/coffee/comparisons.coffee +5 -0
  36. data/packages/coffee-script/documentation/coffee/conditionals.coffee +13 -0
  37. data/packages/coffee-script/documentation/coffee/default_args.coffee +8 -0
  38. data/packages/coffee-script/documentation/coffee/do.coffee +4 -0
  39. data/packages/coffee-script/documentation/coffee/embedded.coffee +5 -0
  40. data/packages/coffee-script/documentation/coffee/existence.coffee +10 -0
  41. data/packages/coffee-script/documentation/coffee/expressions.coffee +9 -0
  42. data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +3 -0
  43. data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +3 -0
  44. data/packages/coffee-script/documentation/coffee/expressions_try.coffee +7 -0
  45. data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +6 -0
  46. data/packages/coffee-script/documentation/coffee/functions.coffee +2 -0
  47. data/packages/coffee-script/documentation/coffee/heredocs.coffee +7 -0
  48. data/packages/coffee-script/documentation/coffee/heregexes.coffee +11 -0
  49. data/packages/coffee-script/documentation/coffee/interpolation.coffee +6 -0
  50. data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +7 -0
  51. data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +4 -0
  52. data/packages/coffee-script/documentation/coffee/object_extraction.coffee +13 -0
  53. data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +19 -0
  54. data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +5 -0
  55. data/packages/coffee-script/documentation/coffee/overview.coffee +28 -0
  56. data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +6 -0
  57. data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +7 -0
  58. data/packages/coffee-script/documentation/coffee/prototypes.coffee +3 -0
  59. data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +2 -0
  60. data/packages/coffee-script/documentation/coffee/scope.coffee +5 -0
  61. data/packages/coffee-script/documentation/coffee/slices.coffee +7 -0
  62. data/packages/coffee-script/documentation/coffee/soaks.coffee +1 -0
  63. data/packages/coffee-script/documentation/coffee/splats.coffee +27 -0
  64. data/packages/coffee-script/documentation/coffee/splices.coffee +5 -0
  65. data/packages/coffee-script/documentation/coffee/strings.coffee +8 -0
  66. data/packages/coffee-script/documentation/coffee/switch.coffee +10 -0
  67. data/packages/coffee-script/documentation/coffee/try.coffee +8 -0
  68. data/packages/coffee-script/documentation/coffee/while.coffee +10 -0
  69. data/packages/coffee-script/documentation/css/docs.css +374 -0
  70. data/packages/coffee-script/documentation/css/idle.css +64 -0
  71. data/packages/coffee-script/documentation/docs/browser.html +25 -0
  72. data/packages/coffee-script/documentation/docs/cake.html +43 -0
  73. data/packages/coffee-script/documentation/docs/coffee-script.html +51 -0
  74. data/packages/coffee-script/documentation/docs/command.html +161 -0
  75. data/packages/coffee-script/documentation/docs/docco.css +186 -0
  76. data/packages/coffee-script/documentation/docs/grammar.html +399 -0
  77. data/packages/coffee-script/documentation/docs/helpers.html +31 -0
  78. data/packages/coffee-script/documentation/docs/index.html +3 -0
  79. data/packages/coffee-script/documentation/docs/lexer.html +490 -0
  80. data/packages/coffee-script/documentation/docs/nodes.html +1338 -0
  81. data/packages/coffee-script/documentation/docs/optparse.html +78 -0
  82. data/packages/coffee-script/documentation/docs/repl.html +24 -0
  83. data/packages/coffee-script/documentation/docs/rewriter.html +251 -0
  84. data/packages/coffee-script/documentation/docs/scope.html +54 -0
  85. data/packages/coffee-script/documentation/docs/underscore.html +295 -0
  86. data/packages/coffee-script/documentation/images/background.png +0 -0
  87. data/packages/coffee-script/documentation/images/banding.png +0 -0
  88. data/packages/coffee-script/documentation/images/button_bg.png +0 -0
  89. data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
  90. data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
  91. data/packages/coffee-script/documentation/images/favicon.ico +0 -0
  92. data/packages/coffee-script/documentation/images/logo.png +0 -0
  93. data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
  94. data/packages/coffee-script/documentation/index.html.erb +1607 -0
  95. data/packages/coffee-script/documentation/js/aliases.js +17 -0
  96. data/packages/coffee-script/documentation/js/array_comprehensions.js +6 -0
  97. data/packages/coffee-script/documentation/js/block_comment.js +4 -0
  98. data/packages/coffee-script/documentation/js/cake_tasks.js +10 -0
  99. data/packages/coffee-script/documentation/js/classes.js +44 -0
  100. data/packages/coffee-script/documentation/js/comparisons.js +3 -0
  101. data/packages/coffee-script/documentation/js/conditionals.js +12 -0
  102. data/packages/coffee-script/documentation/js/default_args.js +7 -0
  103. data/packages/coffee-script/documentation/js/do.js +10 -0
  104. data/packages/coffee-script/documentation/js/embedded.js +4 -0
  105. data/packages/coffee-script/documentation/js/existence.js +6 -0
  106. data/packages/coffee-script/documentation/js/expressions.js +15 -0
  107. data/packages/coffee-script/documentation/js/expressions_assignment.js +2 -0
  108. data/packages/coffee-script/documentation/js/expressions_comprehension.js +9 -0
  109. data/packages/coffee-script/documentation/js/expressions_try.js +7 -0
  110. data/packages/coffee-script/documentation/js/fat_arrow.js +9 -0
  111. data/packages/coffee-script/documentation/js/functions.js +7 -0
  112. data/packages/coffee-script/documentation/js/heredocs.js +2 -0
  113. data/packages/coffee-script/documentation/js/heregexes.js +2 -0
  114. data/packages/coffee-script/documentation/js/interpolation.js +4 -0
  115. data/packages/coffee-script/documentation/js/multiple_return_values.js +5 -0
  116. data/packages/coffee-script/documentation/js/object_comprehensions.js +15 -0
  117. data/packages/coffee-script/documentation/js/object_extraction.js +10 -0
  118. data/packages/coffee-script/documentation/js/objects_and_arrays.js +17 -0
  119. data/packages/coffee-script/documentation/js/objects_reserved.js +4 -0
  120. data/packages/coffee-script/documentation/js/overview.js +35 -0
  121. data/packages/coffee-script/documentation/js/parallel_assignment.js +4 -0
  122. data/packages/coffee-script/documentation/js/patterns_and_splats.js +4 -0
  123. data/packages/coffee-script/documentation/js/prototypes.js +3 -0
  124. data/packages/coffee-script/documentation/js/range_comprehensions.js +9 -0
  125. data/packages/coffee-script/documentation/js/scope.js +8 -0
  126. data/packages/coffee-script/documentation/js/slices.js +4 -0
  127. data/packages/coffee-script/documentation/js/soaks.js +2 -0
  128. data/packages/coffee-script/documentation/js/splats.js +15 -0
  129. data/packages/coffee-script/documentation/js/splices.js +3 -0
  130. data/packages/coffee-script/documentation/js/strings.js +2 -0
  131. data/packages/coffee-script/documentation/js/switch.js +23 -0
  132. data/packages/coffee-script/documentation/js/try.js +8 -0
  133. data/packages/coffee-script/documentation/js/while.js +18 -0
  134. data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +6240 -0
  135. data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +16 -0
  136. data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +13 -0
  137. data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +34 -0
  138. data/packages/coffee-script/examples/blocks.coffee +54 -0
  139. data/packages/coffee-script/examples/code.coffee +167 -0
  140. data/packages/coffee-script/examples/computer_science/README +4 -0
  141. data/packages/coffee-script/examples/computer_science/binary_search.coffee +25 -0
  142. data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +11 -0
  143. data/packages/coffee-script/examples/computer_science/linked_list.coffee +108 -0
  144. data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +36 -0
  145. data/packages/coffee-script/examples/computer_science/merge_sort.coffee +19 -0
  146. data/packages/coffee-script/examples/computer_science/selection_sort.coffee +23 -0
  147. data/packages/coffee-script/examples/poignant.coffee +181 -0
  148. data/packages/coffee-script/examples/potion.coffee +206 -0
  149. data/packages/coffee-script/examples/underscore.coffee +682 -0
  150. data/packages/coffee-script/examples/web_server.coffee +12 -0
  151. data/packages/coffee-script/extras/EXTRAS +7 -0
  152. data/packages/coffee-script/extras/coffee-script.js +8 -0
  153. data/packages/coffee-script/extras/jsl.conf +44 -0
  154. data/packages/coffee-script/index.html +2515 -0
  155. data/packages/coffee-script/lib/browser.js +52 -0
  156. data/packages/coffee-script/lib/cake.js +76 -0
  157. data/packages/coffee-script/lib/coffee-script.js +82 -0
  158. data/packages/coffee-script/lib/command.js +263 -0
  159. data/packages/coffee-script/lib/grammar.js +581 -0
  160. data/packages/coffee-script/lib/helpers.js +66 -0
  161. data/packages/coffee-script/lib/index.js +8 -0
  162. data/packages/coffee-script/lib/lexer.js +633 -0
  163. data/packages/coffee-script/lib/nodes.js +2165 -0
  164. data/packages/coffee-script/lib/optparse.js +111 -0
  165. data/packages/coffee-script/lib/parser.js +649 -0
  166. data/packages/coffee-script/lib/repl.js +42 -0
  167. data/packages/coffee-script/lib/rewriter.js +353 -0
  168. data/packages/coffee-script/lib/scope.js +120 -0
  169. data/packages/coffee-script/lib/spade-format.js +45 -0
  170. data/packages/coffee-script/package.json +26 -0
  171. data/packages/coffee-script/src/browser.coffee +43 -0
  172. data/packages/coffee-script/src/cake.coffee +69 -0
  173. data/packages/coffee-script/src/coffee-script.coffee +92 -0
  174. data/packages/coffee-script/src/command.coffee +214 -0
  175. data/packages/coffee-script/src/grammar.coffee +590 -0
  176. data/packages/coffee-script/src/helpers.coffee +56 -0
  177. data/packages/coffee-script/src/index.coffee +2 -0
  178. data/packages/coffee-script/src/lexer.coffee +653 -0
  179. data/packages/coffee-script/src/nodes.coffee +1754 -0
  180. data/packages/coffee-script/src/optparse.coffee +99 -0
  181. data/packages/coffee-script/src/repl.coffee +42 -0
  182. data/packages/coffee-script/src/rewriter.coffee +326 -0
  183. data/packages/coffee-script/src/scope.coffee +94 -0
  184. data/packages/coffee-script/test/arguments.coffee +127 -0
  185. data/packages/coffee-script/test/assignment.coffee +98 -0
  186. data/packages/coffee-script/test/break.coffee +18 -0
  187. data/packages/coffee-script/test/comments.coffee +201 -0
  188. data/packages/coffee-script/test/conditionals.coffee +181 -0
  189. data/packages/coffee-script/test/exception_handling.coffee +90 -0
  190. data/packages/coffee-script/test/helpers.coffee +96 -0
  191. data/packages/coffee-script/test/importing.coffee +18 -0
  192. data/packages/coffee-script/test/operators.coffee +225 -0
  193. data/packages/coffee-script/test/ranges_slices_and_splices.coffee +186 -0
  194. data/packages/coffee-script/test/regular_expressions.coffee +56 -0
  195. data/packages/coffee-script/test/test.html +123 -0
  196. data/packages/coffee-script/test/test_chaining.coffee +77 -0
  197. data/packages/coffee-script/test/test_classes.coffee +372 -0
  198. data/packages/coffee-script/test/test_compilation.coffee +26 -0
  199. data/packages/coffee-script/test/test_comprehensions.coffee +318 -0
  200. data/packages/coffee-script/test/test_existence.coffee +165 -0
  201. data/packages/coffee-script/test/test_functions.coffee +379 -0
  202. data/packages/coffee-script/test/test_heredocs.coffee +111 -0
  203. data/packages/coffee-script/test/test_literals.coffee +270 -0
  204. data/packages/coffee-script/test/test_option_parser.coffee +27 -0
  205. data/packages/coffee-script/test/test_pattern_matching.coffee +162 -0
  206. data/packages/coffee-script/test/test_returns.coffee +63 -0
  207. data/packages/coffee-script/test/test_splats.coffee +102 -0
  208. data/packages/coffee-script/test/test_strings.coffee +118 -0
  209. data/packages/coffee-script/test/test_switch.coffee +103 -0
  210. data/packages/coffee-script/test/test_while.coffee +71 -0
  211. data/packages/ivory/LICENSE.txt +1 -0
  212. data/packages/ivory/README.md +19 -0
  213. data/packages/ivory/lib/buffer.js +111 -0
  214. data/packages/ivory/lib/events.js +137 -0
  215. data/packages/ivory/lib/fs.js +266 -0
  216. data/packages/ivory/lib/main.js +13 -0
  217. data/packages/ivory/lib/path.js +158 -0
  218. data/packages/ivory/lib/ruby/buffer.rb +145 -0
  219. data/packages/ivory/lib/ruby/constants.rb +585 -0
  220. data/packages/ivory/lib/ruby/events.rb +32 -0
  221. data/packages/ivory/lib/ruby/fs.rb +245 -0
  222. data/packages/ivory/lib/ruby/process.rb +28 -0
  223. data/packages/ivory/lib/stream.js +115 -0
  224. data/packages/ivory/lib/util.js +414 -0
  225. data/packages/ivory/package.json +11 -0
  226. data/packages/ivory/spade-boot.js +78 -0
  227. data/packages/jquery/main.js +7179 -0
  228. data/packages/jquery/package.json +10 -0
  229. data/packages/json/lib/main.js +14 -0
  230. data/packages/json/package.json +8 -0
  231. data/packages/lproj/README.md +77 -0
  232. data/packages/lproj/examples/demo-app/en.lproj/localized.strings +2 -0
  233. data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +3 -0
  234. data/packages/lproj/examples/demo-app/index.html +8 -0
  235. data/packages/lproj/examples/demo-app/lib/main.js +7 -0
  236. data/packages/lproj/examples/demo-app/package.json +9 -0
  237. data/packages/lproj/lib/main.js +78 -0
  238. data/packages/lproj/lib/strings-format.js +6 -0
  239. data/packages/lproj/package.json +9 -0
  240. data/packages/optparse/README.md +161 -0
  241. data/packages/optparse/TODO +1 -0
  242. data/packages/optparse/examples/browser-test.html +75 -0
  243. data/packages/optparse/examples/nodejs-test.js +90 -0
  244. data/packages/optparse/lib/optparse.js +309 -0
  245. data/packages/optparse/package.json +13 -0
  246. data/packages/optparse/seed.yml +5 -0
  247. data/packages/text/lib/main.js +8 -0
  248. data/packages/text/package.json +9 -0
  249. data/packages/web-file/README.md +7 -0
  250. data/packages/web-file/lib/errors.js +32 -0
  251. data/packages/web-file/lib/file-reader.js +10 -0
  252. data/packages/web-file/lib/file-system.js +234 -0
  253. data/packages/web-file/lib/file-writer.js +10 -0
  254. data/packages/web-file/lib/file.js +9 -0
  255. data/packages/web-file/lib/main.js +34 -0
  256. data/packages/web-file/lib/platform.js +25 -0
  257. data/packages/web-file/lib/ruby/file.rb +252 -0
  258. data/packages/web-file/lib/ruby/file_reader.rb +69 -0
  259. data/packages/web-file/lib/ruby/file_system.rb +134 -0
  260. data/packages/web-file/lib/ruby/file_writer.rb +78 -0
  261. data/packages/web-file/package.json +12 -0
  262. data/packages/web-typed-array/README.md +7 -0
  263. data/packages/web-typed-array/lib/array-buffer-view.js +9 -0
  264. data/packages/web-typed-array/lib/array-buffer.js +7 -0
  265. data/packages/web-typed-array/lib/main.js +33 -0
  266. data/packages/web-typed-array/lib/platform.js +20 -0
  267. data/packages/web-typed-array/lib/ruby/array_buffer.rb +31 -0
  268. data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +130 -0
  269. data/packages/web-typed-array/lib/ruby/typed_array.rb +133 -0
  270. data/packages/web-typed-array/lib/typed-array.js +26 -0
  271. data/packages/web-typed-array/package.json +9 -0
  272. data/spade-packager.gemspec +39 -0
  273. data/spec/cli/build_spec.rb +57 -0
  274. data/spec/cli/install_spec.rb +119 -0
  275. data/spec/cli/installed_spec.rb +55 -0
  276. data/spec/cli/list_spec.rb +74 -0
  277. data/spec/cli/login_spec.rb +75 -0
  278. data/spec/cli/new_spec.rb +5 -0
  279. data/spec/cli/owner_spec.rb +114 -0
  280. data/spec/cli/push_spec.rb +73 -0
  281. data/spec/cli/uninstall_spec.rb +58 -0
  282. data/spec/cli/unpack_spec.rb +72 -0
  283. data/spec/cli/unyank_spec.rb +73 -0
  284. data/spec/cli/yank_spec.rb +73 -0
  285. data/spec/credentials_spec.rb +23 -0
  286. data/spec/fixtures/badrake-0.8.7.spd +0 -0
  287. data/spec/fixtures/builder-3.0.0.spd +0 -0
  288. data/spec/fixtures/bundler-1.1.pre.spd +0 -0
  289. data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
  290. data/spec/fixtures/core-test-0.4.3.spd +0 -0
  291. data/spec/fixtures/core-test/bin/cot +3 -0
  292. data/spec/fixtures/core-test/lib/main.js +1 -0
  293. data/spec/fixtures/core-test/resources/runner.css +0 -0
  294. data/spec/fixtures/core-test/tests/test.js +1 -0
  295. data/spec/fixtures/highline-1.6.1.spd +0 -0
  296. data/spec/fixtures/ivory-0.0.1.spd +0 -0
  297. data/spec/fixtures/jquery-1.4.3.spd +0 -0
  298. data/spec/fixtures/optparse-1.0.1.spd +0 -0
  299. data/spec/fixtures/package.json +30 -0
  300. data/spec/fixtures/rake-0.8.6.spd +0 -0
  301. data/spec/fixtures/rake-0.8.7.spd +0 -0
  302. data/spec/gauntlet_spec.rb +27 -0
  303. data/spec/package_spec.rb +267 -0
  304. data/spec/spec_helper.rb +32 -0
  305. data/spec/support/cli.rb +103 -0
  306. data/spec/support/fake.rb +48 -0
  307. data/spec/support/fake_gem_server.rb +67 -0
  308. data/spec/support/fake_gemcutter.rb +50 -0
  309. data/spec/support/matchers.rb +32 -0
  310. data/spec/support/path.rb +61 -0
  311. data/templates/project/LICENSE +19 -0
  312. data/templates/project/README.md +21 -0
  313. data/templates/project/lib/main.js +9 -0
  314. data/templates/project/project.json +31 -0
  315. data/templates/project/tests/main-test.js +8 -0
  316. metadata +484 -0
@@ -0,0 +1,66 @@
1
+ (function() {
2
+ var extend, flatten;
3
+ exports.starts = function(string, literal, start) {
4
+ return literal === string.substr(start, literal.length);
5
+ };
6
+ exports.ends = function(string, literal, back) {
7
+ var len;
8
+ len = literal.length;
9
+ return literal === string.substr(string.length - len - (back || 0), len);
10
+ };
11
+ exports.compact = function(array) {
12
+ var item, _i, _len, _results;
13
+ _results = [];
14
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
15
+ item = array[_i];
16
+ if (item) {
17
+ _results.push(item);
18
+ }
19
+ }
20
+ return _results;
21
+ };
22
+ exports.count = function(string, substr) {
23
+ var num, pos;
24
+ num = pos = 0;
25
+ if (!substr.length) {
26
+ return 1 / 0;
27
+ }
28
+ while (pos = 1 + string.indexOf(substr, pos)) {
29
+ num++;
30
+ }
31
+ return num;
32
+ };
33
+ exports.merge = function(options, overrides) {
34
+ return extend(extend({}, options), overrides);
35
+ };
36
+ extend = exports.extend = function(object, properties) {
37
+ var key, val;
38
+ for (key in properties) {
39
+ val = properties[key];
40
+ object[key] = val;
41
+ }
42
+ return object;
43
+ };
44
+ exports.flatten = flatten = function(array) {
45
+ var element, flattened, _i, _len;
46
+ flattened = [];
47
+ for (_i = 0, _len = array.length; _i < _len; _i++) {
48
+ element = array[_i];
49
+ if (element instanceof Array) {
50
+ flattened = flattened.concat(flatten(element));
51
+ } else {
52
+ flattened.push(element);
53
+ }
54
+ }
55
+ return flattened;
56
+ };
57
+ exports.del = function(obj, key) {
58
+ var val;
59
+ val = obj[key];
60
+ delete obj[key];
61
+ return val;
62
+ };
63
+ exports.last = function(array, back) {
64
+ return array[array.length - (back || 0) - 1];
65
+ };
66
+ }).call(this);
@@ -0,0 +1,8 @@
1
+ (function() {
2
+ var key, val, _ref;
3
+ _ref = require('./coffee-script');
4
+ for (key in _ref) {
5
+ val = _ref[key];
6
+ exports[key] = val;
7
+ }
8
+ }).call(this);
@@ -0,0 +1,633 @@
1
+ (function() {
2
+ var ASSIGNED, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HEREDOC, HEREDOC_INDENT, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDEXABLE, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTILINER, MULTI_DENT, NOT_REGEX, NOT_SPACED_REGEX, NO_NEWLINE, NUMBER, OPERATOR, REGEX, RELATION, RESERVED, Rewriter, SHIFT, SIMPLESTR, TRAILING_SPACES, UNARY, WHITESPACE, compact, count, last, op, starts, _ref;
3
+ var __indexOf = Array.prototype.indexOf || function(item) {
4
+ for (var i = 0, l = this.length; i < l; i++) {
5
+ if (this[i] === item) return i;
6
+ }
7
+ return -1;
8
+ };
9
+ Rewriter = require('./rewriter').Rewriter;
10
+ _ref = require('./helpers'), count = _ref.count, starts = _ref.starts, compact = _ref.compact, last = _ref.last;
11
+ exports.Lexer = Lexer = (function() {
12
+ function Lexer() {}
13
+ Lexer.prototype.tokenize = function(code, opts) {
14
+ var i;
15
+ if (opts == null) {
16
+ opts = {};
17
+ }
18
+ code = code.replace(/\r/g, '').replace(TRAILING_SPACES, '');
19
+ this.code = code;
20
+ this.line = opts.line || 0;
21
+ this.indent = 0;
22
+ this.indebt = 0;
23
+ this.outdebt = 0;
24
+ this.indents = [];
25
+ this.tokens = [];
26
+ i = 0;
27
+ while (this.chunk = code.slice(i)) {
28
+ i += this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.heredocToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
29
+ }
30
+ this.closeIndentation();
31
+ if (opts.rewrite === false) {
32
+ return this.tokens;
33
+ }
34
+ return (new Rewriter).rewrite(this.tokens);
35
+ };
36
+ Lexer.prototype.identifierToken = function() {
37
+ var colon, forcedIdentifier, id, input, match, prev, tag, _ref, _ref2;
38
+ if (!(match = IDENTIFIER.exec(this.chunk))) {
39
+ return 0;
40
+ }
41
+ input = match[0], id = match[1], colon = match[2];
42
+ if (id === 'own' && this.tag() === 'FOR') {
43
+ this.token('OWN', id);
44
+ return id.length;
45
+ }
46
+ forcedIdentifier = colon || (prev = last(this.tokens)) && !prev.spaced && ((_ref = prev[0]) === '.' || _ref === '?.' || _ref === '@' || _ref === '::');
47
+ tag = 'IDENTIFIER';
48
+ if (__indexOf.call(JS_KEYWORDS, id) >= 0 || !forcedIdentifier && __indexOf.call(COFFEE_KEYWORDS, id) >= 0) {
49
+ tag = id.toUpperCase();
50
+ if (tag === 'WHEN' && (_ref2 = this.tag(), __indexOf.call(LINE_BREAK, _ref2) >= 0)) {
51
+ tag = 'LEADING_WHEN';
52
+ } else if (tag === 'FOR') {
53
+ this.seenFor = true;
54
+ } else if (tag === 'UNLESS') {
55
+ tag = 'IF';
56
+ } else if (__indexOf.call(UNARY, tag) >= 0) {
57
+ tag = 'UNARY';
58
+ } else if (__indexOf.call(RELATION, tag) >= 0) {
59
+ if (tag !== 'INSTANCEOF' && this.seenFor) {
60
+ tag = 'FOR' + tag;
61
+ this.seenFor = false;
62
+ } else {
63
+ tag = 'RELATION';
64
+ if (this.value() === '!') {
65
+ this.tokens.pop();
66
+ id = '!' + id;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ if (__indexOf.call(JS_FORBIDDEN, id) >= 0) {
72
+ if (forcedIdentifier) {
73
+ tag = 'IDENTIFIER';
74
+ id = new String(id);
75
+ id.reserved = true;
76
+ } else if (__indexOf.call(RESERVED, id) >= 0) {
77
+ this.identifierError(id);
78
+ }
79
+ }
80
+ if (!forcedIdentifier) {
81
+ if (COFFEE_ALIASES.hasOwnProperty(id)) {
82
+ id = COFFEE_ALIASES[id];
83
+ }
84
+ tag = (function() {
85
+ switch (id) {
86
+ case '!':
87
+ return 'UNARY';
88
+ case '==':
89
+ case '!=':
90
+ return 'COMPARE';
91
+ case '&&':
92
+ case '||':
93
+ return 'LOGIC';
94
+ case 'true':
95
+ case 'false':
96
+ case 'null':
97
+ case 'undefined':
98
+ return 'BOOL';
99
+ case 'break':
100
+ case 'continue':
101
+ case 'debugger':
102
+ return 'STATEMENT';
103
+ default:
104
+ return tag;
105
+ }
106
+ })();
107
+ }
108
+ this.token(tag, id);
109
+ if (colon) {
110
+ this.token(':', ':');
111
+ }
112
+ return input.length;
113
+ };
114
+ Lexer.prototype.numberToken = function() {
115
+ var match, number;
116
+ if (!(match = NUMBER.exec(this.chunk))) {
117
+ return 0;
118
+ }
119
+ number = match[0];
120
+ this.token('NUMBER', number);
121
+ return number.length;
122
+ };
123
+ Lexer.prototype.stringToken = function() {
124
+ var match, string;
125
+ switch (this.chunk.charAt(0)) {
126
+ case "'":
127
+ if (!(match = SIMPLESTR.exec(this.chunk))) {
128
+ return 0;
129
+ }
130
+ this.token('STRING', (string = match[0]).replace(MULTILINER, '\\\n'));
131
+ break;
132
+ case '"':
133
+ if (!(string = this.balancedString(this.chunk, '"'))) {
134
+ return 0;
135
+ }
136
+ if (0 < string.indexOf('#{', 1)) {
137
+ this.interpolateString(string.slice(1, -1));
138
+ } else {
139
+ this.token('STRING', this.escapeLines(string));
140
+ }
141
+ break;
142
+ default:
143
+ return 0;
144
+ }
145
+ this.line += count(string, '\n');
146
+ return string.length;
147
+ };
148
+ Lexer.prototype.heredocToken = function() {
149
+ var doc, heredoc, match, quote;
150
+ if (!(match = HEREDOC.exec(this.chunk))) {
151
+ return 0;
152
+ }
153
+ heredoc = match[0];
154
+ quote = heredoc.charAt(0);
155
+ doc = this.sanitizeHeredoc(match[2], {
156
+ quote: quote,
157
+ indent: null
158
+ });
159
+ if (quote === '"' && 0 <= doc.indexOf('#{')) {
160
+ this.interpolateString(doc, {
161
+ heredoc: true
162
+ });
163
+ } else {
164
+ this.token('STRING', this.makeString(doc, quote, true));
165
+ }
166
+ this.line += count(heredoc, '\n');
167
+ return heredoc.length;
168
+ };
169
+ Lexer.prototype.commentToken = function() {
170
+ var comment, here, match;
171
+ if (!(match = this.chunk.match(COMMENT))) {
172
+ return 0;
173
+ }
174
+ comment = match[0], here = match[1];
175
+ this.line += count(comment, '\n');
176
+ if (here) {
177
+ this.token('HERECOMMENT', this.sanitizeHeredoc(here, {
178
+ herecomment: true,
179
+ indent: Array(this.indent + 1).join(' ')
180
+ }));
181
+ this.token('TERMINATOR', '\n');
182
+ }
183
+ return comment.length;
184
+ };
185
+ Lexer.prototype.jsToken = function() {
186
+ var match, script;
187
+ if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) {
188
+ return 0;
189
+ }
190
+ this.token('JS', (script = match[0]).slice(1, -1));
191
+ return script.length;
192
+ };
193
+ Lexer.prototype.regexToken = function() {
194
+ var match, prev, regex, _ref;
195
+ if (this.chunk.charAt(0) !== '/') {
196
+ return 0;
197
+ }
198
+ if (match = HEREGEX.exec(this.chunk)) {
199
+ return this.heregexToken(match);
200
+ }
201
+ prev = last(this.tokens);
202
+ if (prev && (_ref = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref) >= 0)) {
203
+ return 0;
204
+ }
205
+ if (!(match = REGEX.exec(this.chunk))) {
206
+ return 0;
207
+ }
208
+ regex = match[0];
209
+ this.token('REGEX', regex === '//' ? '/(?:)/' : regex);
210
+ return regex.length;
211
+ };
212
+ Lexer.prototype.heregexToken = function(match) {
213
+ var body, flags, heregex, re, tag, tokens, value, _i, _len, _ref, _ref2, _ref3, _ref4;
214
+ heregex = match[0], body = match[1], flags = match[2];
215
+ if (0 > body.indexOf('#{')) {
216
+ re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/');
217
+ this.token('REGEX', "/" + (re || '(?:)') + "/" + flags);
218
+ return heregex.length;
219
+ }
220
+ this.token('IDENTIFIER', 'RegExp');
221
+ this.tokens.push(['CALL_START', '(']);
222
+ tokens = [];
223
+ _ref = this.interpolateString(body, {
224
+ regex: true
225
+ });
226
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
227
+ _ref2 = _ref[_i], tag = _ref2[0], value = _ref2[1];
228
+ if (tag === 'TOKENS') {
229
+ tokens.push.apply(tokens, value);
230
+ } else {
231
+ if (!(value = value.replace(HEREGEX_OMIT, ''))) {
232
+ continue;
233
+ }
234
+ value = value.replace(/\\/g, '\\\\');
235
+ tokens.push(['STRING', this.makeString(value, '"', true)]);
236
+ }
237
+ tokens.push(['+', '+']);
238
+ }
239
+ tokens.pop();
240
+ if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') {
241
+ this.tokens.push(['STRING', '""'], ['+', '+']);
242
+ }
243
+ (_ref4 = this.tokens).push.apply(_ref4, tokens);
244
+ if (flags) {
245
+ this.tokens.push([',', ','], ['STRING', '"' + flags + '"']);
246
+ }
247
+ this.token(')', ')');
248
+ return heregex.length;
249
+ };
250
+ Lexer.prototype.lineToken = function() {
251
+ var diff, indent, match, noNewlines, prev, size;
252
+ if (!(match = MULTI_DENT.exec(this.chunk))) {
253
+ return 0;
254
+ }
255
+ indent = match[0];
256
+ this.line += count(indent, '\n');
257
+ prev = last(this.tokens, 1);
258
+ size = indent.length - 1 - indent.lastIndexOf('\n');
259
+ noNewlines = this.unfinished();
260
+ if (size - this.indebt === this.indent) {
261
+ if (noNewlines) {
262
+ this.suppressNewlines();
263
+ } else {
264
+ this.newlineToken();
265
+ }
266
+ return indent.length;
267
+ }
268
+ if (size > this.indent) {
269
+ if (noNewlines) {
270
+ this.indebt = size - this.indent;
271
+ this.suppressNewlines();
272
+ return indent.length;
273
+ }
274
+ diff = size - this.indent + this.outdebt;
275
+ this.token('INDENT', diff);
276
+ this.indents.push(diff);
277
+ this.outdebt = this.indebt = 0;
278
+ } else {
279
+ this.indebt = 0;
280
+ this.outdentToken(this.indent - size, noNewlines);
281
+ }
282
+ this.indent = size;
283
+ return indent.length;
284
+ };
285
+ Lexer.prototype.outdentToken = function(moveOut, noNewlines, close) {
286
+ var dent, len;
287
+ while (moveOut > 0) {
288
+ len = this.indents.length - 1;
289
+ if (this.indents[len] === void 0) {
290
+ moveOut = 0;
291
+ } else if (this.indents[len] === this.outdebt) {
292
+ moveOut -= this.outdebt;
293
+ this.outdebt = 0;
294
+ } else if (this.indents[len] < this.outdebt) {
295
+ this.outdebt -= this.indents[len];
296
+ moveOut -= this.indents[len];
297
+ } else {
298
+ dent = this.indents.pop() - this.outdebt;
299
+ moveOut -= dent;
300
+ this.outdebt = 0;
301
+ this.token('OUTDENT', dent);
302
+ }
303
+ }
304
+ if (dent) {
305
+ this.outdebt -= moveOut;
306
+ }
307
+ if (!(this.tag() === 'TERMINATOR' || noNewlines)) {
308
+ this.token('TERMINATOR', '\n');
309
+ }
310
+ return this;
311
+ };
312
+ Lexer.prototype.whitespaceToken = function() {
313
+ var match, nline, prev;
314
+ if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) {
315
+ return 0;
316
+ }
317
+ prev = last(this.tokens);
318
+ if (prev) {
319
+ prev[match ? 'spaced' : 'newLine'] = true;
320
+ }
321
+ if (match) {
322
+ return match[0].length;
323
+ } else {
324
+ return 0;
325
+ }
326
+ };
327
+ Lexer.prototype.newlineToken = function() {
328
+ if (this.tag() !== 'TERMINATOR') {
329
+ this.token('TERMINATOR', '\n');
330
+ }
331
+ return this;
332
+ };
333
+ Lexer.prototype.suppressNewlines = function() {
334
+ if (this.value() === '\\') {
335
+ this.tokens.pop();
336
+ }
337
+ return this;
338
+ };
339
+ Lexer.prototype.literalToken = function() {
340
+ var match, prev, tag, value, _ref, _ref2, _ref3, _ref4;
341
+ if (match = OPERATOR.exec(this.chunk)) {
342
+ value = match[0];
343
+ if (CODE.test(value)) {
344
+ this.tagParameters();
345
+ }
346
+ } else {
347
+ value = this.chunk.charAt(0);
348
+ }
349
+ tag = value;
350
+ prev = last(this.tokens);
351
+ if (value === '=' && prev) {
352
+ if (!prev[1].reserved && (_ref = prev[1], __indexOf.call(JS_FORBIDDEN, _ref) >= 0)) {
353
+ this.assignmentError();
354
+ }
355
+ if ((_ref2 = prev[1]) === '||' || _ref2 === '&&') {
356
+ prev[0] = 'COMPOUND_ASSIGN';
357
+ prev[1] += '=';
358
+ return value.length;
359
+ }
360
+ }
361
+ if (value === ';') {
362
+ tag = 'TERMINATOR';
363
+ } else if (__indexOf.call(MATH, value) >= 0) {
364
+ tag = 'MATH';
365
+ } else if (__indexOf.call(COMPARE, value) >= 0) {
366
+ tag = 'COMPARE';
367
+ } else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) {
368
+ tag = 'COMPOUND_ASSIGN';
369
+ } else if (__indexOf.call(UNARY, value) >= 0) {
370
+ tag = 'UNARY';
371
+ } else if (__indexOf.call(SHIFT, value) >= 0) {
372
+ tag = 'SHIFT';
373
+ } else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) {
374
+ tag = 'LOGIC';
375
+ } else if (prev && !prev.spaced) {
376
+ if (value === '(' && (_ref3 = prev[0], __indexOf.call(CALLABLE, _ref3) >= 0)) {
377
+ if (prev[0] === '?') {
378
+ prev[0] = 'FUNC_EXIST';
379
+ }
380
+ tag = 'CALL_START';
381
+ } else if (value === '[' && (_ref4 = prev[0], __indexOf.call(INDEXABLE, _ref4) >= 0)) {
382
+ tag = 'INDEX_START';
383
+ switch (prev[0]) {
384
+ case '?':
385
+ prev[0] = 'INDEX_SOAK';
386
+ break;
387
+ case '::':
388
+ prev[0] = 'INDEX_PROTO';
389
+ }
390
+ }
391
+ }
392
+ this.token(tag, value);
393
+ return value.length;
394
+ };
395
+ Lexer.prototype.sanitizeHeredoc = function(doc, options) {
396
+ var attempt, herecomment, indent, match, _ref;
397
+ indent = options.indent, herecomment = options.herecomment;
398
+ if (herecomment && 0 > doc.indexOf('\n')) {
399
+ return doc;
400
+ }
401
+ if (!herecomment) {
402
+ while (match = HEREDOC_INDENT.exec(doc)) {
403
+ attempt = match[1];
404
+ if (indent === null || (0 < (_ref = attempt.length) && _ref < indent.length)) {
405
+ indent = attempt;
406
+ }
407
+ }
408
+ }
409
+ if (indent) {
410
+ doc = doc.replace(RegExp("\\n" + indent, "g"), '\n');
411
+ }
412
+ if (!herecomment) {
413
+ doc = doc.replace(/^\n/, '');
414
+ }
415
+ return doc;
416
+ };
417
+ Lexer.prototype.tagParameters = function() {
418
+ var i, stack, tok, tokens;
419
+ if (this.tag() !== ')') {
420
+ return this;
421
+ }
422
+ stack = [];
423
+ tokens = this.tokens;
424
+ i = tokens.length;
425
+ tokens[--i][0] = 'PARAM_END';
426
+ while (tok = tokens[--i]) {
427
+ switch (tok[0]) {
428
+ case ')':
429
+ stack.push(tok);
430
+ break;
431
+ case '(':
432
+ case 'CALL_START':
433
+ if (stack.length) {
434
+ stack.pop();
435
+ } else {
436
+ tok[0] = 'PARAM_START';
437
+ return this;
438
+ }
439
+ }
440
+ }
441
+ return this;
442
+ };
443
+ Lexer.prototype.closeIndentation = function() {
444
+ return this.outdentToken(this.indent);
445
+ };
446
+ Lexer.prototype.identifierError = function(word) {
447
+ throw SyntaxError("Reserved word \"" + word + "\" on line " + (this.line + 1));
448
+ };
449
+ Lexer.prototype.assignmentError = function() {
450
+ throw SyntaxError("Reserved word \"" + (this.value()) + "\" on line " + (this.line + 1) + " can't be assigned");
451
+ };
452
+ Lexer.prototype.balancedString = function(str, end) {
453
+ var i, letter, prev, stack, _ref;
454
+ stack = [end];
455
+ for (i = 1, _ref = str.length; (1 <= _ref ? i < _ref : i > _ref); (1 <= _ref ? i += 1 : i -= 1)) {
456
+ switch (letter = str.charAt(i)) {
457
+ case '\\':
458
+ i++;
459
+ continue;
460
+ case end:
461
+ stack.pop();
462
+ if (!stack.length) {
463
+ return str.slice(0, i + 1);
464
+ }
465
+ end = stack[stack.length - 1];
466
+ continue;
467
+ }
468
+ if (end === '}' && (letter === '"' || letter === "'")) {
469
+ stack.push(end = letter);
470
+ } else if (end === '}' && letter === '{') {
471
+ stack.push(end = '}');
472
+ } else if (end === '"' && prev === '#' && letter === '{') {
473
+ stack.push(end = '}');
474
+ }
475
+ prev = letter;
476
+ }
477
+ throw new Error("missing " + (stack.pop()) + ", starting on line " + (this.line + 1));
478
+ };
479
+ Lexer.prototype.interpolateString = function(str, options) {
480
+ var expr, heredoc, i, inner, interpolated, letter, nested, pi, regex, tag, tokens, value, _len, _ref, _ref2, _ref3;
481
+ if (options == null) {
482
+ options = {};
483
+ }
484
+ heredoc = options.heredoc, regex = options.regex;
485
+ tokens = [];
486
+ pi = 0;
487
+ i = -1;
488
+ while (letter = str.charAt(i += 1)) {
489
+ if (letter === '\\') {
490
+ i += 1;
491
+ continue;
492
+ }
493
+ if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) {
494
+ continue;
495
+ }
496
+ if (pi < i) {
497
+ tokens.push(['NEOSTRING', str.slice(pi, i)]);
498
+ }
499
+ inner = expr.slice(1, -1);
500
+ if (inner.length) {
501
+ nested = new Lexer().tokenize(inner, {
502
+ line: this.line,
503
+ rewrite: false
504
+ });
505
+ nested.pop();
506
+ if (((_ref = nested[0]) != null ? _ref[0] : void 0) === 'TERMINATOR') {
507
+ nested.shift();
508
+ }
509
+ if (nested.length > 1) {
510
+ nested.unshift(['(', '(']);
511
+ nested.push([')', ')']);
512
+ }
513
+ tokens.push(['TOKENS', nested]);
514
+ }
515
+ i += expr.length;
516
+ pi = i + 1;
517
+ }
518
+ if ((i > pi && pi < str.length)) {
519
+ tokens.push(['NEOSTRING', str.slice(pi)]);
520
+ }
521
+ if (regex) {
522
+ return tokens;
523
+ }
524
+ if (!tokens.length) {
525
+ return this.token('STRING', '""');
526
+ }
527
+ if (tokens[0][0] !== 'NEOSTRING') {
528
+ tokens.unshift(['', '']);
529
+ }
530
+ if (interpolated = tokens.length > 1) {
531
+ this.token('(', '(');
532
+ }
533
+ for (i = 0, _len = tokens.length; i < _len; i++) {
534
+ _ref2 = tokens[i], tag = _ref2[0], value = _ref2[1];
535
+ if (i) {
536
+ this.token('+', '+');
537
+ }
538
+ if (tag === 'TOKENS') {
539
+ (_ref3 = this.tokens).push.apply(_ref3, value);
540
+ } else {
541
+ this.token('STRING', this.makeString(value, '"', heredoc));
542
+ }
543
+ }
544
+ if (interpolated) {
545
+ this.token(')', ')');
546
+ }
547
+ return tokens;
548
+ };
549
+ Lexer.prototype.token = function(tag, value) {
550
+ return this.tokens.push([tag, value, this.line]);
551
+ };
552
+ Lexer.prototype.tag = function(index, tag) {
553
+ var tok;
554
+ return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]);
555
+ };
556
+ Lexer.prototype.value = function(index, val) {
557
+ var tok;
558
+ return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]);
559
+ };
560
+ Lexer.prototype.unfinished = function() {
561
+ var prev, value;
562
+ return LINE_CONTINUER.test(this.chunk) || (prev = last(this.tokens, 1)) && prev[0] !== '.' && (value = this.value()) && !value.reserved && NO_NEWLINE.test(value) && !CODE.test(value) && !ASSIGNED.test(this.chunk);
563
+ };
564
+ Lexer.prototype.escapeLines = function(str, heredoc) {
565
+ return str.replace(MULTILINER, heredoc ? '\\n' : '');
566
+ };
567
+ Lexer.prototype.makeString = function(body, quote, heredoc) {
568
+ if (!body) {
569
+ return quote + quote;
570
+ }
571
+ body = body.replace(/\\([\s\S])/g, function(match, contents) {
572
+ if (contents === '\n' || contents === quote) {
573
+ return contents;
574
+ } else {
575
+ return match;
576
+ }
577
+ });
578
+ body = body.replace(RegExp("" + quote, "g"), '\\$&');
579
+ return quote + this.escapeLines(body, heredoc) + quote;
580
+ };
581
+ return Lexer;
582
+ })();
583
+ 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'];
584
+ COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when'];
585
+ for (op in COFFEE_ALIASES = {
586
+ and: '&&',
587
+ or: '||',
588
+ is: '==',
589
+ isnt: '!=',
590
+ not: '!',
591
+ yes: 'true',
592
+ no: 'false',
593
+ on: 'true',
594
+ off: 'false'
595
+ }) {
596
+ COFFEE_KEYWORDS.push(op);
597
+ }
598
+ RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf'];
599
+ JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED);
600
+ exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS);
601
+ IDENTIFIER = /^([$A-Za-z_][$\w]*)([^\n\S]*:(?!:))?/;
602
+ NUMBER = /^0x[\da-f]+|^(?:\d+(\.\d+)?|\.\d+)(?:e[+-]?\d+)?/i;
603
+ HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/;
604
+ OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?\.|\.{2,3})/;
605
+ WHITESPACE = /^[^\n\S]+/;
606
+ COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)?$)|^(?:\s*#(?!##[^#]).*)+/;
607
+ CODE = /^[-=]>/;
608
+ MULTI_DENT = /^(?:\n[^\n\S]*)+/;
609
+ SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/;
610
+ JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/;
611
+ REGEX = /^\/(?!\s)[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/[imgy]{0,4}(?!\w)/;
612
+ HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/;
613
+ HEREGEX_OMIT = /\s+(?:#.*)?/g;
614
+ MULTILINER = /\n/g;
615
+ HEREDOC_INDENT = /\n+([^\n\S]*)/g;
616
+ ASSIGNED = /^\s*@?([$A-Za-z_][$\w]*|['"].*['"])[^\n\S]*?[:=][^:=>]/;
617
+ LINE_CONTINUER = /^\s*(?:,|\??\.(?!\.)|::)/;
618
+ TRAILING_SPACES = /\s+$/;
619
+ NO_NEWLINE = /^(?:[-+*&|\/%=<>!.\\][<>=&|]*|and|or|is(?:nt)?|n(?:ot|ew)|delete|typeof|instanceof)$/;
620
+ COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|='];
621
+ UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO'];
622
+ LOGIC = ['&&', '||', '&', '|', '^'];
623
+ SHIFT = ['<<', '>>', '>>>'];
624
+ COMPARE = ['==', '!=', '<', '>', '<=', '>='];
625
+ MATH = ['*', '/', '%'];
626
+ RELATION = ['IN', 'OF', 'INSTANCEOF'];
627
+ BOOL = ['TRUE', 'FALSE', 'NULL', 'UNDEFINED'];
628
+ NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', '++', '--', ']'];
629
+ NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING');
630
+ CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER'];
631
+ INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL');
632
+ LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR'];
633
+ }).call(this);