coffeescript-router 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.gitignore +3 -0
  2. data/Cakefile +122 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/LICENSE.txt +19 -0
  6. data/README.md +18 -0
  7. data/Rakefile +2 -0
  8. data/SpecRunner.html +25 -0
  9. data/coffeescript-router.gemspec +19 -0
  10. data/lib/CoffeeScript.png +0 -0
  11. data/lib/coffeescript-router/version.rb +5 -0
  12. data/lib/jasmine-1.0.2/MIT.LICENSE +20 -0
  13. data/lib/jasmine-1.0.2/jasmine-html.js +188 -0
  14. data/lib/jasmine-1.0.2/jasmine.css +166 -0
  15. data/lib/jasmine-1.0.2/jasmine.js +2421 -0
  16. data/node_modules/.bin/cake +7 -0
  17. data/node_modules/.bin/coffee +7 -0
  18. data/node_modules/.bin/uglifyjs +212 -0
  19. data/node_modules/coffee-script/.npmignore +11 -0
  20. data/node_modules/coffee-script/LICENSE +22 -0
  21. data/node_modules/coffee-script/README +48 -0
  22. data/node_modules/coffee-script/Rakefile +78 -0
  23. data/node_modules/coffee-script/bin/cake +7 -0
  24. data/node_modules/coffee-script/bin/coffee +7 -0
  25. data/node_modules/coffee-script/lib/browser.js +75 -0
  26. data/node_modules/coffee-script/lib/cake.js +76 -0
  27. data/node_modules/coffee-script/lib/coffee-script.js +107 -0
  28. data/node_modules/coffee-script/lib/command.js +274 -0
  29. data/node_modules/coffee-script/lib/grammar.js +591 -0
  30. data/node_modules/coffee-script/lib/helpers.js +66 -0
  31. data/node_modules/coffee-script/lib/index.js +8 -0
  32. data/node_modules/coffee-script/lib/lexer.js +650 -0
  33. data/node_modules/coffee-script/lib/nodes.js +2230 -0
  34. data/node_modules/coffee-script/lib/optparse.js +111 -0
  35. data/node_modules/coffee-script/lib/parser.js +676 -0
  36. data/node_modules/coffee-script/lib/repl.js +114 -0
  37. data/node_modules/coffee-script/lib/rewriter.js +359 -0
  38. data/node_modules/coffee-script/lib/scope.js +120 -0
  39. data/node_modules/coffee-script/package.json +27 -0
  40. data/node_modules/growl/History.md +16 -0
  41. data/node_modules/growl/Readme.md +74 -0
  42. data/node_modules/growl/lib/growl.js +82 -0
  43. data/node_modules/growl/package.json +6 -0
  44. data/node_modules/growl/test.js +17 -0
  45. data/node_modules/uglify-js/.gitignore +4 -0
  46. data/node_modules/uglify-js/README.html +825 -0
  47. data/node_modules/uglify-js/README.org +431 -0
  48. data/node_modules/uglify-js/bin/uglifyjs +212 -0
  49. data/node_modules/uglify-js/docstyle.css +75 -0
  50. data/node_modules/uglify-js/lib/parse-js.js +1319 -0
  51. data/node_modules/uglify-js/lib/process.js +1614 -0
  52. data/node_modules/uglify-js/lib/squeeze-more.js +22 -0
  53. data/node_modules/uglify-js/package.json +22 -0
  54. data/node_modules/uglify-js/test/beautify.js +28 -0
  55. data/node_modules/uglify-js/test/testparser.js +402 -0
  56. data/node_modules/uglify-js/test/unit/compress/expected/array1.js +1 -0
  57. data/node_modules/uglify-js/test/unit/compress/expected/array2.js +1 -0
  58. data/node_modules/uglify-js/test/unit/compress/expected/array3.js +1 -0
  59. data/node_modules/uglify-js/test/unit/compress/expected/array4.js +1 -0
  60. data/node_modules/uglify-js/test/unit/compress/expected/assignment.js +1 -0
  61. data/node_modules/uglify-js/test/unit/compress/expected/concatstring.js +1 -0
  62. data/node_modules/uglify-js/test/unit/compress/expected/const.js +1 -0
  63. data/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js +1 -0
  64. data/node_modules/uglify-js/test/unit/compress/expected/forstatement.js +1 -0
  65. data/node_modules/uglify-js/test/unit/compress/expected/if.js +1 -0
  66. data/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js +1 -0
  67. data/node_modules/uglify-js/test/unit/compress/expected/issue10.js +1 -0
  68. data/node_modules/uglify-js/test/unit/compress/expected/issue11.js +1 -0
  69. data/node_modules/uglify-js/test/unit/compress/expected/issue13.js +1 -0
  70. data/node_modules/uglify-js/test/unit/compress/expected/issue14.js +1 -0
  71. data/node_modules/uglify-js/test/unit/compress/expected/issue16.js +1 -0
  72. data/node_modules/uglify-js/test/unit/compress/expected/issue17.js +1 -0
  73. data/node_modules/uglify-js/test/unit/compress/expected/issue20.js +1 -0
  74. data/node_modules/uglify-js/test/unit/compress/expected/issue21.js +1 -0
  75. data/node_modules/uglify-js/test/unit/compress/expected/issue25.js +1 -0
  76. data/node_modules/uglify-js/test/unit/compress/expected/issue27.js +1 -0
  77. data/node_modules/uglify-js/test/unit/compress/expected/issue28.js +1 -0
  78. data/node_modules/uglify-js/test/unit/compress/expected/issue29.js +1 -0
  79. data/node_modules/uglify-js/test/unit/compress/expected/issue30.js +1 -0
  80. data/node_modules/uglify-js/test/unit/compress/expected/issue34.js +1 -0
  81. data/node_modules/uglify-js/test/unit/compress/expected/issue4.js +1 -0
  82. data/node_modules/uglify-js/test/unit/compress/expected/issue48.js +1 -0
  83. data/node_modules/uglify-js/test/unit/compress/expected/issue50.js +1 -0
  84. data/node_modules/uglify-js/test/unit/compress/expected/issue53.js +1 -0
  85. data/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js +1 -0
  86. data/node_modules/uglify-js/test/unit/compress/expected/issue68.js +1 -0
  87. data/node_modules/uglify-js/test/unit/compress/expected/issue69.js +1 -0
  88. data/node_modules/uglify-js/test/unit/compress/expected/issue9.js +1 -0
  89. data/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js +1 -0
  90. data/node_modules/uglify-js/test/unit/compress/expected/var.js +1 -0
  91. data/node_modules/uglify-js/test/unit/compress/test/array1.js +3 -0
  92. data/node_modules/uglify-js/test/unit/compress/test/array2.js +4 -0
  93. data/node_modules/uglify-js/test/unit/compress/test/array3.js +4 -0
  94. data/node_modules/uglify-js/test/unit/compress/test/array4.js +6 -0
  95. data/node_modules/uglify-js/test/unit/compress/test/assignment.js +20 -0
  96. data/node_modules/uglify-js/test/unit/compress/test/concatstring.js +3 -0
  97. data/node_modules/uglify-js/test/unit/compress/test/const.js +5 -0
  98. data/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js +4 -0
  99. data/node_modules/uglify-js/test/unit/compress/test/forstatement.js +10 -0
  100. data/node_modules/uglify-js/test/unit/compress/test/if.js +6 -0
  101. data/node_modules/uglify-js/test/unit/compress/test/ifreturn.js +9 -0
  102. data/node_modules/uglify-js/test/unit/compress/test/issue10.js +1 -0
  103. data/node_modules/uglify-js/test/unit/compress/test/issue11.js +3 -0
  104. data/node_modules/uglify-js/test/unit/compress/test/issue13.js +1 -0
  105. data/node_modules/uglify-js/test/unit/compress/test/issue14.js +1 -0
  106. data/node_modules/uglify-js/test/unit/compress/test/issue16.js +1 -0
  107. data/node_modules/uglify-js/test/unit/compress/test/issue17.js +4 -0
  108. data/node_modules/uglify-js/test/unit/compress/test/issue20.js +1 -0
  109. data/node_modules/uglify-js/test/unit/compress/test/issue21.js +6 -0
  110. data/node_modules/uglify-js/test/unit/compress/test/issue25.js +7 -0
  111. data/node_modules/uglify-js/test/unit/compress/test/issue27.js +1 -0
  112. data/node_modules/uglify-js/test/unit/compress/test/issue28.js +3 -0
  113. data/node_modules/uglify-js/test/unit/compress/test/issue29.js +1 -0
  114. data/node_modules/uglify-js/test/unit/compress/test/issue30.js +3 -0
  115. data/node_modules/uglify-js/test/unit/compress/test/issue34.js +3 -0
  116. data/node_modules/uglify-js/test/unit/compress/test/issue4.js +3 -0
  117. data/node_modules/uglify-js/test/unit/compress/test/issue48.js +1 -0
  118. data/node_modules/uglify-js/test/unit/compress/test/issue50.js +9 -0
  119. data/node_modules/uglify-js/test/unit/compress/test/issue53.js +1 -0
  120. data/node_modules/uglify-js/test/unit/compress/test/issue54.1.js +3 -0
  121. data/node_modules/uglify-js/test/unit/compress/test/issue68.js +5 -0
  122. data/node_modules/uglify-js/test/unit/compress/test/issue69.js +1 -0
  123. data/node_modules/uglify-js/test/unit/compress/test/issue9.js +4 -0
  124. data/node_modules/uglify-js/test/unit/compress/test/strict-equals.js +3 -0
  125. data/node_modules/uglify-js/test/unit/compress/test/var.js +3 -0
  126. data/node_modules/uglify-js/test/unit/scripts.js +46 -0
  127. data/node_modules/uglify-js/uglify-js.js +2 -0
  128. data/src/coffeescript/coffeescript-router.js.coffee +31 -0
  129. data/test/coffeescript/routerSpec.coffee +47 -0
  130. data/vendor/assets/javascripts/coffeescript-router.min.js +1 -0
  131. metadata +187 -0
