-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.html
17751 lines (15294 loc) · 567 KB
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang="en"><head><title>example game</title><script>(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
// Generated by IcedCoffeeScript 1.8.0-d
(function() {
var CoffeeScript, Compiler, Scope, assert, compile, nodes, parse, prepare, quote, render,
__slice = [].slice;
exports.quote = quote = function(s) {
s = s.replace(/([\\'])/g, '\\$1').replace(/\n/g, '\\n').replace(/\r/g, '\\r');
return "'" + s + "'";
};
exports.stdlib = function(imbroglio) {
if (imbroglio == null) {
imbroglio = {};
}
imbroglio.elem || (imbroglio.elem = function() {
var addChild, attrs, child, children, k, result, tag, v, _i, _len;
tag = arguments[0], attrs = arguments[1], children = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
if (attrs == null) {
attrs = {};
}
result = window.document.createElement(tag);
for (k in attrs) {
v = attrs[k];
result.setAttribute(k, v);
}
addChild = (function(_this) {
return function(child) {
var c, _i, _len, _ref, _ref1;
if ((child == null) || child === '') {
return;
}
if (child instanceof Array) {
for (_i = 0, _len = child.length; _i < _len; _i++) {
c = child[_i];
addChild(c);
}
return;
}
if (!child.cloneNode) {
child = "" + child;
if ((_ref = _this.state) != null ? _ref.smartQuotes : void 0) {
child = child.replace(/(\s)"/g, '$1\u201c').replace(/^"(\w)/g, '\u201c$1').replace('"', '\u201d').replace(/(\s)'/g, '$1\u2018').replace(/^'(\w)/g, '\u2018$1').replace("'", '\u2019');
}
if ((_ref1 = _this.state) != null ? _ref1.smartPunct : void 0) {
child = child.replace(/\s+--\s+/g, '\u2009\u2014\u2009').replace(/--\s+/g, '\u2014\u2009').replace(/\s+--/g, '\u2009\u2014').replace(/--/g, '\u2014').replace(/\.{3}/g, '\u2026');
}
child = window.document.createTextNode(child);
}
result.appendChild(child);
};
})(this);
for (_i = 0, _len = children.length; _i < _len; _i++) {
child = children[_i];
addChild(child);
}
return result;
});
return imbroglio;
};
assert = require('assert');
CoffeeScript = require('coffee-script');
Scope = require('coffee-script/lib/coffee-script/scope').Scope;
nodes = require('coffee-script/lib/coffee-script/nodes');
Compiler = (function() {
function Compiler(opts) {
this.opts = opts;
this.referencedVars = [];
this.scope = new Scope(null, null, null, this.referencedVars);
}
Compiler.prototype.refTokens = function(tokens) {
var token, _i, _len;
for (_i = 0, _len = tokens.length; _i < _len; _i++) {
token = tokens[_i];
if (token.variable) {
this.referencedVars.push(token[1]);
}
}
};
Compiler.prototype.lit = function(x) {
return new nodes.Literal(x);
};
Compiler.prototype.val = function() {
var props, x;
x = arguments[0], props = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return new nodes.Value(x, props);
};
Compiler.prototype.litval = function(x) {
return this.val(this.lit(x));
};
Compiler.prototype.assign = function(k, v) {
return new nodes.Assign(this.val(k), v);
};
Compiler.prototype.field = function(lit, field) {
return this.val(lit, new nodes.Access(this.lit(field)));
};
Compiler.prototype.string = function(s) {
return this.litval(quote(s));
};
Compiler.prototype.call = function() {
var arg, args, fn, _i, _len;
fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
for (_i = 0, _len = args.length; _i < _len; _i++) {
arg = args[_i];
assert(arg.compileToFragments);
}
return new nodes.Call(fn, args);
};
Compiler.prototype.callname = function() {
var args, name;
name = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return this.call.apply(this, [this.litval(name)].concat(__slice.call(args)));
};
Compiler.prototype.block = function(children) {
return new nodes.Block(children);
};
Compiler.prototype.ret = function(result) {
return new nodes.Return(result);
};
Compiler.prototype.blockret = function(result) {
return this.block([this.ret(result)]);
};
Compiler.prototype.wrap = function(ast) {
if (!this.opts.thisVar) {
return ast;
}
return this.blockret(this.call(this.field(new nodes.Parens(this.block([new nodes.Code([], ast)])), 'call'), this.litval(this.opts.thisVar)));
};
Compiler.prototype.text = function(s) {
return this.string(s);
};
Compiler.prototype.obj = function(obj) {
var attrs, k, v;
attrs = (function() {
var _results;
_results = [];
for (k in obj) {
v = obj[k];
assert('string' === typeof v, v);
_results.push(new nodes.Assign(this.string(k), this.string(v), 'object'));
}
return _results;
}).call(this);
return this.val(new nodes.Obj(attrs));
};
Compiler.prototype.elem = function() {
var attrs, children, tag;
tag = arguments[0], attrs = arguments[1], children = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
if (attrs == null) {
attrs = {};
}
return this.callname.apply(this, ['imbroglio.elem', this.string(tag), this.obj(attrs)].concat(__slice.call(children)));
};
Compiler.prototype.main = function(result) {
this.scope.expressions = this.wrap(this.blockret(result));
return {
scope: this.scope,
ast: this.scope.expressions,
level: 1,
indent: ''
};
};
return Compiler;
})();
exports.parse = parse = function(src, opts) {
var ast, code, codeBegin, codeEnd, compiler, e, end, error, found, idx, p, pieces, pp, start, tokens;
if (opts == null) {
opts = {};
}
compiler = new Compiler(opts);
codeBegin = '#{';
codeEnd = '}';
pp = (function() {
var _i, _len, _ref, _results;
_ref = src.split(/\n\s*\n/);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
p = _ref[_i];
if (!/\S/.test(p)) {
continue;
}
pieces = [];
idx = 0;
while (true) {
found = p.indexOf(codeBegin, idx);
if (found < 0) {
found = p.length;
}
pieces.push(compiler.text(p.substring(idx, found)));
if (found === p.length) {
break;
}
start = found + codeBegin.length;
end = start - 1;
error = true;
while (true) {
end = p.indexOf(codeEnd, end + 1);
if (end < 0) {
idx = p.length;
break;
}
code = p.substring(start, end);
try {
tokens = CoffeeScript.tokens(code);
ast = CoffeeScript.nodes(tokens);
} catch (_error) {
e = _error;
error = e;
continue;
}
error = null;
compiler.refTokens(tokens);
pieces.push(ast);
idx = end + codeEnd.length;
break;
}
if (error) {
if (opts.handleError) {
opts.handleError({
error: error
});
}
pieces.push(compiler.elem('span', {
"class": 'error',
title: error.toString()
}, compiler.text(codeBegin)));
idx = start;
}
}
_results.push(compiler.elem.apply(compiler, ['p', {}].concat(__slice.call(pieces))));
}
return _results;
})();
return compiler.main(compiler.elem.apply(compiler, ['div', {
"class": 'passage'
}].concat(__slice.call(pp))));
};
exports.compile = compile = function(src, opts) {
var fragment, fragments, o;
o = parse(src, opts);
fragments = o.ast.compileWithDeclarations(o);
return ((function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = fragments.length; _i < _len; _i++) {
fragment = fragments[_i];
_results.push(fragment.code);
}
return _results;
})()).join('');
};
exports.prepare = prepare = function(src, opts) {
var argNames, code, f, k, varNames;
code = compile(src, opts);
varNames = !opts.vars ? [] : (function() {
var _results;
_results = [];
for (k in opts.vars) {
_results.push(k);
}
return _results;
})();
argNames = varNames.concat(opts.argNames || []);
f = (function(func, args, ctor) {
ctor.prototype = func.prototype;
var child = new ctor, result = func.apply(child, args);
return Object(result) === result ? result : child;
})(Function, __slice.call(argNames).concat([code]), function(){});
if (varNames.length) {
f = f.bind.apply(f, [null].concat(__slice.call((function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = varNames.length; _i < _len; _i++) {
k = varNames[_i];
_results.push(opts.vars[k]);
}
return _results;
})())));
}
return f;
};
exports.render = render = function(src, opts) {
return prepare(src, opts)();
};
}).call(this);
},{"assert":14,"coffee-script":4,"coffee-script/lib/coffee-script/nodes":7,"coffee-script/lib/coffee-script/scope":11}],2:[function(require,module,exports){
// Generated by IcedCoffeeScript 1.8.0-d
(function() {
var fs, imbroglio, src;
src = "#start\n\nThis is the first passage in the game. From here you could go\n[[left]] or [[right->To the Right]].\n\n#left\n\nYou went left! There isn't much here.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vel vehicula ipsum. In velit mauris, porta in sapien sed, faucibus imperdiet tellus. Etiam dapibus metus eu erat suscipit, vitae laoreet mi vulputate. Proin suscipit venenatis placerat. Fusce iaculis leo metus, sit amet iaculis dui convallis ac. Proin id augue dignissim, pellentesque quam vitae, cursus quam. Etiam volutpat lobortis nisi. Maecenas ultrices egestas molestie. Aliquam erat volutpat.\n\nCras facilisis vulputate lacus, sit amet elementum ex faucibus sed. Aliquam mollis convallis nibh, eget molestie massa fermentum ut. Morbi porttitor ante ac congue vulputate. Nunc pretium urna urna, ut ultrices est sagittis ullamcorper. Fusce dictum quam ut dapibus commodo. Etiam non tempus dui. Quisque scelerisque magna efficitur consectetur rhoncus. Duis in commodo nibh. Curabitur quis ornare est, id aliquam ipsum. Pellentesque id nunc eu nisi luctus aliquet. Vestibulum mattis porta diam id volutpat. Nullam at orci faucibus urna luctus auctor.\n\nInteger aliquet vel urna eget tempus. Nam a neque pulvinar, ornare lorem eu, mattis dui. Interdum et malesuada fames ac ante ipsum primis in faucibus. Phasellus felis ligula, fermentum sit amet suscipit et, euismod et enim. Aenean fringilla venenatis tellus quis elementum. Integer non semper quam. In eget arcu pretium neque tempus sodales hendrerit vel quam. Donec nulla orci, rhoncus non varius quis, rhoncus eu nisi. Aenean vel vehicula enim. Nunc eu vulputate sapien. Proin id leo a libero blandit auctor vel ac arcu. Nulla efficitur purus id neque sodales congue. Quisque ultricies, mauris ac scelerisque faucibus, velit elit malesuada ipsum, at ultrices nunc urna a massa. Fusce finibus elit ut libero interdum, non mattis magna vehicula. Aliquam congue congue turpis at semper. Vestibulum velit nisi, fermentum a ante congue, sagittis egestas augue.\n\nNullam interdum, lorem ac molestie tempor, tortor tellus eleifend turpis, ut auctor tellus mauris id nunc. Cras viverra elit quam, a interdum enim fermentum ac. Aliquam sollicitudin risus vehicula metus elementum, sed porttitor risus eleifend. Maecenas mattis sem nec sagittis auctor. Proin id maximus arcu. Quisque ex turpis, cursus quis molestie ac, volutpat vitae justo. Duis dignissim mollis felis quis porta. Vestibulum nec feugiat ante.\n\nSed ut nisi ac risus scelerisque consequat sed ac sem. Sed arcu lacus, pellentesque eu erat ac, sodales suscipit mauris. Sed imperdiet sit amet ex vitae scelerisque. Cras vitae fermentum magna, posuere eleifend ante. Sed sagittis nulla ut lacus elementum porttitor. Proin aliquam laoreet purus. Fusce quis felis eu est sodales viverra. Curabitur convallis ac lectus ac posuere.\n\n# To the Right\n\nYou went right! Wow, this is boring.\nYou have been here #{@count or= 0; ++@count}\ntime#{if @count is 1 then '' else 's'}.\nGo [[start<-back]] maybe?\n";
imbroglio = require('.');
imbroglio.play.start(src);
}).call(this);
},{".":3}],3:[function(require,module,exports){
// Generated by IcedCoffeeScript 1.8.0-d
(function() {
exports.play = require('./play');
}).call(this);
},{"./play":23}],4:[function(require,module,exports){
(function (process,global){
// Generated by CoffeeScript 1.9.1
(function() {
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors,
hasProp = {}.hasOwnProperty,
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; };
fs = require('fs');
vm = require('vm');
path = require('path');
Lexer = require('./lexer').Lexer;
parser = require('./parser').parser;
helpers = require('./helpers');
SourceMap = require('./sourcemap');
exports.VERSION = '1.9.1';
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
exports.helpers = helpers;
withPrettyErrors = function(fn) {
return function(code, options) {
var err;
if (options == null) {
options = {};
}
try {
return fn.call(this, code, options);
} catch (_error) {
err = _error;
throw helpers.updateSyntaxError(err, code, options.filename);
}
};
};
exports.compile = compile = withPrettyErrors(function(code, options) {
var answer, currentColumn, currentLine, extend, fragment, fragments, header, i, js, len, map, merge, newLines, token, tokens;
merge = helpers.merge, extend = helpers.extend;
options = extend({}, options);
if (options.sourceMap) {
map = new SourceMap;
}
tokens = lexer.tokenize(code, options);
options.referencedVars = (function() {
var i, len, results;
results = [];
for (i = 0, len = tokens.length; i < len; i++) {
token = tokens[i];
if (token.variable) {
results.push(token[1]);
}
}
return results;
})();
fragments = parser.parse(tokens).compileToFragments(options);
currentLine = 0;
if (options.header) {
currentLine += 1;
}
if (options.shiftLine) {
currentLine += 1;
}
currentColumn = 0;
js = "";
for (i = 0, len = fragments.length; i < len; i++) {
fragment = fragments[i];
if (options.sourceMap) {
if (fragment.locationData) {
map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
noReplace: true
});
}
newLines = helpers.count(fragment.code, "\n");
currentLine += newLines;
if (newLines) {
currentColumn = fragment.code.length - (fragment.code.lastIndexOf("\n") + 1);
} else {
currentColumn += fragment.code.length;
}
}
js += fragment.code;
}
if (options.header) {
header = "Generated by CoffeeScript " + this.VERSION;
js = "// " + header + "\n" + js;
}
if (options.sourceMap) {
answer = {
js: js
};
answer.sourceMap = map;
answer.v3SourceMap = map.generate(options, code);
return answer;
} else {
return js;
}
});
exports.tokens = withPrettyErrors(function(code, options) {
return lexer.tokenize(code, options);
});
exports.nodes = withPrettyErrors(function(source, options) {
if (typeof source === 'string') {
return parser.parse(lexer.tokenize(source, options));
} else {
return parser.parse(source);
}
});
exports.run = function(code, options) {
var answer, dir, mainModule, ref;
if (options == null) {
options = {};
}
mainModule = require.main;
mainModule.filename = process.argv[1] = options.filename ? fs.realpathSync(options.filename) : '.';
mainModule.moduleCache && (mainModule.moduleCache = {});
dir = options.filename ? path.dirname(fs.realpathSync(options.filename)) : fs.realpathSync('.');
mainModule.paths = require('module')._nodeModulePaths(dir);
if (!helpers.isCoffee(mainModule.filename) || require.extensions) {
answer = compile(code, options);
code = (ref = answer.js) != null ? ref : answer;
}
return mainModule._compile(code, mainModule.filename);
};
exports["eval"] = function(code, options) {
var Module, _module, _require, createContext, i, isContext, js, k, len, o, r, ref, ref1, ref2, ref3, sandbox, v;
if (options == null) {
options = {};
}
if (!(code = code.trim())) {
return;
}
createContext = (ref = vm.Script.createContext) != null ? ref : vm.createContext;
isContext = (ref1 = vm.isContext) != null ? ref1 : function(ctx) {
return options.sandbox instanceof createContext().constructor;
};
if (createContext) {
if (options.sandbox != null) {
if (isContext(options.sandbox)) {
sandbox = options.sandbox;
} else {
sandbox = createContext();
ref2 = options.sandbox;
for (k in ref2) {
if (!hasProp.call(ref2, k)) continue;
v = ref2[k];
sandbox[k] = v;
}
}
sandbox.global = sandbox.root = sandbox.GLOBAL = sandbox;
} else {
sandbox = global;
}
sandbox.__filename = options.filename || 'eval';
sandbox.__dirname = path.dirname(sandbox.__filename);
if (!(sandbox !== global || sandbox.module || sandbox.require)) {
Module = require('module');
sandbox.module = _module = new Module(options.modulename || 'eval');
sandbox.require = _require = function(path) {
return Module._load(path, _module, true);
};
_module.filename = sandbox.__filename;
ref3 = Object.getOwnPropertyNames(require);
for (i = 0, len = ref3.length; i < len; i++) {
r = ref3[i];
if (r !== 'paths') {
_require[r] = require[r];
}
}
_require.paths = _module.paths = Module._nodeModulePaths(process.cwd());
_require.resolve = function(request) {
return Module._resolveFilename(request, _module);
};
}
}
o = {};
for (k in options) {
if (!hasProp.call(options, k)) continue;
v = options[k];
o[k] = v;
}
o.bare = true;
js = compile(code, o);
if (sandbox === global) {
return vm.runInThisContext(js);
} else {
return vm.runInContext(js, sandbox);
}
};
exports.register = function() {
return require('./register');
};
if (require.extensions) {
ref = this.FILE_EXTENSIONS;
for (i = 0, len = ref.length; i < len; i++) {
ext = ref[i];
if ((base = require.extensions)[ext] == null) {
base[ext] = function() {
throw new Error("Use CoffeeScript.register() or require the coffee-script/register module to require " + ext + " files.");
};
}
}
}
exports._compileFile = function(filename, sourceMap) {
var answer, err, raw, stripped;
if (sourceMap == null) {
sourceMap = false;
}
raw = fs.readFileSync(filename, 'utf8');
stripped = raw.charCodeAt(0) === 0xFEFF ? raw.substring(1) : raw;
try {
answer = compile(stripped, {
filename: filename,
sourceMap: sourceMap,
literate: helpers.isLiterate(filename)
});
} catch (_error) {
err = _error;
throw helpers.updateSyntaxError(err, stripped, filename);
}
return answer;
};
lexer = new Lexer;
parser.lexer = {
lex: function() {
var tag, token;
token = parser.tokens[this.pos++];
if (token) {
tag = token[0], this.yytext = token[1], this.yylloc = token[2];
parser.errorToken = token.origin || token;
this.yylineno = this.yylloc.first_line;
} else {
tag = '';
}
return tag;
},
setInput: function(tokens) {
parser.tokens = tokens;
return this.pos = 0;
},
upcomingInput: function() {
return "";
}
};
parser.yy = require('./nodes');
parser.yy.parseError = function(message, arg) {
var errorLoc, errorTag, errorText, errorToken, token, tokens;
token = arg.token;
errorToken = parser.errorToken, tokens = parser.tokens;
errorTag = errorToken[0], errorText = errorToken[1], errorLoc = errorToken[2];
errorText = (function() {
switch (false) {
case errorToken !== tokens[tokens.length - 1]:
return 'end of input';
case errorTag !== 'INDENT' && errorTag !== 'OUTDENT':
return 'indentation';
case errorTag !== 'IDENTIFIER' && errorTag !== 'NUMBER' && errorTag !== 'STRING' && errorTag !== 'STRING_START' && errorTag !== 'REGEX' && errorTag !== 'REGEX_START':
return errorTag.replace(/_START$/, '').toLowerCase();
default:
return helpers.nameWhitespaceCharacter(errorText);
}
})();
return helpers.throwSyntaxError("unexpected " + errorText, errorLoc);
};
formatSourcePosition = function(frame, getSourceMapping) {
var as, column, fileLocation, fileName, functionName, isConstructor, isMethodCall, line, methodName, source, tp, typeName;
fileName = void 0;
fileLocation = '';
if (frame.isNative()) {
fileLocation = "native";
} else {
if (frame.isEval()) {
fileName = frame.getScriptNameOrSourceURL();
if (!fileName) {
fileLocation = (frame.getEvalOrigin()) + ", ";
}
} else {
fileName = frame.getFileName();
}
fileName || (fileName = "<anonymous>");
line = frame.getLineNumber();
column = frame.getColumnNumber();
source = getSourceMapping(fileName, line, column);
fileLocation = source ? fileName + ":" + source[0] + ":" + source[1] : fileName + ":" + line + ":" + column;
}
functionName = frame.getFunctionName();
isConstructor = frame.isConstructor();
isMethodCall = !(frame.isToplevel() || isConstructor);
if (isMethodCall) {
methodName = frame.getMethodName();
typeName = frame.getTypeName();
if (functionName) {
tp = as = '';
if (typeName && functionName.indexOf(typeName)) {
tp = typeName + ".";
}
if (methodName && functionName.indexOf("." + methodName) !== functionName.length - methodName.length - 1) {
as = " [as " + methodName + "]";
}
return "" + tp + functionName + as + " (" + fileLocation + ")";
} else {
return typeName + "." + (methodName || '<anonymous>') + " (" + fileLocation + ")";
}
} else if (isConstructor) {
return "new " + (functionName || '<anonymous>') + " (" + fileLocation + ")";
} else if (functionName) {
return functionName + " (" + fileLocation + ")";
} else {
return fileLocation;
}
};
sourceMaps = {};
getSourceMap = function(filename) {
var answer, ref1;
if (sourceMaps[filename]) {
return sourceMaps[filename];
}
if (ref1 = path != null ? path.extname(filename) : void 0, indexOf.call(exports.FILE_EXTENSIONS, ref1) < 0) {
return;
}
answer = exports._compileFile(filename, true);
return sourceMaps[filename] = answer.sourceMap;
};
Error.prepareStackTrace = function(err, stack) {
var frame, frames, getSourceMapping;
getSourceMapping = function(filename, line, column) {
var answer, sourceMap;
sourceMap = getSourceMap(filename);
if (sourceMap) {
answer = sourceMap.sourceLocation([line - 1, column - 1]);
}
if (answer) {
return [answer[0] + 1, answer[1] + 1];
} else {
return null;
}
};
frames = (function() {
var j, len1, results;
results = [];
for (j = 0, len1 = stack.length; j < len1; j++) {
frame = stack[j];
if (frame.getFunction() === exports.run) {
break;
}
results.push(" at " + (formatSourcePosition(frame, getSourceMapping)));
}
return results;
})();
return (err.toString()) + "\n" + (frames.join('\n')) + "\n";
};
}).call(this);
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./helpers":5,"./lexer":6,"./nodes":7,"./parser":8,"./register":9,"./sourcemap":12,"_process":17,"fs":13,"module":13,"path":16,"vm":20}],5:[function(require,module,exports){
(function (process){
// Generated by CoffeeScript 1.9.1
(function() {
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
exports.starts = function(string, literal, start) {
return literal === string.substr(start, literal.length);
};
exports.ends = function(string, literal, back) {
var len;
len = literal.length;
return literal === string.substr(string.length - len - (back || 0), len);
};
exports.repeat = repeat = function(str, n) {
var res;
res = '';
while (n > 0) {
if (n & 1) {
res += str;
}
n >>>= 1;
str += str;
}
return res;
};
exports.compact = function(array) {
var i, item, len1, results;
results = [];
for (i = 0, len1 = array.length; i < len1; i++) {
item = array[i];
if (item) {
results.push(item);
}
}
return results;
};
exports.count = function(string, substr) {
var num, pos;
num = pos = 0;
if (!substr.length) {
return 1 / 0;
}
while (pos = 1 + string.indexOf(substr, pos)) {
num++;
}
return num;
};
exports.merge = function(options, overrides) {
return extend(extend({}, options), overrides);
};
extend = exports.extend = function(object, properties) {
var key, val;
for (key in properties) {
val = properties[key];
object[key] = val;
}
return object;
};
exports.flatten = flatten = function(array) {
var element, flattened, i, len1;
flattened = [];
for (i = 0, len1 = array.length; i < len1; i++) {
element = array[i];
if (element instanceof Array) {
flattened = flattened.concat(flatten(element));
} else {
flattened.push(element);
}
}
return flattened;
};
exports.del = function(obj, key) {
var val;
val = obj[key];
delete obj[key];
return val;
};
exports.some = (ref = Array.prototype.some) != null ? ref : function(fn) {
var e, i, len1;
for (i = 0, len1 = this.length; i < len1; i++) {
e = this[i];
if (fn(e)) {
return true;
}
}
return false;
};
exports.invertLiterate = function(code) {
var line, lines, maybe_code;
maybe_code = true;
lines = (function() {
var i, len1, ref1, results;
ref1 = code.split('\n');
results = [];
for (i = 0, len1 = ref1.length; i < len1; i++) {
line = ref1[i];
if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) {
results.push(line);
} else if (maybe_code = /^\s*$/.test(line)) {
results.push(line);
} else {
results.push('# ' + line);
}
}
return results;
})();
return lines.join('\n');
};
buildLocationData = function(first, last) {
if (!last) {
return first;
} else {
return {
first_line: first.first_line,
first_column: first.first_column,
last_line: last.last_line,
last_column: last.last_column
};
}
};
exports.addLocationDataFn = function(first, last) {
return function(obj) {
if (((typeof obj) === 'object') && (!!obj['updateLocationDataIfMissing'])) {
obj.updateLocationDataIfMissing(buildLocationData(first, last));
}
return obj;
};
};
exports.locationDataToString = function(obj) {
var locationData;
if (("2" in obj) && ("first_line" in obj[2])) {
locationData = obj[2];
} else if ("first_line" in obj) {
locationData = obj;
}
if (locationData) {
return ((locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ((locationData.last_line + 1) + ":" + (locationData.last_column + 1));
} else {
return "No location data";
}
};
exports.baseFileName = function(file, stripExt, useWinPathSep) {
var parts, pathSep;
if (stripExt == null) {
stripExt = false;
}
if (useWinPathSep == null) {
useWinPathSep = false;
}
pathSep = useWinPathSep ? /\\|\// : /\//;
parts = file.split(pathSep);
file = parts[parts.length - 1];
if (!(stripExt && file.indexOf('.') >= 0)) {
return file;
}
parts = file.split('.');
parts.pop();
if (parts[parts.length - 1] === 'coffee' && parts.length > 1) {
parts.pop();
}
return parts.join('.');
};
exports.isCoffee = function(file) {
return /\.((lit)?coffee|coffee\.md)$/.test(file);
};
exports.isLiterate = function(file) {
return /\.(litcoffee|coffee\.md)$/.test(file);
};
exports.throwSyntaxError = function(message, location) {
var error;
error = new SyntaxError(message);
error.location = location;
error.toString = syntaxErrorToString;
error.stack = error.toString();
throw error;
};
exports.updateSyntaxError = function(error, code, filename) {
if (error.toString === syntaxErrorToString) {
error.code || (error.code = code);
error.filename || (error.filename = filename);
error.stack = error.toString();
}
return error;
};
syntaxErrorToString = function() {
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start;
if (!(this.code && this.location)) {
return Error.prototype.toString.call(this);
}
ref1 = this.location, first_line = ref1.first_line, first_column = ref1.first_column, last_line = ref1.last_line, last_column = ref1.last_column;
if (last_line == null) {
last_line = first_line;
}
if (last_column == null) {
last_column = first_column;
}
filename = this.filename || '[stdin]';
codeLine = this.code.split('\n')[first_line];
start = first_column;
end = first_line === last_line ? last_column + 1 : codeLine.length;
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
if (typeof process !== "undefined" && process !== null) {
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
}
if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) {
colorize = function(str) {
return "\x1B[1;31m" + str + "\x1B[0m";
};
codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end);
marker = colorize(marker);
}
return filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker;
};
exports.nameWhitespaceCharacter = function(string) {
switch (string) {
case ' ':
return 'space';
case '\n':
return 'newline';
case '\r':
return 'carriage return';
case '\t':
return 'tab';
default:
return string;
}
};
}).call(this);
}).call(this,require('_process'))
},{"_process":17}],6:[function(require,module,exports){
// Generated by CoffeeScript 1.9.1
(function() {
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, key, locationDataToString, ref, ref1, repeat, starts, throwSyntaxError,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
ref = require('./rewriter'), Rewriter = ref.Rewriter, INVERSES = ref.INVERSES;
ref1 = require('./helpers'), count = ref1.count, starts = ref1.starts, compact = ref1.compact, repeat = ref1.repeat, invertLiterate = ref1.invertLiterate, locationDataToString = ref1.locationDataToString, throwSyntaxError = ref1.throwSyntaxError;
exports.Lexer = Lexer = (function() {
function Lexer() {}
Lexer.prototype.tokenize = function(code, opts) {
var consumed, end, i, ref2;
if (opts == null) {
opts = {};
}
this.literate = opts.literate;
this.indent = 0;
this.baseIndent = 0;
this.indebt = 0;
this.outdebt = 0;
this.indents = [];
this.ends = [];
this.tokens = [];
this.chunkLine = opts.line || 0;
this.chunkColumn = opts.column || 0;
code = this.clean(code);
i = 0;
while (this.chunk = code.slice(i)) {
consumed = this.identifierToken() || this.commentToken() || this.whitespaceToken() || this.lineToken() || this.stringToken() || this.numberToken() || this.regexToken() || this.jsToken() || this.literalToken();
ref2 = this.getLineAndColumnFromChunk(consumed), this.chunkLine = ref2[0], this.chunkColumn = ref2[1];
i += consumed;