mambascript 0.5.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/README.md +509 -267
  3. package/bin/mamba +1 -258
  4. package/decision.js +1 -246
  5. package/docs/coverage.md +70 -0
  6. package/docs/features.md +3348 -0
  7. package/docs/perf.md +94 -0
  8. package/docs/reference.md +1295 -0
  9. package/docs/vs-coffeescript.md +1593 -0
  10. package/docs/vs-iced-coffeescript.md +626 -0
  11. package/docs/vs-typescript.md +107 -0
  12. package/esm.js +8 -0
  13. package/jest.js +33 -0
  14. package/lib/black.js +17 -13
  15. package/lib/browser.js +2 -4
  16. package/lib/cli.js +207 -136
  17. package/lib/compiler.js +1162 -93
  18. package/lib/decision.js +10 -10
  19. package/lib/diagnostics.js +219 -0
  20. package/lib/esm-hooks.js +60 -0
  21. package/lib/fast-parser.js +3469 -0
  22. package/lib/functional-helpers.js +26 -9
  23. package/lib/helpers.js +67 -50
  24. package/lib/js-nodes.js +151 -12
  25. package/lib/lexer.js +1499 -0
  26. package/lib/light-module.js +200 -63
  27. package/lib/mamba.js +372 -0
  28. package/lib/module.js +23 -172
  29. package/lib/nodes.js +84 -21
  30. package/lib/optimiser.js +29 -9
  31. package/lib/optparse.js +32 -15
  32. package/lib/parser.js +9433 -4840
  33. package/lib/preprocessor.js +3 -5
  34. package/lib/register.js +49 -56
  35. package/lib/repl.js +28 -9
  36. package/lib/reporter.js +106 -69
  37. package/lib/run.js +3 -5
  38. package/lib/string-scanner.js +94 -0
  39. package/lib/syntax-tables.js +480 -0
  40. package/lib/type-checker.js +258 -44
  41. package/lib/type-helpers.js +28 -10
  42. package/lib/type-resolver.js +256 -34
  43. package/lib/type-scope.js +10 -6
  44. package/lib/type-walker.js +664 -85
  45. package/lib/types.js +17 -7
  46. package/lib/underscore.js +170 -76
  47. package/lib/unicode-classes.js +122 -0
  48. package/mambaview.js +1 -0
  49. package/package.json +49 -46
  50. package/stdlib.js +1 -0
  51. package/vendor/README.md +40 -0
  52. package/vendor/escodegen/LICENSE.BSD +19 -0
  53. package/vendor/escodegen/escodegen.js +2289 -0
  54. package/vendor/estraverse/LICENSE.BSD +19 -0
  55. package/vendor/estraverse/estraverse.js +706 -0
  56. package/vendor/mambacodegen/LICENSE +24 -0
  57. package/vendor/mambacodegen/lib/mscodegen.js +620 -0
  58. package/vendor/patches/escodegen.diff +130 -0
  59. package/vendor/patches/estraverse.diff +51 -0
  60. package/vendor/patches/pegjs.diff +70 -0
  61. package/vendor/patches/source-map.diff +160 -0
  62. package/vendor/source-map/LICENSE +28 -0
  63. package/vendor/source-map/lib/source-map/array-set.js +92 -0
  64. package/vendor/source-map/lib/source-map/base64-vlq.js +140 -0
  65. package/vendor/source-map/lib/source-map/base64.js +38 -0
  66. package/vendor/source-map/lib/source-map/binary-search.js +77 -0
  67. package/vendor/source-map/lib/source-map/source-map-consumer.js +404 -0
  68. package/vendor/source-map/lib/source-map/source-map-generator.js +229 -0
  69. package/vendor/source-map/lib/source-map/source-node.js +201 -0
  70. package/vendor/source-map/lib/source-map/util.js +57 -0
  71. package/vendor/source-map/lib/source-map.js +8 -0
  72. package/bin/fix +0 -17
  73. package/bin/updateImports +0 -46
  74. package/build.js +0 -25
  75. package/lib/module-esm.js +0 -901
  76. package/lib/pegjs-kofu-plugin.js +0 -35
  77. package/lib/pegjs-mamba-plugin.js +0 -35
  78. package/lib/processor-esm.js +0 -507
  79. package/mamba +0 -259
  80. package/msast.js +0 -1
  81. package/utils/gulp-mamba.js +0 -29
  82. /package/{lib/esm.js → vendor/patches/mambacodegen.diff} +0 -0