@@ -0,0 +1,591 @@
1
+ (function() {
2
+ var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
3
+ Parser = require('jison').Parser;
4
+ unwrap = /^function\s*\(\)\s*\{\s*return\s*([\s\S]*);\s*\}/;
5
+ o = function(patternString, action, options) {
6
+ var match;
7
+ patternString = patternString.replace(/\s{2,}/g, ' ');
8
+ if (!action) {
9
+ return [patternString, '$$ = $1;', options];
10
+ }
11
+ action = (match = unwrap.exec(action)) ? match[1] : "(" + action + "())";
12
+ action = action.replace(/\bnew /g, '$&yy.');
13
+ action = action.replace(/\b(?:Block\.wrap|extend)\b/g, 'yy.$&');
14
+ return [patternString, "$$ = " + action + ";", options];
15
+ };
16
+ grammar = {
17
+ Root: [
18
+ o('', function() {
19
+ return new Block;
20
+ }), o('Body'), o('Block TERMINATOR')
21
+ ],
22
+ Body: [
23
+ o('Line', function() {
24
+ return Block.wrap([$1]);
25
+ }), o('Body TERMINATOR Line', function() {
26
+ return $1.push($3);
27
+ }), o('Body TERMINATOR')
28
+ ],
29
+ Line: [o('Expression'), o('Statement')],
30
+ Statement: [
31
+ o('Return'), o('Throw'), o('Comment'), o('STATEMENT', function() {
32
+ return new Literal($1);
33
+ })
34
+ ],
35
+ Expression: [o('Value'), o('Invocation'), o('Code'), o('Operation'), o('Assign'), o('If'), o('Try'), o('While'), o('For'), o('Switch'), o('Class')],
36
+ Block: [
37
+ o('INDENT OUTDENT', function() {
38
+ return new Block;
39
+ }), o('INDENT Body OUTDENT', function() {
40
+ return $2;
41
+ })
42
+ ],
43
+ Identifier: [
44
+ o('IDENTIFIER', function() {
45
+ return new Literal($1);
46
+ })
47
+ ],
48
+ AlphaNumeric: [
49
+ o('NUMBER', function() {
50
+ return new Literal($1);
51
+ }), o('STRING', function() {
52
+ return new Literal($1);
53
+ })
54
+ ],
55
+ Literal: [
56
+ o('AlphaNumeric'), o('JS', function() {
57
+ return new Literal($1);
58
+ }), o('REGEX', function() {
59
+ return new Literal($1);
60
+ }), o('BOOL', function() {
61
+ var val;
62
+ val = new Literal($1);
63
+ if ($1 === 'undefined') {
64
+ val.isUndefined = true;
65
+ }
66
+ return val;
67
+ })
68
+ ],
69
+ Assign: [
70
+ o('Assignable = Expression', function() {
71
+ return new Assign($1, $3);
72
+ }), o('Assignable = INDENT Expression OUTDENT', function() {
73
+ return new Assign($1, $4);
74
+ })
75
+ ],
76
+ AssignObj: [
77
+ o('ObjAssignable', function() {
78
+ return new Value($1);
79
+ }), o('ObjAssignable : Expression', function() {
80
+ return new Assign(new Value($1), $3, 'object');
81
+ }), o('ObjAssignable :\
82
+ INDENT Expression OUTDENT', function() {
83
+ return new Assign(new Value($1), $4, 'object');
84
+ }), o('Comment')
85
+ ],
86
+ ObjAssignable: [o('Identifier'), o('AlphaNumeric'), o('ThisProperty')],
87
+ Return: [
88
+ o('RETURN Expression', function() {
89
+ return new Return($2);
90
+ }), o('RETURN', function() {
91
+ return new Return;
92
+ })
93
+ ],
94
+ Comment: [
95
+ o('HERECOMMENT', function() {
96
+ return new Comment($1);
97
+ })
98
+ ],
99
+ Code: [
100
+ o('PARAM_START ParamList PARAM_END FuncGlyph Block', function() {
101
+ return new Code($2, $5, $4);
102
+ }), o('FuncGlyph Block', function() {
103
+ return new Code([], $2, $1);
104
+ })
105
+ ],
106
+ FuncGlyph: [
107
+ o('->', function() {
108
+ return 'func';
109
+ }), o('=>', function() {
110
+ return 'boundfunc';
111
+ })
112
+ ],
113
+ OptComma: [o(''), o(',')],
114
+ ParamList: [
115
+ o('', function() {
116
+ return [];
117
+ }), o('Param', function() {
118
+ return [$1];
119
+ }), o('ParamList , Param', function() {
120
+ return $1.concat($3);
121
+ })
122
+ ],
123
+ Param: [
124
+ o('ParamVar', function() {
125
+ return new Param($1);
126
+ }), o('ParamVar ...', function() {
127
+ return new Param($1, null, true);
128
+ }), o('ParamVar = Expression', function() {
129
+ return new Param($1, $3);
130
+ })
131
+ ],
132
+ ParamVar: [o('Identifier'), o('ThisProperty'), o('Array'), o('Object')],
133
+ Splat: [
134
+ o('Expression ...', function() {
135
+ return new Splat($1);
136
+ })
137
+ ],
138
+ SimpleAssignable: [
139
+ o('Identifier', function() {
140
+ return new Value($1);
141
+ }), o('Value Accessor', function() {
142
+ return $1.push($2);
143
+ }), o('Invocation Accessor', function() {
144
+ return new Value($1, [$2]);
145
+ }), o('ThisProperty')
146
+ ],
147
+ Assignable: [
148
+ o('SimpleAssignable'), o('Array', function() {
149
+ return new Value($1);
150
+ }), o('Object', function() {
151
+ return new Value($1);
152
+ })
153
+ ],
154
+ Value: [
155
+ o('Assignable'), o('Literal', function() {
156
+ return new Value($1);
157
+ }), o('Parenthetical', function() {
158
+ return new Value($1);
159
+ }), o('Range', function() {
160
+ return new Value($1);
161
+ }), o('This')
162
+ ],
163
+ Accessor: [
164
+ o('. Identifier', function() {
165
+ return new Access($2);
166
+ }), o('?. Identifier', function() {
167
+ return new Access($2, 'soak');
168
+ }), o(':: Identifier', function() {
169
+ return new Access($2, 'proto');
170
+ }), o('::', function() {
171
+ return new Access(new Literal('prototype'));
172
+ }), o('Index')
173
+ ],
174
+ Index: [
175
+ o('INDEX_START IndexValue INDEX_END', function() {
176
+ return $2;
177
+ }), o('INDEX_SOAK Index', function() {
178
+ return extend($2, {
179
+ soak: true
180
+ });
181
+ }), o('INDEX_PROTO Index', function() {
182
+ return extend($2, {
183
+ proto: true
184
+ });
185
+ })
186
+ ],
187
+ IndexValue: [
188
+ o('Expression', function() {
189
+ return new Index($1);
190
+ }), o('Slice', function() {
191
+ return new Slice($1);
192
+ })
193
+ ],
194
+ Object: [
195
+ o('{ AssignList OptComma }', function() {
196
+ return new Obj($2, $1.generated);
197
+ })
198
+ ],
199
+ AssignList: [
200
+ o('', function() {
201
+ return [];
202
+ }), o('AssignObj', function() {
203
+ return [$1];
204
+ }), o('AssignList , AssignObj', function() {
205
+ return $1.concat($3);
206
+ }), o('AssignList OptComma TERMINATOR AssignObj', function() {
207
+ return $1.concat($4);
208
+ }), o('AssignList OptComma INDENT AssignList OptComma OUTDENT', function() {
209
+ return $1.concat($4);
210
+ })
211
+ ],
212
+ Class: [
213
+ o('CLASS', function() {
214
+ return new Class;
215
+ }), o('CLASS Block', function() {
216
+ return new Class(null, null, $2);
217
+ }), o('CLASS EXTENDS Value', function() {
218
+ return new Class(null, $3);
219
+ }), o('CLASS EXTENDS Value Block', function() {
220
+ return new Class(null, $3, $4);
221
+ }), o('CLASS SimpleAssignable', function() {
222
+ return new Class($2);
223
+ }), o('CLASS SimpleAssignable Block', function() {
224
+ return new Class($2, null, $3);
225
+ }), o('CLASS SimpleAssignable EXTENDS Value', function() {
226
+ return new Class($2, $4);
227
+ }), o('CLASS SimpleAssignable EXTENDS Value Block', function() {
228
+ return new Class($2, $4, $5);
229
+ })
230
+ ],
231
+ Invocation: [
232
+ o('Value OptFuncExist Arguments', function() {
233
+ return new Call($1, $3, $2);
234
+ }), o('Invocation OptFuncExist Arguments', function() {
235
+ return new Call($1, $3, $2);
236
+ }), o('SUPER', function() {
237
+ return new Call('super', [new Splat(new Literal('arguments'))]);
238
+ }), o('SUPER Arguments', function() {
239
+ return new Call('super', $2);
240
+ })
241
+ ],
242
+ OptFuncExist: [
243
+ o('', function() {
244
+ return false;
245
+ }), o('FUNC_EXIST', function() {
246
+ return true;
247
+ })
248
+ ],
249
+ Arguments: [
250
+ o('CALL_START CALL_END', function() {
251
+ return [];
252
+ }), o('CALL_START ArgList OptComma CALL_END', function() {
253
+ return $2;
254
+ })
255
+ ],
256
+ This: [
257
+ o('THIS', function() {
258
+ return new Value(new Literal('this'));
259
+ }), o('@', function() {
260
+ return new Value(new Literal('this'));
261
+ })
262
+ ],
263
+ ThisProperty: [
264
+ o('@ Identifier', function() {
265
+ return new Value(new Literal('this'), [new Access($2)], 'this');
266
+ })
267
+ ],
268
+ Array: [
269
+ o('[ ]', function() {
270
+ return new Arr([]);
271
+ }), o('[ ArgList OptComma ]', function() {
272
+ return new Arr($2);
273
+ })
274
+ ],
275
+ RangeDots: [
276
+ o('..', function() {
277
+ return 'inclusive';
278
+ }), o('...', function() {
279
+ return 'exclusive';
280
+ })
281
+ ],
282
+ Range: [
283
+ o('[ Expression RangeDots Expression ]', function() {
284
+ return new Range($2, $4, $3);
285
+ })
286
+ ],
287
+ Slice: [
288
+ o('Expression RangeDots Expression', function() {
289
+ return new Range($1, $3, $2);
290
+ }), o('Expression RangeDots', function() {
291
+ return new Range($1, null, $2);
292
+ }), o('RangeDots Expression', function() {
293
+ return new Range(null, $2, $1);
294
+ })
295
+ ],
296
+ ArgList: [
297
+ o('Arg', function() {
298
+ return [$1];
299
+ }), o('ArgList , Arg', function() {
300
+ return $1.concat($3);
301
+ }), o('ArgList OptComma TERMINATOR Arg', function() {
302
+ return $1.concat($4);
303
+ }), o('INDENT ArgList OptComma OUTDENT', function() {
304
+ return $2;
305
+ }), o('ArgList OptComma INDENT ArgList OptComma OUTDENT', function() {
306
+ return $1.concat($4);
307
+ })
308
+ ],
309
+ Arg: [o('Expression'), o('Splat')],
310
+ SimpleArgs: [
311
+ o('Expression'), o('SimpleArgs , Expression', function() {
312
+ return [].concat($1, $3);
313
+ })
314
+ ],
315
+ Try: [
316
+ o('TRY Block', function() {
317
+ return new Try($2);
318
+ }), o('TRY Block Catch', function() {
319
+ return new Try($2, $3[0], $3[1]);
320
+ }), o('TRY Block FINALLY Block', function() {
321
+ return new Try($2, null, null, $4);
322
+ }), o('TRY Block Catch FINALLY Block', function() {
323
+ return new Try($2, $3[0], $3[1], $5);
324
+ })
325
+ ],
326
+ Catch: [
327
+ o('CATCH Identifier Block', function() {
328
+ return [$2, $3];
329
+ })
330
+ ],
331
+ Throw: [
332
+ o('THROW Expression', function() {
333
+ return new Throw($2);
334
+ })
335
+ ],
336
+ Parenthetical: [
337
+ o('( Body )', function() {
338
+ return new Parens($2);
339
+ }), o('( INDENT Body OUTDENT )', function() {
340
+ return new Parens($3);
341
+ })
342
+ ],
343
+ WhileSource: [
344
+ o('WHILE Expression', function() {
345
+ return new While($2);
346
+ }), o('WHILE Expression WHEN Expression', function() {
347
+ return new While($2, {
348
+ guard: $4
349
+ });
350
+ }), o('UNTIL Expression', function() {
351
+ return new While($2, {
352
+ invert: true
353
+ });
354
+ }), o('UNTIL Expression WHEN Expression', function() {
355
+ return new While($2, {
356
+ invert: true,
357
+ guard: $4
358
+ });
359
+ })
360
+ ],
361
+ While: [
362
+ o('WhileSource Block', function() {
363
+ return $1.addBody($2);
364
+ }), o('Statement WhileSource', function() {
365
+ return $2.addBody(Block.wrap([$1]));
366
+ }), o('Expression WhileSource', function() {
367
+ return $2.addBody(Block.wrap([$1]));
368
+ }), o('Loop', function() {
369
+ return $1;
370
+ })
371
+ ],
372
+ Loop: [
373
+ o('LOOP Block', function() {
374
+ return new While(new Literal('true')).addBody($2);
375
+ }), o('LOOP Expression', function() {
376
+ return new While(new Literal('true')).addBody(Block.wrap([$2]));
377
+ })
378
+ ],
379
+ For: [
380
+ o('Statement ForBody', function() {
381
+ return new For($1, $2);
382
+ }), o('Expression ForBody', function() {
383
+ return new For($1, $2);
384
+ }), o('ForBody Block', function() {
385
+ return new For($2, $1);
386
+ })
387
+ ],
388
+ ForBody: [
389
+ o('FOR Range', function() {
390
+ return {
391
+ source: new Value($2)
392
+ };
393
+ }), o('ForStart ForSource', function() {
394
+ $2.own = $1.own;
395
+ $2.name = $1[0];
396
+ $2.index = $1[1];
397
+ return $2;
398
+ })
399
+ ],
400
+ ForStart: [
401
+ o('FOR ForVariables', function() {
402
+ return $2;
403
+ }), o('FOR OWN ForVariables', function() {
404
+ $3.own = true;
405
+ return $3;
406
+ })
407
+ ],
408
+ ForValue: [
409
+ o('Identifier'), o('Array', function() {
410
+ return new Value($1);
411
+ }), o('Object', function() {
412
+ return new Value($1);
413
+ })
414
+ ],
415
+ ForVariables: [
416
+ o('ForValue', function() {
417
+ return [$1];
418
+ }), o('ForValue , ForValue', function() {
419
+ return [$1, $3];
420
+ })
421
+ ],
422
+ ForSource: [
423
+ o('FORIN Expression', function() {
424
+ return {
425
+ source: $2
426
+ };
427
+ }), o('FOROF Expression', function() {
428
+ return {
429
+ source: $2,
430
+ object: true
431
+ };
432
+ }), o('FORIN Expression WHEN Expression', function() {
433
+ return {
434
+ source: $2,
435
+ guard: $4
436
+ };
437
+ }), o('FOROF Expression WHEN Expression', function() {
438
+ return {
439
+ source: $2,
440
+ guard: $4,
441
+ object: true
442
+ };
443
+ }), o('FORIN Expression BY Expression', function() {
444
+ return {
445
+ source: $2,
446
+ step: $4
447
+ };
448
+ }), o('FORIN Expression WHEN Expression BY Expression', function() {
449
+ return {
450
+ source: $2,
451
+ guard: $4,
452
+ step: $6
453
+ };
454
+ }), o('FORIN Expression BY Expression WHEN Expression', function() {
455
+ return {
456
+ source: $2,
457
+ step: $4,
458
+ guard: $6
459
+ };
460
+ })
461
+ ],
462
+ Switch: [
463
+ o('SWITCH Expression INDENT Whens OUTDENT', function() {
464
+ return new Switch($2, $4);
465
+ }), o('SWITCH Expression INDENT Whens ELSE Block OUTDENT', function() {
466
+ return new Switch($2, $4, $6);
467
+ }), o('SWITCH INDENT Whens OUTDENT', function() {
468
+ return new Switch(null, $3);
469
+ }), o('SWITCH INDENT Whens ELSE Block OUTDENT', function() {
470
+ return new Switch(null, $3, $5);
471
+ })
472
+ ],
473
+ Whens: [
474
+ o('When'), o('Whens When', function() {
475
+ return $1.concat($2);
476
+ })
477
+ ],
478
+ When: [
479
+ o('LEADING_WHEN SimpleArgs Block', function() {
480
+ return [[$2, $3]];
481
+ }), o('LEADING_WHEN SimpleArgs Block TERMINATOR', function() {
482
+ return [[$2, $3]];
483
+ })
484
+ ],
485
+ IfBlock: [
486
+ o('IF Expression Block', function() {
487
+ return new If($2, $3, {
488
+ type: $1
489
+ });
490
+ }), o('IfBlock ELSE IF Expression Block', function() {
491
+ return $1.addElse(new If($4, $5, {
492
+ type: $3
493
+ }));
494
+ })
495
+ ],
496
+ If: [
497
+ o('IfBlock'), o('IfBlock ELSE Block', function() {
498
+ return $1.addElse($3);
499
+ }), o('Statement POST_IF Expression', function() {
500
+ return new If($3, Block.wrap([$1]), {
501
+ type: $2,
502
+ statement: true
503
+ });
504
+ }), o('Expression POST_IF Expression', function() {
505
+ return new If($3, Block.wrap([$1]), {
506
+ type: $2,
507
+ statement: true
508
+ });
509
+ })
510
+ ],
511
+ Operation: [
512
+ o('UNARY Expression', function() {
513
+ return new Op($1, $2);
514
+ }), o('- Expression', (function() {
515
+ return new Op('-', $2);
516
+ }), {
517
+ prec: 'UNARY'
518
+ }), o('+ Expression', (function() {
519
+ return new Op('+', $2);
520
+ }), {
521
+ prec: 'UNARY'
522
+ }), o('-- SimpleAssignable', function() {
523
+ return new Op('--', $2);
524
+ }), o('++ SimpleAssignable', function() {
525
+ return new Op('++', $2);
526
+ }), o('SimpleAssignable --', function() {
527
+ return new Op('--', $1, null, true);
528
+ }), o('SimpleAssignable ++', function() {
529
+ return new Op('++', $1, null, true);
530
+ }), o('Expression ?', function() {
531
+ return new Existence($1);
532
+ }), o('Expression + Expression', function() {
533
+ return new Op('+', $1, $3);
534
+ }), o('Expression - Expression', function() {
535
+ return new Op('-', $1, $3);
536
+ }), o('Expression MATH Expression', function() {
537
+ return new Op($2, $1, $3);
538
+ }), o('Expression SHIFT Expression', function() {
539
+ return new Op($2, $1, $3);
540
+ }), o('Expression COMPARE Expression', function() {
541
+ return new Op($2, $1, $3);
542
+ }), o('Expression LOGIC Expression', function() {
543
+ return new Op($2, $1, $3);
544
+ }), o('Expression RELATION Expression', function() {
545
+ if ($2.charAt(0) === '!') {
546
+ return new Op($2.slice(1), $1, $3).invert();
547
+ } else {
548
+ return new Op($2, $1, $3);
549
+ }
550
+ }), o('SimpleAssignable COMPOUND_ASSIGN\
551
+ Expression', function() {
552
+ return new Assign($1, $3, $2);
553
+ }), o('SimpleAssignable COMPOUND_ASSIGN\
554
+ INDENT Expression OUTDENT', function() {
555
+ return new Assign($1, $4, $2);
556
+ }), o('SimpleAssignable EXTENDS Expression', function() {
557
+ return new Extends($1, $3);
558
+ })
559
+ ]
560
+ };
561
+ operators = [['left', '.', '?.', '::'], ['left', 'CALL_START', 'CALL_END'], ['nonassoc', '++', '--'], ['left', '?'], ['right', 'UNARY'], ['left', 'MATH'], ['left', '+', '-'], ['left', 'SHIFT'], ['left', 'RELATION'], ['left', 'COMPARE'], ['left', 'LOGIC'], ['nonassoc', 'INDENT', 'OUTDENT'], ['right', '=', ':', 'COMPOUND_ASSIGN', 'RETURN', 'THROW', 'EXTENDS'], ['right', 'FORIN', 'FOROF', 'BY', 'WHEN'], ['right', 'IF', 'ELSE', 'FOR', 'DO', 'WHILE', 'UNTIL', 'LOOP', 'SUPER', 'CLASS'], ['right', 'POST_IF']];
562
+ tokens = [];
563
+ for (name in grammar) {
564
+ alternatives = grammar[name];
565
+ grammar[name] = (function() {
566
+ var _i, _j, _len, _len2, _ref, _results;
567
+ _results = [];
568
+ for (_i = 0, _len = alternatives.length; _i < _len; _i++) {
569
+ alt = alternatives[_i];
570
+ _ref = alt[0].split(' ');
571
+ for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
572
+ token = _ref[_j];
573
+ if (!grammar[token]) {
574
+ tokens.push(token);
575
+ }
576
+ }
577
+ if (name === 'Root') {
578
+ alt[1] = "return " + alt[1];
579
+ }
580
+ _results.push(alt);
581
+ }
582
+ return _results;
583
+ })();
584
+ }
585
+ exports.parser = new Parser({
586
+ tokens: tokens.join(' '),
587
+ bnf: grammar,
588
+ operators: operators.reverse(),
589
+ startSymbol: 'Root'
590
+ });
591
+ }).call(this);