@@ -1,35 +0,0 @@
1
- // Generated by KofuScript 0.1.0-beta6
2
- var present = console.log;
3
- // Generated by KofuScript 0.1.0-beta6
4
- var compile, eachCode, KofuScript;
5
- KofuScript = require('./module');
6
- eachCode = require('pegjs-each-code');
7
- compile = function (ksCode, options) {
8
- var jsAST, ksAST;
9
- if (null == options)
10
- options = {};
11
- ksAST = KofuScript.parse('-> ' + ksCode.trimRight());
12
- if (ksAST.body.statements.length > 1)
13
- throw new Error('inconsistent base indentation');
14
- jsAST = KofuScript.compile(ksAST, {
15
- bare: true,
16
- inScope: options.inScope
17
- });
18
- jsAST.leadingComments = [];
19
- jsAST.body = jsAST.body[0].expression.body.body.concat(jsAST.body.slice(1));
20
- return KofuScript.js(jsAST);
21
- };
22
- exports.use = function (config) {
23
- return config.passes.transform.unshift(function (ast) {
24
- ast.initializer.code = KofuScript.cs2js(ast.initializer.code, { bare: true });
25
- return eachCode(ast, function (node, labels, ruleName) {
26
- var error;
27
- try {
28
- return node.code = compile(node.code, { inScope: labels });
29
- } catch (e$) {
30
- error = e$;
31
- throw new Error("In the '" + ruleName + "' rule:\n" + error.message + '');
32
- }
33
- });
34
- });
35
- };
@@ -1,35 +0,0 @@
1
- // Generated by MambaScript 0.5.2
2
- var present = console.log;
3
- // Generated by MambaScript 0.5.2
4
- var compile, eachCode, MambaScript;
5
- MambaScript = require('./module');
6
- eachCode = require('pegjs-each-code');
7
- compile = function (ksCode, options) {
8
- var jsAST, ksAST;
9
- if (null == options)
10
- options = {};
11
- ksAST = MambaScript.parse('-> ' + ksCode.trimRight());
12
- if (ksAST.body.statements.length > 1)
13
- throw new Error('inconsistent base indentation');
14
- jsAST = MambaScript.compile(ksAST, {
15
- bare: true,
16
- inScope: options.inScope
17
- });
18
- jsAST.leadingComments = [];
19
- jsAST.body = jsAST.body[0].expression.body.body.concat(jsAST.body.slice(1));
20
- return MambaScript.js(jsAST);
21
- };
22
- exports.use = function (config) {
23
- return config.passes.transform.unshift(function (ast) {
24
- ast.initializer.code = MambaScript.cs2js(ast.initializer.code, { bare: true });
25
- return eachCode(ast, function (node, labels, ruleName) {
26
- var error;
27
- try {
28
- return node.code = compile(node.code, { inScope: labels });
29
- } catch (e$) {
30
- error = e$;
31
- throw new Error("In the '" + ruleName + "' rule:\n" + error.message + '');
32
- }
33
- });
34
- });
35
- };
@@ -1,507 +0,0 @@
1
- // Generated by KofuScript 0.0.3-alpha.2
2
- var present = console.log;
3
- // Generated by KofuScript 0.0.3-alpha.2
4
- var DEDENT, INDENT, pointToErrorLocation, Preprocessor, StringScanner, TERM, ws;
5
- StringScanner = function () {
6
- function StringScanner(param$) {
7
- if (null == param$)
8
- param$ = '';
9
- this.str = param$;
10
- this.str = '' + this.str;
11
- this.pos = 0;
12
- this.lastMatch = {
13
- reset: function () {
14
- this.str = null;
15
- this.captures = [];
16
- return this;
17
- }
18
- }.reset();
19
- }
20
- StringScanner.prototype.bol = function () {
21
- return this.pos <= 0 || this.str[this.pos - 1] === '\n';
22
- };
23
- StringScanner.prototype.captures = function () {
24
- return this.lastMatch.captures;
25
- };
26
- StringScanner.prototype.check = function (pattern) {
27
- var matches;
28
- if (this.str.substr(this.pos).search(pattern) !== 0) {
29
- this.lastMatch.reset();
30
- return null;
31
- }
32
- matches = this.str.substr(this.pos).match(pattern);
33
- this.lastMatch.str = matches[0];
34
- this.lastMatch.captures = matches.slice(1);
35
- return this.lastMatch.str;
36
- };
37
- StringScanner.prototype.checkUntil = function (pattern) {
38
- var matches, patternPos;
39
- patternPos = this.str.substr(this.pos).search(pattern);
40
- if (patternPos < 0) {
41
- this.lastMatch.reset();
42
- return null;
43
- }
44
- matches = this.str.substr(this.pos + patternPos).match(pattern);
45
- this.lastMatch.captures = matches.slice(1);
46
- return this.lastMatch.str = this.str.substr(this.pos, patternPos) + matches[0];
47
- };
48
- StringScanner.prototype.clone = function () {
49
- var clone, prop, value;
50
- clone = new this.constructor(this.str);
51
- clone.pos = this.pos;
52
- clone.lastMatch = {};
53
- for (prop in this.lastMatch) {
54
- value = this.lastMatch[prop];
55
- clone.lastMatch[prop] = value;
56
- }
57
- return clone;
58
- };
59
- StringScanner.prototype.concat = function (str) {
60
- this.str += str;
61
- return this;
62
- };
63
- StringScanner.prototype.eos = function () {
64
- return this.pos === this.str.length;
65
- };
66
- StringScanner.prototype.exists = function (pattern) {
67
- var matches, patternPos;
68
- patternPos = this.str.substr(this.pos).search(pattern);
69
- if (patternPos < 0) {
70
- this.lastMatch.reset();
71
- return null;
72
- }
73
- matches = this.str.substr(this.pos + patternPos).match(pattern);
74
- this.lastMatch.str = matches[0];
75
- this.lastMatch.captures = matches.slice(1);
76
- return patternPos;
77
- };
78
- StringScanner.prototype.getch = function () {
79
- return this.scan(/./);
80
- };
81
- StringScanner.prototype.match = function () {
82
- return this.lastMatch.str;
83
- };
84
- StringScanner.prototype.matches = function (pattern) {
85
- this.check(pattern);
86
- return this.matchSize();
87
- };
88
- StringScanner.prototype.matched = function () {
89
- return null != this.lastMatch.str;
90
- };
91
- StringScanner.prototype.matchSize = function () {
92
- if (this.matched()) {
93
- return this.match().length;
94
- } else {
95
- return null;
96
- }
97
- };
98
- StringScanner.prototype.peek = function (len) {
99
- return this.str.substr(this.pos, len);
100
- };
101
- StringScanner.prototype.pointer = function () {
102
- return this.pos;
103
- };
104
- StringScanner.prototype.setPointer = function (pos) {
105
- pos = +pos;
106
- if (pos < 0)
107
- pos = 0;
108
- if (pos > this.str.length)
109
- pos = this.str.length;
110
- return this.pos = pos;
111
- };
112
- StringScanner.prototype.reset = function () {
113
- this.lastMatch.reset();
114
- this.pos = 0;
115
- return this;
116
- };
117
- StringScanner.prototype.rest = function () {
118
- return this.str.substr(this.pos);
119
- };
120
- StringScanner.prototype.scan = function (pattern) {
121
- var chk;
122
- chk = this.check(pattern);
123
- if (null != chk)
124
- this.pos += chk.length;
125
- return chk;
126
- };
127
- StringScanner.prototype.scanUntil = function (pattern) {
128
- var chk;
129
- chk = this.checkUntil(pattern);
130
- if (null != chk)
131
- this.pos += chk.length;
132
- return chk;
133
- };
134
- StringScanner.prototype.skip = function (pattern) {
135
- this.scan(pattern);
136
- return this.matchSize();
137
- };
138
- StringScanner.prototype.skipUntil = function (pattern) {
139
- this.scanUntil(pattern);
140
- return this.matchSize();
141
- };
142
- StringScanner.prototype.string = function () {
143
- return this.str;
144
- };
145
- StringScanner.prototype.terminate = function () {
146
- this.pos = this.str.length;
147
- this.lastMatch.reset();
148
- return this;
149
- };
150
- StringScanner.prototype.toString = function () {
151
- return '#<StringScanner ' + (this.eos() ? 'fin' : '' + this.pos + '/' + this.str.length + ' @ ' + (this.str.length > 8 ? '' + this.str.substr(0, 5) + '...' : this.str)) + '>';
152
- };
153
- return StringScanner;
154
- }();
155
- StringScanner.prototype.beginningOfLine = StringScanner.prototype.bol;
156
- StringScanner.prototype.clear = StringScanner.prototype.terminate;
157
- StringScanner.prototype.dup = StringScanner.prototype.clone;
158
- StringScanner.prototype.endOfString = StringScanner.prototype.eos;
159
- StringScanner.prototype.exist = StringScanner.prototype.exists;
160
- StringScanner.prototype.getChar = StringScanner.prototype.getch;
161
- StringScanner.prototype.position = StringScanner.prototype.pointer;
162
- StringScanner.StringScanner = StringScanner;
163
- pointToErrorLocation = function (source, line, column, numLinesOfContext) {
164
- var currentLineOffset, lines, numberedLines, padSize, postLines, preLines, startLine;
165
- if (null == numLinesOfContext)
166
- numLinesOfContext = 3;
167
- lines = source.split('\n');
168
- if (!lines[lines.length - 1])
169
- lines.pop();
170
- currentLineOffset = line - 1;
171
- startLine = currentLineOffset - numLinesOfContext;
172
- if (startLine < 0)
173
- startLine = 0;
174
- preLines = lines.slice(startLine, +currentLineOffset + 1 || 9e9);
175
- preLines[preLines.length - 1] = colourise('yellow', preLines[preLines.length - 1]);
176
- postLines = lines.slice(currentLineOffset + 1, +(currentLineOffset + numLinesOfContext) + 1 || 9e9);
177
- numberedLines = numberLines(cleanMarkers([].slice.call(preLines).concat([].slice.call(postLines)).join('\n')), startLine + 1).split('\n');
178
- preLines = numberedLines.slice(0, preLines.length);
179
- postLines = numberedLines.slice(preLines.length);
180
- column = cleanMarkers(('' + lines[currentLineOffset] + '\n').slice(0, column)).length;
181
- padSize = (currentLineOffset + 1 + postLines.length).toString(10).length;
182
- return [].slice.call(preLines).concat(['' + colourise('red', Array(padSize + 1).join('^')) + ' : ' + Array(column).join(' ') + colourise('red', '^')], [].slice.call(postLines)).join('\n');
183
- };
184
- this.Preprocessor = Preprocessor = function () {
185
- ws = '\\t\\x0B\\f\\r \\xA0\\u1680\\u180E\\u2000-\\u200A\\u202F\\u205F\\u3000\\uFEFF';
186
- INDENT = '\uefef';
187
- DEDENT = '\ueffe';
188
- TERM = '\uefff';
189
- function Preprocessor(param$) {
190
- if (null == param$)
191
- param$ = {};
192
- this.options = param$;
193
- this.preprocessed = '';
194
- this.base = null;
195
- this.indents = [];
196
- this.context = [];
197
- }
198
- Preprocessor.process = function (input, options) {
199
- if (null == options)
200
- options = {};
201
- return new Preprocessor(options).process(input);
202
- };
203
- Preprocessor.prototype.err = function (c) {
204
- var columns, context, lines, token;
205
- token = function () {
206
- switch (c) {
207
- case INDENT:
208
- return 'INDENT';
209
- case DEDENT:
210
- return 'DEDENT';
211
- case TERM:
212
- return 'TERM';
213
- default:
214
- return '"' + c.replace(/"/g, '\\"') + '"';
215
- }
216
- }.call(this);
217
- lines = this.ss.str.substr(0, this.ss.pos).split(/\n/) || [''];
218
- columns = null != lines[lines.length - 1] ? lines[lines.length - 1].length : 0;
219
- context = pointToErrorLocation(this.ss.str, lines.length, columns);
220
- throw new Error('Unexpected ' + token + '\n' + context);
221
- };
222
- Preprocessor.prototype.peek = function () {
223
- if (this.context.length) {
224
- return this.context[this.context.length - 1];
225
- } else {
226
- return null;
227
- }
228
- };
229
- Preprocessor.prototype.observe = function (c) {
230
- var top;
231
- top = this.peek();
232
- switch (c) {
233
- case '"""':
234
- case "'''":
235
- case '"':
236
- case "'":
237
- case '###':
238
- case '`':
239
- case '///':
240
- case '/':
241
- if (top === c) {
242
- this.context.pop();
243
- } else {
244
- this.context.push(c);
245
- }
246
- break;
247
- case INDENT:
248
- case '#':
249
- case '#{':
250
- case '[':
251
- case '(':
252
- case '{':
253
- case '\\':
254
- case 'regexp-[':
255
- case 'regexp-(':
256
- case 'regexp-{':
257
- case 'heregexp-#':
258
- case 'heregexp-[':
259
- case 'heregexp-(':
260
- case 'heregexp-{':
261
- this.context.push(c);
262
- break;
263
- case DEDENT:
264
- if (!(top === INDENT))
265
- this.err(c);
266
- this.indents.pop();
267
- this.context.pop();
268
- break;
269
- case '\n':
270
- if (!(top === '#' || top === 'heregexp-#'))
271
- this.err(c);
272
- this.context.pop();
273
- break;
274
- case ']':
275
- if (!(top === '[' || top === 'regexp-[' || top === 'heregexp-['))
276
- this.err(c);
277
- this.context.pop();
278
- break;
279
- case ')':
280
- if (!(top === '(' || top === 'regexp-(' || top === 'heregexp-('))
281
- this.err(c);
282
- this.context.pop();
283
- break;
284
- case '}':
285
- if (!(top === '#{' || top === '{' || top === 'regexp-{' || top === 'heregexp-{'))
286
- this.err(c);
287
- this.context.pop();
288
- break;
289
- case 'end-\\':
290
- if (!(top === '\\'))
291
- this.err(c);
292
- this.context.pop();
293
- break;
294
- default:
295
- throw new Error('undefined token observed: ' + c);
296
- }
297
- return this.context;
298
- };
299
- Preprocessor.prototype.p = function (s) {
300
- if (null != s)
301
- this.preprocessed = '' + this.preprocessed + s;
302
- return s;
303
- };
304
- Preprocessor.prototype.scan = function (r) {
305
- return this.p(this.ss.scan(r));
306
- };
307
- Preprocessor.prototype.consumeIndentation = function () {
308
- var context, indent, indentIndex, lineLen, lines, message;
309
- if (this.ss.bol() || this.scan(new RegExp('(?:[' + ws + ']*\\n)+'))) {
310
- this.scan(new RegExp('(?:[' + ws + ']*(\\#\\#?(?!\\#)[^\\n]*)?\\n)+'));
311
- if (null != this.base) {
312
- if (!(this.ss.eos() || null != this.scan(this.base))) {
313
- throw new Error('inconsistent base indentation');
314
- }
315
- } else {
316
- this.base = new RegExp('' + this.scan(new RegExp('[' + ws + ']*')) + '');
317
- }
318
- indentIndex = 0;
319
- while (indentIndex < this.indents.length) {
320
- indent = this.indents[indentIndex];
321
- if (this.ss.check(new RegExp('' + indent + ''))) {
322
- this.scan(new RegExp('' + indent + ''));
323
- } else if (this.ss.eos() || this.ss.check(new RegExp('[^' + ws + ']'))) {
324
- --indentIndex;
325
- this.p('' + DEDENT + TERM);
326
- this.observe(DEDENT);
327
- } else {
328
- lines = this.ss.str.substr(0, this.ss.pos).split(/\n/) || [''];
329
- message = 'Syntax error on line ' + lines.length + ': indentation is ambiguous';
330
- lineLen = this.indents.reduce(function (l, r) {
331
- return l + r.length;
332
- }, 0);
333
- context = pointToErrorLocation(this.ss.str, lines.length, lineLen);
334
- throw new Error('' + message + '\n' + context);
335
- }
336
- ++indentIndex;
337
- }
338
- if (this.ss.check(new RegExp('[' + ws + ']+[^' + ws + '#]'))) {
339
- this.indents.push(this.scan(new RegExp('[' + ws + ']+')));
340
- this.p(INDENT);
341
- return this.observe(INDENT);
342
- }
343
- }
344
- };
345
- Preprocessor.prototype.introduceContext = function () {
346
- var impliedRegexp, lastChar, pos, spaceBefore, tok;
347
- if (tok = this.scan(/"""|'''|\/\/\/|###|["'`#[({\\]/)) {
348
- return this.observe(tok);
349
- } else if (tok = this.scan(/\//)) {
350
- pos = this.ss.position();
351
- if (pos > 1) {
352
- lastChar = this.ss.string()[pos - 2];
353
- spaceBefore = new RegExp('[' + ws + ']').test(lastChar);
354
- impliedRegexp = /[;,=><*%^&|[(+!~-]/.test(lastChar);
355
- }
356
- if (pos === 1 || impliedRegexp || spaceBefore && !this.ss.check(new RegExp('[' + ws + '=]')) && this.ss.check(/[^\r\n]*\//))
357
- return this.observe('/');
358
- }
359
- };
360
- Preprocessor.prototype.process = function (input) {
361
- var tok;
362
- if (this.options.literate)
363
- input = input.replace(/^( {0,3}\S)/gm, ' #$1');
364
- this.ss = new StringScanner(input);
365
- while (!this.ss.eos()) {
366
- switch (this.peek()) {
367
- case null:
368
- case INDENT:
369
- this.consumeIndentation();
370
- this.scan(/[^\n'"\\\/#`[(){}\]]+/);
371
- if (this.ss.check(/[})\]]/)) {
372
- while (this.peek() === INDENT) {
373
- this.p('' + DEDENT + TERM);
374
- this.observe(DEDENT);
375
- }
376
- this.observe(this.scan(/[})\]]/));
377
- } else {
378
- this.introduceContext();
379
- }
380
- break;
381
- case '#{':
382
- case '{':
383
- this.scan(/[^\n'"\\\/#`[({}]+/);
384
- if (tok = this.scan(/\}/)) {
385
- this.observe(tok);
386
- } else {
387
- this.consumeIndentation();
388
- this.introduceContext();
389
- }
390
- break;
391
- case '[':
392
- this.scan(/[^\n'"\\\/#`[({\]]+/);
393
- if (tok = this.scan(/\]/)) {
394
- this.observe(tok);
395
- } else {
396
- this.consumeIndentation();
397
- this.introduceContext();
398
- }
399
- break;
400
- case '(':
401
- this.scan(/[^\n'"\\\/#`[({)]+/);
402
- if (tok = this.scan(/\)/)) {
403
- this.observe(tok);
404
- } else {
405
- this.consumeIndentation();
406
- this.introduceContext();
407
- }
408
- break;
409
- case '\\':
410
- if (this.scan(/[\s\S]/))
411
- this.observe('end-\\');
412
- break;
413
- case '"""':
414
- this.scan(/(?:[^"#\\]+|""?(?!")|#(?!{)|\\.)+/);
415
- this.ss.scan(/\\\n/);
416
- if (tok = this.scan(/#{|"""/)) {
417
- this.observe(tok);
418
- } else if (tok = this.scan(/#{|"""/)) {
419
- this.observe(tok);
420
- }
421
- break;
422
- case '"':
423
- this.scan(/(?:[^"#\\]+|#(?!{)|\\.)+/);
424
- this.ss.scan(/\\\n/);
425
- if (tok = this.scan(/#{|"/))
426
- this.observe(tok);
427
- break;
428
- case "'''":
429
- this.scan(/(?:[^'\\]+|''?(?!')|\\.)+/);
430
- this.ss.scan(/\\\n/);
431
- if (tok = this.scan(/'''/))
432
- this.observe(tok);
433
- break;
434
- case "'":
435
- this.scan(/(?:[^'\\]+|\\.)+/);
436
- this.ss.scan(/\\\n/);
437
- if (tok = this.scan(/'/))
438
- this.observe(tok);
439
- break;
440
- case '###':
441
- this.scan(/(?:[^#]+|##?(?!#))+/);
442
- if (tok = this.scan(/###/))
443
- this.observe(tok);
444
- break;
445
- case '#':
446
- this.scan(/[^\n]+/);
447
- if (tok = this.scan(/\n/))
448
- this.observe(tok);
449
- break;
450
- case '`':
451
- this.scan(/[^`]+/);
452
- if (tok = this.scan(/`/))
453
- this.observe(tok);
454
- break;
455
- case '///':
456
- this.scan(/(?:[^[/#\\]+|\/\/?(?!\/)|\\.)+/);
457
- if (tok = this.scan(/#{|\/\/\/|\\/)) {
458
- this.observe(tok);
459
- } else if (this.ss.scan(/#/)) {
460
- this.observe('heregexp-#');
461
- } else if (tok = this.scan(/[\[]/)) {
462
- this.observe('heregexp-' + tok);
463
- }
464
- break;
465
- case 'heregexp-[':
466
- this.scan(/(?:[^\]\/\\]+|\/\/?(?!\/))+/);
467
- if (tok = this.scan(/[\]\\]|#{|\/\/\//))
468
- this.observe(tok);
469
- break;
470
- case 'heregexp-#':
471
- this.ss.scan(/(?:[^\n/]+|\/\/?(?!\/))+/);
472
- if (tok = this.scan(/\n|\/\/\//))
473
- this.observe(tok);
474
- break;
475
- case '/':
476
- this.scan(/[^[/\\]+/);
477
- if (tok = this.scan(/[\/\\]/)) {
478
- this.observe(tok);
479
- } else if (tok = this.scan(/\[/)) {
480
- this.observe('regexp-' + tok);
481
- }
482
- break;
483
- case 'regexp-[':
484
- this.scan(/[^\]\\]+/);
485
- if (tok = this.scan(/[\]\\]/))
486
- this.observe(tok);
487
- }
488
- }
489
- this.scan(new RegExp('[' + ws + '\\n]*$'));
490
- while (this.context.length) {
491
- switch (this.peek()) {
492
- case INDENT:
493
- this.p('' + DEDENT + TERM);
494
- this.observe(DEDENT);
495
- break;
496
- case '#':
497
- this.p('\n');
498
- this.observe('\n');
499
- break;
500
- default:
501
- throw new Error('Unclosed "' + this.peek().replace(/"/g, '\\"') + '" at EOF');
502
- }
503
- }
504
- return this.preprocessed;
505
- };
506
- return Preprocessor;
507
- }();