UNPKG

76.7 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ i: moduleId,
16/******/ l: false,
17/******/ exports: {}
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.l = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // identity function for calling harmony imports with the correct context
38/******/ __webpack_require__.i = function(value) { return value; };
39
40/******/ // define getter function for harmony exports
41/******/ __webpack_require__.d = function(exports, name, getter) {
42/******/ if(!__webpack_require__.o(exports, name)) {
43/******/ Object.defineProperty(exports, name, {
44/******/ configurable: false,
45/******/ enumerable: true,
46/******/ get: getter
47/******/ });
48/******/ }
49/******/ };
50
51/******/ // getDefaultExport function for compatibility with non-harmony modules
52/******/ __webpack_require__.n = function(module) {
53/******/ var getter = module && module.__esModule ?
54/******/ function getDefault() { return module['default']; } :
55/******/ function getModuleExports() { return module; };
56/******/ __webpack_require__.d(getter, 'a', getter);
57/******/ return getter;
58/******/ };
59
60/******/ // Object.prototype.hasOwnProperty.call
61/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
62
63/******/ // __webpack_public_path__
64/******/ __webpack_require__.p = "";
65
66/******/ // Load entry module and return exports
67/******/ return __webpack_require__(__webpack_require__.s = 27);
68/******/ })
69/************************************************************************/
70/******/ ([
71/* 0 */
72/***/ (function(module, exports) {
73
74module.exports = require("art-standard-lib");
75
76/***/ }),
77/* 1 */
78/***/ (function(module, exports) {
79
80module.exports = require("art-class-system");
81
82/***/ }),
83/* 2 */
84/***/ (function(module, exports, __webpack_require__) {
85
86module.exports = __webpack_require__(5);
87
88module.exports.addModules({
89 EmptyNode: __webpack_require__(10),
90 EmptyOptionalNode: __webpack_require__(21),
91 Node: __webpack_require__(11),
92 ScratchNode: __webpack_require__(22)
93});
94
95
96/***/ }),
97/* 3 */
98/***/ (function(module, exports, __webpack_require__) {
99
100var Stats,
101 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
102 hasProp = {}.hasOwnProperty;
103
104module.exports = Stats = (function(superClass) {
105 extend(Stats, superClass);
106
107 function Stats() {
108 return Stats.__super__.constructor.apply(this, arguments);
109 }
110
111 Stats._stats = {};
112
113 Stats.reset = function() {
114 return this._stats = {};
115 };
116
117 Stats.add = function(statName, amount) {
118 if (amount == null) {
119 amount = 1;
120 }
121 return this._stats[statName] = (this._stats[statName] || 0) + amount;
122 };
123
124 Stats.get = function() {
125 return this._stats;
126 };
127
128 return Stats;
129
130})(__webpack_require__(1).BaseClass);
131
132
133/***/ }),
134/* 4 */
135/***/ (function(module, exports) {
136
137module.exports = function(module) {
138 if(!module.webpackPolyfill) {
139 module.deprecate = function() {};
140 module.paths = [];
141 // module.parent = undefined by default
142 if(!module.children) module.children = [];
143 Object.defineProperty(module, "loaded", {
144 enumerable: true,
145 get: function() {
146 return module.l;
147 }
148 });
149 Object.defineProperty(module, "id", {
150 enumerable: true,
151 get: function() {
152 return module.i;
153 }
154 });
155 module.webpackPolyfill = 1;
156 }
157 return module;
158};
159
160
161/***/ }),
162/* 5 */
163/***/ (function(module, exports, __webpack_require__) {
164
165var BabelBridge, Nodes,
166 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
167 hasProp = {}.hasOwnProperty;
168
169BabelBridge = __webpack_require__(7);
170
171module.exports = BabelBridge.Nodes || BabelBridge.addNamespace('Nodes', Nodes = (function(superClass) {
172 extend(Nodes, superClass);
173
174 function Nodes() {
175 return Nodes.__super__.constructor.apply(this, arguments);
176 }
177
178 return Nodes;
179
180})(Neptune.Base));
181
182
183/***/ }),
184/* 6 */
185/***/ (function(module, exports, __webpack_require__) {
186
187/* WEBPACK VAR INJECTION */(function(module) {var Repl, defineModule, formattedInspect, isClass, log, ref;
188
189ref = __webpack_require__(0), defineModule = ref.defineModule, formattedInspect = ref.formattedInspect, isClass = ref.isClass, log = ref.log;
190
191__webpack_require__(24);
192
193defineModule(module, Repl = (function() {
194 function Repl() {}
195
196 Repl.babelBridgeRepl = function(parser) {
197 if (isClass(parser)) {
198 parser = new parser;
199 }
200 return __webpack_require__(26).start({
201 prompt: ((parser.getClassName()) + "> ").grey,
202 "eval": function(command, context, filename, callback) {
203 var e, parsed, result;
204 try {
205 parsed = parser.parse(command.trim());
206 try {
207 if (result = typeof parsed.evaluate === "function" ? parsed.evaluate() : void 0) {
208 return callback(null, result);
209 } else {
210 log(formattedInspect(parsed, {
211 color: true
212 }));
213 return callback();
214 }
215 } catch (error) {
216 e = error;
217 return callback(e);
218 }
219 } catch (error) {
220 e = error;
221 return callback(parser.getParseFailureInfo({
222 color: true
223 }).replace("<HERE>", "<HERE>".red));
224 }
225 }
226 });
227 };
228
229 return Repl;
230
231})());
232
233/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
234
235/***/ }),
236/* 7 */
237/***/ (function(module, exports, __webpack_require__) {
238
239var BabelBridge, Neptune,
240 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
241 hasProp = {}.hasOwnProperty;
242
243Neptune = __webpack_require__(25);
244
245module.exports = Neptune.BabelBridge || Neptune.addNamespace('BabelBridge', BabelBridge = (function(superClass) {
246 extend(BabelBridge, superClass);
247
248 function BabelBridge() {
249 return BabelBridge.__super__.constructor.apply(this, arguments);
250 }
251
252 return BabelBridge;
253
254})(Neptune.Base));
255
256__webpack_require__(9);
257
258__webpack_require__(5);
259
260
261/***/ }),
262/* 8 */
263/***/ (function(module, exports, __webpack_require__) {
264
265/* WEBPACK VAR INJECTION */(function(module) {var BabelBridgeCompileError, ErrorWithInfo, defineModule, formattedInspect, isFunction, log, mergeInto, ref,
266 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
267 hasProp = {}.hasOwnProperty;
268
269ref = __webpack_require__(0), defineModule = ref.defineModule, log = ref.log, mergeInto = ref.mergeInto, isFunction = ref.isFunction, formattedInspect = ref.formattedInspect, ErrorWithInfo = ref.ErrorWithInfo;
270
271defineModule(module, BabelBridgeCompileError = (function(superClass) {
272 extend(BabelBridgeCompileError, superClass);
273
274 function BabelBridgeCompileError(message, info) {
275 BabelBridgeCompileError.__super__.constructor.call(this, message, info, "BabelBridgeCompileError");
276 }
277
278 return BabelBridgeCompileError;
279
280})(ErrorWithInfo));
281
282/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
283
284/***/ }),
285/* 9 */
286/***/ (function(module, exports, __webpack_require__) {
287
288var BabelBridge, Extensions,
289 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
290 hasProp = {}.hasOwnProperty;
291
292BabelBridge = __webpack_require__(7);
293
294module.exports = BabelBridge.Extensions || BabelBridge.addNamespace('Extensions', Extensions = (function(superClass) {
295 extend(Extensions, superClass);
296
297 function Extensions() {
298 return Extensions.__super__.constructor.apply(this, arguments);
299 }
300
301 return Extensions;
302
303})(Neptune.Base));
304
305
306/***/ }),
307/* 10 */
308/***/ (function(module, exports, __webpack_require__) {
309
310var EmptyNode,
311 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
312 hasProp = {}.hasOwnProperty;
313
314module.exports = EmptyNode = (function(superClass) {
315 extend(EmptyNode, superClass);
316
317 function EmptyNode() {
318 return EmptyNode.__super__.constructor.apply(this, arguments);
319 }
320
321 EmptyNode.getter({
322 present: function() {
323 return false;
324 }
325 });
326
327 return EmptyNode;
328
329})(__webpack_require__(11));
330
331
332/***/ }),
333/* 11 */
334/***/ (function(module, exports, __webpack_require__) {
335
336var BaseClass, Node, Nodes, Stats, array, arrayWith, compactFlatten, inspectedObjectLiteral, isPlainArray, isPlainObject, log, merge, mergeInto, objectWithout, peek, push, ref,
337 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
338 hasProp = {}.hasOwnProperty;
339
340ref = __webpack_require__(0), arrayWith = ref.arrayWith, array = ref.array, peek = ref.peek, log = ref.log, push = ref.push, compactFlatten = ref.compactFlatten, objectWithout = ref.objectWithout, isPlainArray = ref.isPlainArray, isPlainObject = ref.isPlainObject, inspectedObjectLiteral = ref.inspectedObjectLiteral, merge = ref.merge, mergeInto = ref.mergeInto;
341
342Nodes = __webpack_require__(5);
343
344BaseClass = __webpack_require__(1).BaseClass;
345
346Stats = __webpack_require__(3);
347
348module.exports = Node = (function(superClass) {
349 var emptyArray;
350
351 extend(Node, superClass);
352
353 function Node(parent, options) {
354 var ref1;
355 Node.__super__.constructor.apply(this, arguments);
356 Stats.add("newNode");
357 this._parent = parent;
358 this._parser = parent._parser;
359 this._offset = ((ref1 = options != null ? options.offset : void 0) != null ? ref1 : this._parent.getNextOffset()) | 0;
360 this._matchLength = 0;
361 this._ruleName = this._pluralRuleName = this._label = this._pluralLabel = this._pattern = this._nonMatches = this._ruleVariant = this._matches = this._matchPatterns = null;
362 this._labelsApplied = this._nonMatch = false;
363 if (options) {
364 this._matchLength = (options.matchLength || 0) | 0;
365 this._ruleVariant = options.ruleVariant;
366 this._matches = options.matches;
367 this._matchPatterns = options.matchPatterns;
368 }
369 }
370
371 Node._createSubclassBase = function() {
372 var NodeSubclass;
373 return NodeSubclass = (function(superClass1) {
374 extend(NodeSubclass, superClass1);
375
376 function NodeSubclass() {
377 return NodeSubclass.__super__.constructor.apply(this, arguments);
378 }
379
380 return NodeSubclass;
381
382 })(this);
383 };
384
385 Node.createSubclass = function(options) {
386 var klass;
387 klass = this._createSubclassBase();
388 if (options.name) {
389 klass._name = klass.prototype._name = options.name;
390 }
391 if (options.ruleVarient) {
392 klass.ruleVarient = options.ruleVarient;
393 klass.rule = klass.ruleVariant.rule;
394 }
395 mergeInto(klass.prototype, objectWithout(options, "getter"));
396 if (options.getter) {
397 klass.getter(options.getter);
398 }
399 return klass;
400 };
401
402 Node.prototype.toString = function() {
403 return this.text;
404 };
405
406 emptyArray = [];
407
408 Node.setter("matches offset matchLength ruleVariant pattern matchPatterns");
409
410 Node.getter("parent parser offset matchLength matchPatterns label pluralLabel ruleName pluralRuleName pattern nonMatch", {
411 realNode: function() {
412 return this;
413 },
414 name: function() {
415 return this._name || this.ruleName || this["class"].getName();
416 },
417 present: function() {
418 return this._matchLength > 0 || this._nonMatch;
419 },
420 matches: function() {
421 return this._matches || (this._matches = []);
422 },
423 source: function() {
424 return this._parser.source;
425 },
426 isRoot: function() {
427 return this._parser === this._parent;
428 },
429 absoluteOffset: function() {
430 return this._parser.offsetInRootParserSource(this._offset);
431 },
432 ancestors: function(into) {
433 if (into == null) {
434 into = [];
435 }
436 this.parent.getAncestors(into);
437 into.push(this);
438 return into;
439 },
440 parseInfo: function() {
441 if (this.subparseInfo) {
442 return "subparse:" + this.ruleName + ":" + this.offset;
443 } else {
444 return this.ruleName + ":" + this.offset;
445 }
446 },
447 rulePath: function() {
448 var ancestor, ancestorRuleNames;
449 ancestorRuleNames = (function() {
450 var j, len, ref1, results;
451 ref1 = this.ancestors;
452 results = [];
453 for (j = 0, len = ref1.length; j < len; j++) {
454 ancestor = ref1[j];
455 results.push(ancestor.parseInfo);
456 }
457 return results;
458 }).call(this);
459 return ancestorRuleNames.join(" > ");
460 },
461 nextOffset: function() {
462 return this.offset + this.matchLength;
463 },
464 text: function() {
465 var matchLength, offset, ref1, source;
466 ref1 = this.subparseInfo || this, matchLength = ref1.matchLength, offset = ref1.offset, source = ref1.source;
467 if (matchLength === 0) {
468 return "";
469 } else {
470 return source.slice(offset, offset + matchLength);
471 }
472 },
473 ruleVariant: function() {
474 var ref1;
475 return this._ruleVariant || ((ref1 = this._parent) != null ? ref1.ruleVariant : void 0);
476 },
477 ruleName: function() {
478 var ref1;
479 return this.ruleNameOrNull || ((ref1 = this.parent) != null ? ref1.ruleName : void 0) || ("" + (this.pattern || 'no rule'));
480 },
481 ruleNameOrNull: function() {
482 var ref1, ref2;
483 return ((ref1 = this["class"].rule) != null ? ref1.getName() : void 0) || ((ref2 = this._ruleVariant) != null ? ref2.rule.getName() : void 0);
484 },
485 ruleNameOrPattern: function() {
486 var ref1;
487 return this.ruleNameOrNull || ("" + (((ref1 = this.pattern) != null ? ref1.pattern : void 0) || 'no rule'));
488 },
489 isRuleNode: function() {
490 return this["class"].rule;
491 },
492 isPassThrough: function() {
493 var ref1;
494 return (ref1 = this.ruleVariant) != null ? ref1.isPassThrough : void 0;
495 },
496 nonPassThrough: function() {
497 var ref1;
498 return !((ref1 = this.ruleVariant) != null ? ref1.isPassThrough : void 0);
499 }
500 });
501
502 Node.prototype.getNextText = function(length) {
503 var nextOffset;
504 nextOffset = this.nextOffset;
505 return this.source.slice(nextOffset, nextOffset + length);
506 };
507
508 Node.prototype.formattedInspect = function() {
509 return "CUSTOM";
510 };
511
512 Node.getter({
513 parseTreePath: function() {
514 var ref1;
515 return compactFlatten([(ref1 = this.parent) != null ? ref1.parseTreePath : void 0, this["class"].getName()]);
516 },
517 presentMatches: function() {
518 var j, len, m, ref1, results;
519 ref1 = this.matches;
520 results = [];
521 for (j = 0, len = ref1.length; j < len; j++) {
522 m = ref1[j];
523 if (typeof m.getPresent === "function" ? m.getPresent() : void 0) {
524 results.push(m);
525 }
526 }
527 return results;
528 },
529 isNonMatch: function() {
530 return !!this.nonMatch;
531 },
532 isPartialMatch: function() {
533 var j, len, match, ref1;
534 if (!this.nonMatch) {
535 return false;
536 }
537 ref1 = this.presentMatches;
538 for (j = 0, len = ref1.length; j < len; j++) {
539 match = ref1[j];
540 if (!match.nonMatch) {
541 return true;
542 }
543 }
544 return false;
545 },
546 isMatch: function() {
547 return !this.nonMatch;
548 },
549 nonMatchingLeaf: function() {
550 return this.nonMatch && peek(this.matches);
551 },
552 firstPartialMatchParent: function() {
553 if (this.parent === this.parser || this.isPartialMatch) {
554 return this;
555 } else {
556 return this.parent.firstPartialMatchParent;
557 }
558 },
559 inspectedObjects: function(verbose) {
560 var children, hasOneOrMoreMatchingChildren, label, match, matches, nonMatch, obj, parts, path, ref1, ref2, ref3, ruleName;
561 match = this;
562 matches = this.presentMatches;
563 if (matches.length > 0) {
564 path = [];
565 while (matches.length === 1 && ((ref1 = matches[0].matches) != null ? ref1.length : void 0) > 0) {
566 path.push("" + (match.label ? match.label + ":" : "") + match.ruleName);
567 match = matches[0];
568 matches = match.presentMatches;
569 }
570 label = match.label, ruleName = match.ruleName, nonMatch = match.nonMatch;
571 path.push(ruleName);
572 path = path.join('.');
573 hasOneOrMoreMatchingChildren = false;
574 children = (function() {
575 var j, len, results;
576 results = [];
577 for (j = 0, len = matches.length; j < len; j++) {
578 match = matches[j];
579 if (!match.nonMatch) {
580 hasOneOrMoreMatchingChildren = true;
581 }
582 results.push(match.getInspectedObjects(verbose));
583 }
584 return results;
585 })();
586 parts = compactFlatten([
587 label ? {
588 label: label
589 } : void 0, children.length > 0 ? children : match.toString()
590 ]);
591 if (parts.length === 1) {
592 parts = parts[0];
593 }
594 return (
595 obj = {},
596 obj["" + (nonMatch ? hasOneOrMoreMatchingChildren ? 'partialMatch-' : 'nonMatch-' : '') + path] = parts,
597 obj
598 );
599 } else if (this.nonMatch) {
600 return {
601 nonMatch: {
602 offset: this.offset,
603 pattern: "" + ((ref2 = this.pattern) != null ? ref2.pattern : void 0)
604 }
605 };
606 } else {
607 if (verbose) {
608 return {
609 token: {
610 offset: this.offset,
611 length: this.matchLength,
612 text: this.text,
613 pattern: "" + ((ref3 = this.pattern) != null ? ref3.pattern : void 0),
614 "class": this["class"].getName(),
615 ruleName: this.ruleName
616 }
617 };
618 } else {
619 return this.text;
620 }
621 }
622 },
623 detailedInspectedObjects: function() {
624 var children, match, matches, ret;
625 matches = this.matches;
626 if (matches.length > 0) {
627 children = (function() {
628 var j, len, results;
629 results = [];
630 for (j = 0, len = matches.length; j < len; j++) {
631 match = matches[j];
632 results.push(match.detailedInspectedObjects);
633 }
634 return results;
635 })();
636 ret = {};
637 ret[this.name] = children.length === 1 ? children[0] : children;
638 return ret;
639 } else {
640 return this.text;
641 }
642 },
643 plainObjects: function() {
644 var match, ref1, ret;
645 ret = [
646 {
647 inspect: (function(_this) {
648 return function() {
649 return _this["class"].getName();
650 };
651 })(this)
652 }
653 ];
654 if (((ref1 = this._matches) != null ? ref1.length : void 0) > 0) {
655 ret = ret.concat((function() {
656 var j, len, ref2, results;
657 ref2 = this.matches;
658 results = [];
659 for (j = 0, len = ref2.length; j < len; j++) {
660 match = ref2[j];
661 results.push(match.getPlainObjects());
662 }
663 return results;
664 }).call(this));
665 } else {
666 ret = this.text;
667 }
668 return ret;
669 }
670 });
671
672 Node.prototype.find = function(searchName, out) {
673 var j, len, m, ref1;
674 if (out == null) {
675 out = [];
676 }
677 ref1 = this.matches;
678 for (j = 0, len = ref1.length; j < len; j++) {
679 m = ref1[j];
680 if (m.getName() === searchName) {
681 out.push(m);
682 } else {
683 m.find(searchName, out);
684 }
685 }
686 return out;
687 };
688
689 Node.prototype.subparse = function(subSource, options) {
690 return this._parser.subparse(subSource, merge(options, {
691 parentNode: this
692 }));
693 };
694
695
696 /*
697 IN: pattern, match - instanceof Node
698 OUT: true if match was added
699 */
700
701 Node.prototype.addMatch = function(pattern, match) {
702 if (!match) {
703 return false;
704 }
705 this._matches = push(this._matches, match);
706 this._matchPatterns = push(this._matchPatterns, pattern);
707 this._matchLength = match.nextOffset - this.offset;
708 return true;
709 };
710
711 Node.prototype.applyLabels = function() {
712 if (!this._matches || this._labelsApplied) {
713 return;
714 }
715 this._labelsApplied = true;
716 return array(this._matches, (function(_this) {
717 return function(match, i) {
718 var label, pattern, pluralLabel, pluralRuleName, ruleName;
719 pattern = _this._matchPatterns[i];
720 match._parent = _this;
721 if (pattern) {
722 label = pattern.label, ruleName = pattern.ruleName;
723 match._pattern = pattern;
724 match._label = label;
725 match._ruleName = ruleName;
726 }
727 if (label) {
728 match._pluralLabel = pluralLabel = _this.parser.pluralize(label);
729 }
730 if (ruleName) {
731 match._pluralRuleName = pluralRuleName = _this.parser.pluralize(ruleName);
732 }
733 label || (label = ruleName);
734 pluralLabel || (pluralLabel = pluralRuleName);
735 if (label && !(match instanceof Nodes.EmptyNode)) {
736 _this._bindToLabelLists(pluralLabel, match);
737 _this._bindToSingleLabels(label, match);
738 }
739 return match.applyLabels();
740 };
741 })(this));
742 };
743
744 Node.prototype._bindToLabelLists = function(pluralLabel, match) {
745 if (this.__proto__[pluralLabel] == null) {
746 return this[pluralLabel] = push(this[pluralLabel], match);
747 }
748 };
749
750 Node.prototype._bindToSingleLabels = function(label, match) {
751 if (this.__proto__[label] == null) {
752 return this[label] = match;
753 }
754 };
755
756 Node.prototype._addNonMatch = function(node) {
757 return (this._nonMatches || (this._nonMatches = [])).push(node);
758 };
759
760 Node.prototype._addToParentAsNonMatch = function() {
761 if (this._matchLength === 0) {
762 this._matchLength = 1;
763 }
764 if (this.parent) {
765 if (this.parent.matches) {
766 if (!(0 <= this.parent.matches.indexOf(this))) {
767 this._nonMatch = true;
768 this.parent.matches.push(this);
769 this.parent._presentMatches = null;
770 if (this.parent._matchLength === 0) {
771 this.parent._matchLength = 1;
772 }
773 }
774 return this.parent._addToParentAsNonMatch();
775 } else {
776 return this;
777 }
778 } else {
779 return this;
780 }
781 };
782
783 return Node;
784
785})(BaseClass);
786
787
788/***/ }),
789/* 12 */
790/***/ (function(module, exports, __webpack_require__) {
791
792/* WEBPACK VAR INJECTION */(function(module) {var BaseClass, NonMatch, defineModule, log, ref,
793 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
794 hasProp = {}.hasOwnProperty;
795
796ref = __webpack_require__(0), log = ref.log, defineModule = ref.defineModule;
797
798BaseClass = __webpack_require__(1).BaseClass;
799
800defineModule(module, NonMatch = (function(superClass) {
801 extend(NonMatch, superClass);
802
803 function NonMatch(_node, _patternElement) {
804 this._node = _node;
805 this._patternElement = _patternElement;
806 }
807
808 NonMatch.getter("node patternElement", {
809 inspectedObjects: function() {
810 return {
811 NonMatch: {
812 patternElement: this.toString(),
813 offset: this.node.offset
814 }
815 };
816 }
817 });
818
819 NonMatch.prototype.toString = function() {
820 return this.patternElement.ruleVariant.toString();
821 };
822
823 return NonMatch;
824
825})(BaseClass));
826
827/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
828
829/***/ }),
830/* 13 */
831/***/ (function(module, exports, __webpack_require__) {
832
833var EmptyNode, EmptyOptionalNode, Node, PatternElement, inspect, isPlainObject, isRegExp, isString, log, ref, ref1,
834 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
835 hasProp = {}.hasOwnProperty;
836
837ref = __webpack_require__(2), Node = ref.Node, EmptyNode = ref.EmptyNode, EmptyOptionalNode = ref.EmptyOptionalNode;
838
839ref1 = __webpack_require__(0), isPlainObject = ref1.isPlainObject, isString = ref1.isString, isRegExp = ref1.isRegExp, inspect = ref1.inspect, log = ref1.log;
840
841module.exports = PatternElement = (function(superClass) {
842 var escapeRegExp;
843
844 extend(PatternElement, superClass);
845
846 PatternElement.escapeRegExp = escapeRegExp = function(str) {
847 return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
848 };
849
850 PatternElement.regExpRegExp = /\/((?:[^\\\/]|\\.)+)\//;
851
852 PatternElement.ruleRegExp = /([a-zA-Z0-9_]+)/;
853
854 PatternElement.singleQuotedStringRegExp = /'((?:[^\\']|\\.)+)'/;
855
856 PatternElement.doubleQuotedStringRegExp = /"((?:[^\\"]|\\.)+)"/;
857
858 PatternElement.labelRegExp = /([a-zA-Z0-9_]+)\:/;
859
860 PatternElement.patternElementRegExp = RegExp("(?:" + PatternElement.labelRegExp.source + ")?([!&])?(?:" + PatternElement.ruleRegExp.source + "|" + PatternElement.regExpRegExp.source + "|" + PatternElement.singleQuotedStringRegExp.source + "|" + PatternElement.doubleQuotedStringRegExp.source + ")([?*+])?");
861
862 PatternElement.allPatternElementsRegExp = RegExp("" + PatternElement.patternElementRegExp.source, "g");
863
864 function PatternElement(pattern1, arg) {
865 this.pattern = pattern1;
866 this.ruleVariant = (arg != null ? arg : {}).ruleVariant;
867 PatternElement.__super__.constructor.apply(this, arguments);
868 this.parse = null;
869 this._init();
870 }
871
872 PatternElement.prototype.toString = function() {
873 return "PatternElement(" + this.pattern + ")";
874 };
875
876 PatternElement.getter("isTokenPattern");
877
878 PatternElement.property({
879 label: null,
880 optional: false,
881 negative: false,
882 couldMatch: false,
883 zeroOrMore: false,
884 oneOrMore: false,
885 pattern: null,
886 ruleName: null
887 });
888
889 PatternElement.getter({
890 isBasicRulePattern: function() {
891 return this.ruleName && !this.optional && !this.negative && !this.zeroOrMore && !this.oneOrMore && !this.couldMatch;
892 },
893 inspectedObjects: function() {
894 return {
895 PatternElement: this.props
896 };
897 },
898 props: function() {
899 var props;
900 props = {
901 pattern: this.pattern
902 };
903 if (this.ruleName) {
904 props.ruleName = this.ruleName;
905 }
906 if (this.negative) {
907 props.negative = true;
908 }
909 if (this.zeroOrMore) {
910 props.zeroOrMore = true;
911 }
912 if (this.oneOrMore) {
913 props.oneOrMore = true;
914 }
915 if (this.couldMatch) {
916 props.couldMatch = true;
917 }
918 return props;
919 }
920 });
921
922 PatternElement.prototype.parse = function(parentNode) {
923 throw new Error("should be overridden");
924 };
925
926 PatternElement.prototype.parseInto = function(parentNode) {
927 return !!parentNode.addMatch(this, this.parse(parentNode));
928 };
929
930 PatternElement.prototype._applyParseFlags = function() {
931 var singleParser;
932 singleParser = this.parse;
933 if (this._optional) {
934 this.parse = function(parentNode) {
935 var match;
936 if (match = singleParser(parentNode)) {
937 return match;
938 } else {
939 return new EmptyOptionalNode(parentNode);
940 }
941 };
942 }
943 if (this._negative) {
944 this.parse = function(parentNode) {
945 return parentNode.parser._matchNegative(function() {
946 var match;
947 if (match = singleParser(parentNode)) {
948 return null;
949 } else {
950 return new EmptyNode(parentNode);
951 }
952 });
953 };
954 }
955 if (this.couldMatch) {
956 this.parse = function(parentNode) {
957 if (singleParser(parentNode)) {
958 return new EmptyNode(parentNode);
959 }
960 };
961 }
962 if (this._zeroOrMore) {
963 this.parseInto = (function(_this) {
964 return function(parentNode) {
965 var m, matchCount;
966 matchCount = 0;
967 while (parentNode.addMatch(_this, m = singleParser(parentNode))) {
968 matchCount++;
969 if (m.matchLength === 0) {
970 break;
971 }
972 }
973 return true;
974 };
975 })(this);
976 }
977 if (this._oneOrMore) {
978 return this.parseInto = (function(_this) {
979 return function(parentNode) {
980 var m, matchCount;
981 matchCount = 0;
982 while (parentNode.addMatch(_this, m = singleParser(parentNode))) {
983 matchCount++;
984 if (m.matchLength === 0) {
985 break;
986 }
987 }
988 return matchCount > 0;
989 };
990 })(this);
991 }
992 };
993
994 PatternElement.prototype._init = function() {
995 var __, doubleQuotedString, pattern, prefix, ref2, regExp, res, singleQuotedString, string, suffix;
996 this.parse = this.label = this.ruleName = null;
997 this.negative = this.couldMatch = this.oneOrMore = this.optional = this.zeroOrMore = false;
998 this._isTokenPattern = false;
999 pattern = this.pattern;
1000 if (isPlainObject(pattern)) {
1001 this._initPlainObject(pattern);
1002 } else if (isString(pattern)) {
1003 ref2 = res = pattern.match(PatternElement.patternElementRegExp), __ = ref2[0], this.label = ref2[1], prefix = ref2[2], this.ruleName = ref2[3], regExp = ref2[4], singleQuotedString = ref2[5], doubleQuotedString = ref2[6], suffix = ref2[7];
1004 if (prefix && suffix) {
1005 throw new Error("pattern can only have one prefix: !/& or one suffix: ?/+/*");
1006 }
1007 switch (prefix) {
1008 case "!":
1009 this.negative = true;
1010 break;
1011 case "&":
1012 this.couldMatch = true;
1013 }
1014 switch (suffix) {
1015 case "?":
1016 this.optional = true;
1017 break;
1018 case "+":
1019 this.oneOrMore = true;
1020 break;
1021 case "*":
1022 this.zeroOrMore = true;
1023 }
1024 string = singleQuotedString || doubleQuotedString;
1025 if (this.ruleName) {
1026 this._initRule(this.ruleName);
1027 } else if (regExp) {
1028 this._initRegExp(new RegExp(regExp));
1029 } else if (string) {
1030 this._initRegExp(new RegExp(escapeRegExp(string)));
1031 } else {
1032 throw new Error("invalid pattern: " + pattern);
1033 }
1034 } else if (isRegExp(pattern)) {
1035 this._initRegExp(pattern);
1036 } else {
1037 throw new Error("invalid pattern type: " + (inspect(pattern)));
1038 }
1039 return this._applyParseFlags();
1040 };
1041
1042 PatternElement.prototype._initPlainObject = function(object) {
1043 var parseInto;
1044 this.negative = object.negative, this.oneOrMore = object.oneOrMore, this.zeroOrMore = object.zeroOrMore, this.optional = object.optional, this.parse = object.parse, parseInto = object.parseInto;
1045 if (parseInto) {
1046 this.parseInto = parseInto;
1047 }
1048 if (!(this.parse || parseInto)) {
1049 throw new Error("plain-object pattern definition requires 'parse' or 'parseInto'");
1050 }
1051 };
1052
1053 PatternElement.prototype._initRule = function(ruleName) {
1054 var matchRule;
1055 matchRule = null;
1056 return this.parse = function(parentNode) {
1057 matchRule || (matchRule = parentNode.parser.getRule(ruleName));
1058 return matchRule.parse(parentNode);
1059 };
1060 };
1061
1062
1063 /*
1064 NOTE: regExp.test is 3x faster than .exec in Safari, but about the
1065 same in node/chrome. Safari is 2.5x faster than Chrome/Node in this.
1066
1067 Regexp must have the global flag set, even if we are using the y-flag,
1068 to make .test() set .lastIndex correctly.
1069
1070 SEE: https://jsperf.com/regex-match-length
1071 */
1072
1073 PatternElement.prototype._initRegExp = function(regExp) {
1074 var flags;
1075 this._isTokenPattern = true;
1076 flags = "yg";
1077 if (regExp.ignoreCase) {
1078 flags += "i";
1079 }
1080 regExp = RegExp(regExp.source, flags);
1081 return this.parse = function(parentNode) {
1082 var nextOffset, source;
1083 nextOffset = parentNode.nextOffset, source = parentNode.source;
1084 regExp.lastIndex = nextOffset;
1085 if (regExp.test(source)) {
1086 return new Node(parentNode, {
1087 offset: nextOffset,
1088 matchLength: regExp.lastIndex - nextOffset
1089 });
1090 }
1091 };
1092 };
1093
1094 return PatternElement;
1095
1096})(__webpack_require__(1).BaseClass);
1097
1098
1099/***/ }),
1100/* 14 */
1101/***/ (function(module, exports, __webpack_require__) {
1102
1103var Rule, RuleVariant, Stats, log, merge, objectName, ref, upperCamelCase,
1104 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1105 hasProp = {}.hasOwnProperty;
1106
1107RuleVariant = __webpack_require__(15);
1108
1109Stats = __webpack_require__(3);
1110
1111ref = __webpack_require__(0), merge = ref.merge, upperCamelCase = ref.upperCamelCase, objectName = ref.objectName, log = ref.log;
1112
1113module.exports = Rule = (function(superClass) {
1114 extend(Rule, superClass);
1115
1116 function Rule(_name, _parserClass, _variants) {
1117 this._name = _name;
1118 this._parserClass = _parserClass;
1119 this._variants = _variants != null ? _variants : [];
1120 }
1121
1122 Rule.getter("nodeClassName name variantNodeClasses", {
1123 numVariants: function() {
1124 return this._variants.length;
1125 }
1126 });
1127
1128 Rule.prototype.addVariant = function(options) {
1129 var v;
1130 this._variants.push(v = new RuleVariant(merge(options, {
1131 variantNumber: this._variants.length + 1,
1132 rule: this,
1133 parserClass: this._parserClass
1134 })));
1135 return v;
1136 };
1137
1138 Rule.getter({
1139 inspectObjects: function() {
1140 return [
1141 {
1142 inspect: (function(_this) {
1143 return function() {
1144 return "<Rule: " + _this._name + ">";
1145 };
1146 })(this)
1147 }, this._variants
1148 ];
1149 }
1150 });
1151
1152 Rule.prototype.clone = function() {
1153 return new Rule(this._name, this._parserClass, this._variants.slice());
1154 };
1155
1156
1157 /*
1158 IN:
1159 parentNode: node instance
1160 This provides critical info:
1161 parentNode.source: the source string
1162 parentNode.nextOffset: the index in the source where parsing starts
1163 parentNode.parser: access to the parser object
1164
1165 EFFECT: If returning a new Node, it is expected that node's parent is already set to parentNode
1166 OUT: Node instance if parsing was successful
1167 */
1168
1169 Rule.prototype.parse = function(parentNode) {
1170 var cached, i, len, match, nextOffset, parser, ref1, v;
1171 Stats.add("parseRule");
1172 parser = parentNode.parser, nextOffset = parentNode.nextOffset;
1173 if (cached = parser._cached(this.name, nextOffset)) {
1174 if (cached === "no_match") {
1175 Stats.add("cacheHitNoMatch");
1176 return null;
1177 } else {
1178 Stats.add("cacheHit");
1179 return cached;
1180 }
1181 }
1182 ref1 = this._variants;
1183 for (i = 0, len = ref1.length; i < len; i++) {
1184 v = ref1[i];
1185 if (match = v.parse(parentNode)) {
1186 return parser._cacheMatch(this.name, match);
1187 }
1188 }
1189 return parser._cacheNoMatch(this.name, nextOffset);
1190 };
1191
1192 return Rule;
1193
1194})(__webpack_require__(1).BaseClass);
1195
1196
1197/***/ }),
1198/* 15 */
1199/***/ (function(module, exports, __webpack_require__) {
1200
1201var BaseClass, Node, PatternElement, RuleVariant, ScratchNode, Stats, allPatternElementsRegExp, compactFlatten, inspect, isPlainObject, isString, log, merge, pad, push, ref, ref1, toInspectedObjects, upperCamelCase,
1202 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1203 hasProp = {}.hasOwnProperty;
1204
1205PatternElement = __webpack_require__(13);
1206
1207Stats = __webpack_require__(3);
1208
1209ref = __webpack_require__(2), Node = ref.Node, ScratchNode = ref.ScratchNode;
1210
1211ref1 = __webpack_require__(0), log = ref1.log, toInspectedObjects = ref1.toInspectedObjects, isPlainObject = ref1.isPlainObject, push = ref1.push, isString = ref1.isString, compactFlatten = ref1.compactFlatten, inspect = ref1.inspect, pad = ref1.pad, upperCamelCase = ref1.upperCamelCase, merge = ref1.merge;
1212
1213allPatternElementsRegExp = PatternElement.allPatternElementsRegExp;
1214
1215BaseClass = __webpack_require__(1).BaseClass;
1216
1217module.exports = RuleVariant = (function(superClass) {
1218 extend(RuleVariant, superClass);
1219
1220 function RuleVariant(options1) {
1221 var ref2;
1222 this.options = options1;
1223 this._toString = null;
1224 if (!isPlainObject(this.options)) {
1225 this.options = {
1226 pattern: this.options
1227 };
1228 }
1229 ref2 = this.options, this.pattern = ref2.pattern, this.rule = ref2.rule, this.parserClass = ref2.parserClass;
1230 this._variantNodeClassName = this.options.variantNodeClassName;
1231 this._initVariantNodeClass(this.options);
1232 if (this.options.parse) {
1233 this.parse = this.options.parse;
1234 }
1235 }
1236
1237 RuleVariant.property({
1238 passThroughRuleName: null
1239 });
1240
1241 RuleVariant.setter("variantNodeClassName");
1242
1243 RuleVariant.getter({
1244 isPassThrough: function() {
1245 return this._passThroughRuleName;
1246 },
1247 name: function() {
1248 return this.variantNodeClassName + "Variant";
1249 },
1250 numVariants: function() {
1251 return this.rule.numVariants;
1252 },
1253 patternElements: function() {
1254 return this._patternElements || (this._patternElements = this._generatePatternElements());
1255 }
1256 });
1257
1258 RuleVariant.prototype._generatePatternElements = function() {
1259 var part, parts, pes;
1260 pes = (function() {
1261 var i, len, results;
1262 if (isString(this.pattern)) {
1263 parts = this.pattern.match(allPatternElementsRegExp);
1264 if (!parts) {
1265 throw new Error("no pattern-parts found in: " + (inspect(this.pattern)));
1266 }
1267 results = [];
1268 for (i = 0, len = parts.length; i < len; i++) {
1269 part = parts[i];
1270 results.push(new PatternElement(part, {
1271 ruleVariant: this
1272 }));
1273 }
1274 return results;
1275 } else {
1276 return [
1277 new PatternElement(this.pattern, {
1278 ruleVariant: this
1279 })
1280 ];
1281 }
1282 }).call(this);
1283 pes = compactFlatten(pes);
1284 if (pes.length === 1 && pes[0].isBasicRulePattern) {
1285 this.passThroughRuleName = pes[0].ruleName;
1286 }
1287 return pes;
1288 };
1289
1290 RuleVariant.prototype.inspect = function() {
1291 return this.toString();
1292 };
1293
1294 RuleVariant.prototype.toString = function() {
1295 return this._toString || (this._toString = this.name + ": " + this.patternString);
1296 };
1297
1298 RuleVariant.getter({
1299 patternString: function() {
1300 return this.pattern || (this.options.parse && 'function()');
1301 }
1302 });
1303
1304
1305 /*
1306 see: BabelBridge.Rule#parse
1307 */
1308
1309 RuleVariant.prototype.parse = function(parentNode) {
1310 var i, len, parser, patternElement, ref2, scratchNode;
1311 Stats.add("parseVariant");
1312 scratchNode = ScratchNode.checkout(parentNode, this);
1313 parser = parentNode.parser;
1314 ref2 = this.patternElements;
1315 for (i = 0, len = ref2.length; i < len; i++) {
1316 patternElement = ref2[i];
1317 if (!parser.tryPatternElement(patternElement, scratchNode, this)) {
1318 scratchNode.checkin();
1319 return false;
1320 }
1321 }
1322 scratchNode.checkin();
1323 return scratchNode.getRealNode();
1324 };
1325
1326 RuleVariant.getter({
1327 variantNodeClassName: function() {
1328 var baseName, ref2;
1329 if (this._variantNodeClassName) {
1330 return this._variantNodeClassName;
1331 }
1332 baseName = upperCamelCase(this.rule.name) + "Rule" + (this.pattern ? upperCamelCase(((ref2 = ("" + this.pattern).match(/[a-zA-Z0-9_]+/g)) != null ? ref2.join('_') : void 0) || "") : this.parse ? "CustomParser" : void 0);
1333 return this._variantNodeClassName = baseName;
1334 }
1335 });
1336
1337
1338 /*
1339 OPTIONS:
1340
1341 node / nodeClass
1342 TODO: pick one, I like 'node' today
1343
1344 extends / baseClass / nodeBaseClass
1345 TODO: pick one, I like 'extends' today
1346 */
1347
1348 RuleVariant.prototype._initVariantNodeClass = function(options) {
1349 var nodeBaseClass, nodeSubclassOptions, rule;
1350 rule = options.rule;
1351 nodeSubclassOptions = options.node || options.nodeClass || options;
1352 nodeBaseClass = options["extends"] || options.baseClass || options.nodeBaseClass || Node;
1353 return this.VariantNodeClass = (typeof nodeClass !== "undefined" && nodeClass !== null ? nodeClass.prototype : void 0) instanceof Node ? nodeClass : nodeBaseClass.createSubclass(merge({
1354 name: this.variantNodeClassName,
1355 ruleVarient: this.ruleVarient
1356 }, nodeSubclassOptions));
1357 };
1358
1359 return RuleVariant;
1360
1361})(BaseClass);
1362
1363
1364/***/ }),
1365/* 16 */
1366/***/ (function(module, exports, __webpack_require__) {
1367
1368var Tools, peek;
1369
1370peek = __webpack_require__(0).peek;
1371
1372module.exports = Tools = (function() {
1373 var getLineColumn;
1374
1375 function Tools() {}
1376
1377 Tools.getLineColumn = getLineColumn = function(string, offset) {
1378 var lines;
1379 if (string.length === 0 || offset === 0) {
1380 return {
1381 line: 1,
1382 column: 1
1383 };
1384 }
1385 lines = (string.slice(0, offset)).split("\n");
1386 return {
1387 line: lines.length,
1388 column: peek(lines).length + 1
1389 };
1390 };
1391
1392 Tools.getLineColumnString = function(string, offset) {
1393 var column, line, ref;
1394 ref = getLineColumn(string, offset), line = ref.line, column = ref.column;
1395 return line + ":" + column;
1396 };
1397
1398 return Tools;
1399
1400})();
1401
1402
1403/***/ }),
1404/* 17 */
1405/***/ (function(module, exports, __webpack_require__) {
1406
1407module.exports = __webpack_require__(7);
1408
1409module.exports.includeInNamespace(__webpack_require__(18)).addModules({
1410 BabelBridgeCompileError: __webpack_require__(8),
1411 NonMatch: __webpack_require__(12),
1412 Parser: __webpack_require__(23),
1413 PatternElement: __webpack_require__(13),
1414 Repl: __webpack_require__(6),
1415 Rule: __webpack_require__(14),
1416 RuleVariant: __webpack_require__(15),
1417 Stats: __webpack_require__(3),
1418 Tools: __webpack_require__(16)
1419});
1420
1421__webpack_require__(20);
1422
1423__webpack_require__(2);
1424
1425
1426/***/ }),
1427/* 18 */
1428/***/ (function(module, exports, __webpack_require__) {
1429
1430var isClass, log, ref;
1431
1432ref = __webpack_require__(0), isClass = ref.isClass, log = ref.log;
1433
1434module.exports = __webpack_require__(6);
1435
1436
1437/***/ }),
1438/* 19 */
1439/***/ (function(module, exports, __webpack_require__) {
1440
1441/* WEBPACK VAR INJECTION */(function(module) {var Node, array, defineModule, escapeJavascriptString, find, log, merge, ref;
1442
1443ref = __webpack_require__(0), array = ref.array, defineModule = ref.defineModule, log = ref.log, merge = ref.merge, escapeJavascriptString = ref.escapeJavascriptString, find = ref.find;
1444
1445Node = __webpack_require__(2).Node;
1446
1447defineModule(module, function() {
1448 var IndentBlocks;
1449 return IndentBlocks = (function() {
1450 var blockLinesRegExp, blockStartRegExp, computeSubsourceToParentSourceMap, matchBlock, matchToEolAndBlock, toEolContent;
1451
1452 function IndentBlocks() {}
1453
1454 blockStartRegExp = /\n(?: *\n)*( +)(?=$|[^ \n])/y;
1455
1456 toEolContent = /(\ *)((?:\ *[^ \n]+)+)\ */y;
1457
1458 blockLinesRegExp = function(indent) {
1459 return RegExp("((?:\\s*\\n)(?:" + indent + " *[^\\n ][^\\n]*))+", "y");
1460 };
1461
1462
1463 /*
1464 TODO:
1465 for matchBlock and matchToEolAndBlock
1466
1467 We also need a source-offset mapper from the new source back to the old-source.
1468
1469 I think the map should just be part of the returned object
1470 */
1471
1472 IndentBlocks.matchBlock = matchBlock = function(source, sourceOffset, returnRawMatch) {
1473 var __, indent, length, linesRegExp, match, rawSubsource, replaceRegExp, replaceWith, subsource, subsourceToParentSourceMap;
1474 if (returnRawMatch == null) {
1475 returnRawMatch = false;
1476 }
1477 blockStartRegExp.lastIndex = sourceOffset;
1478 if (match = blockStartRegExp.exec(source)) {
1479 __ = match[0], indent = match[1];
1480 length = indent.length;
1481 linesRegExp = blockLinesRegExp(indent);
1482 linesRegExp.lastIndex = sourceOffset;
1483 rawSubsource = linesRegExp.exec(source)[0];
1484 replaceRegExp = RegExp("(?:^\\n" + indent + ")|(\\n)(?:" + indent + ")", "g");
1485 replaceWith = "$1";
1486 subsourceToParentSourceMap = null;
1487 subsource = returnRawMatch ? rawSubsource : rawSubsource.replace(replaceRegExp, "$1");
1488 return {
1489 matchLength: rawSubsource.length,
1490 subsource: subsource,
1491 sourceMap: returnRawMatch ? function(suboffset) {
1492 return suboffset + sourceOffset;
1493 } : function(suboffset) {
1494 var bestMapEntry;
1495 subsourceToParentSourceMap || (subsourceToParentSourceMap = computeSubsourceToParentSourceMap(sourceOffset, replaceRegExp, indent, rawSubsource));
1496 bestMapEntry = find(subsourceToParentSourceMap, function(entry) {
1497 if (suboffset < entry.subsourceEndOffset) {
1498 return entry;
1499 }
1500 });
1501 return suboffset + bestMapEntry.toSourceDelta;
1502 }
1503 };
1504 }
1505 };
1506
1507 computeSubsourceToParentSourceMap = function(sourceBaseOffset, replaceRegExp, indent, rawSubsource) {
1508 var indentLength, indentWithNewLineLength, indexes, keptLength, match, matchLength, ref1, removedLength, sourceEndOffset, sourceOffset, subsourceEndOffset, subsourceOffset, toSourceDelta;
1509 indentLength = indent.length;
1510 indentWithNewLineLength = indentLength + 1;
1511 indexes = [];
1512 sourceOffset = toSourceDelta = sourceBaseOffset;
1513 subsourceOffset = subsourceEndOffset = 0;
1514 while (match = replaceRegExp.exec(rawSubsource)) {
1515 matchLength = match[0].length;
1516 keptLength = ((ref1 = match[1]) != null ? ref1.length : void 0) || 0;
1517 removedLength = matchLength - keptLength;
1518 sourceEndOffset = match.index + sourceBaseOffset + matchLength;
1519 subsourceEndOffset += sourceEndOffset - sourceOffset - removedLength;
1520 indexes.push({
1521 keptLength: keptLength,
1522 removedLength: removedLength,
1523 sourceOffset: sourceOffset,
1524 subsourceOffset: subsourceOffset,
1525 toSourceDelta: toSourceDelta,
1526 sourceEndOffset: sourceEndOffset,
1527 subsourceEndOffset: subsourceEndOffset
1528 });
1529 toSourceDelta += removedLength;
1530 sourceOffset = sourceEndOffset;
1531 subsourceOffset = subsourceEndOffset;
1532 }
1533 sourceEndOffset = sourceBaseOffset + rawSubsource.length;
1534 subsourceEndOffset = sourceEndOffset - sourceOffset + sourceOffset;
1535 indexes.push({
1536 sourceOffset: sourceOffset,
1537 subsourceOffset: subsourceOffset,
1538 toSourceDelta: toSourceDelta,
1539 sourceEndOffset: sourceEndOffset,
1540 subsourceEndOffset: subsourceEndOffset
1541 });
1542 return indexes;
1543 };
1544
1545 IndentBlocks.matchToEolAndBlock = matchToEolAndBlock = function(source, offset) {
1546 var blockMatch, eolMatch, matchLength, sourceMatched, spaces;
1547 toEolContent.lastIndex = offset;
1548 if (eolMatch = toEolContent.exec(source)) {
1549 sourceMatched = eolMatch[0], spaces = eolMatch[1];
1550 matchLength = sourceMatched.length;
1551 if (blockMatch = matchBlock(source, offset + matchLength, true)) {
1552 matchLength += blockMatch.matchLength;
1553 }
1554 return {
1555 subsource: source.slice(offset + spaces.length, offset + matchLength),
1556 sourceMap: function(suboffset) {
1557 return offset + spaces.length + suboffset;
1558 },
1559 matchLength: matchLength
1560 };
1561 } else {
1562 return matchBlock(source, offset);
1563 }
1564 };
1565
1566 IndentBlocks.getParseFunction = function(matcher, subparseOptions) {
1567 return {
1568 parse: function(parentNode) {
1569 var block, matchLength, offset, source, sourceMap, subsource;
1570 offset = parentNode.nextOffset, source = parentNode.source;
1571 if (block = matcher(source, offset)) {
1572 subsource = block.subsource, matchLength = block.matchLength, sourceMap = block.sourceMap;
1573 return parentNode.subparse(subsource, merge(subparseOptions, {
1574 originalOffset: offset,
1575 originalMatchLength: matchLength,
1576 sourceMap: sourceMap
1577 }));
1578 }
1579 }
1580 };
1581 };
1582
1583 IndentBlocks.getPropsToSubparseBlock = function(subparseOptions) {
1584 if (subparseOptions == null) {
1585 subparseOptions = {};
1586 }
1587 return IndentBlocks.getParseFunction(IndentBlocks.matchBlock, subparseOptions);
1588 };
1589
1590 IndentBlocks.getPropsToSubparseToEolAndBlock = function(subparseOptions) {
1591 if (subparseOptions == null) {
1592 subparseOptions = {};
1593 }
1594 return IndentBlocks.getParseFunction(IndentBlocks.matchToEolAndBlock, subparseOptions);
1595 };
1596
1597 return IndentBlocks;
1598
1599 })();
1600});
1601
1602/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
1603
1604/***/ }),
1605/* 20 */
1606/***/ (function(module, exports, __webpack_require__) {
1607
1608module.exports = __webpack_require__(9);
1609
1610module.exports.addModules({
1611 IndentBlocks: __webpack_require__(19)
1612});
1613
1614
1615/***/ }),
1616/* 21 */
1617/***/ (function(module, exports, __webpack_require__) {
1618
1619var EmptyOptionalNode,
1620 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1621 hasProp = {}.hasOwnProperty;
1622
1623module.exports = EmptyOptionalNode = (function(superClass) {
1624 extend(EmptyOptionalNode, superClass);
1625
1626 function EmptyOptionalNode() {
1627 return EmptyOptionalNode.__super__.constructor.apply(this, arguments);
1628 }
1629
1630 EmptyOptionalNode.getter({
1631 present: function() {
1632 return false;
1633 }
1634 });
1635
1636 return EmptyOptionalNode;
1637
1638})(__webpack_require__(10));
1639
1640
1641/***/ }),
1642/* 22 */
1643/***/ (function(module, exports, __webpack_require__) {
1644
1645/* WEBPACK VAR INJECTION */(function(module) {var BaseClass, ScratchNode, compactFlatten, defineModule, inspect, isPlainObject, isString, log, merge, pad, push, ref, toInspectedObjects, upperCamelCase,
1646 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1647 hasProp = {}.hasOwnProperty;
1648
1649ref = __webpack_require__(0), log = ref.log, defineModule = ref.defineModule, toInspectedObjects = ref.toInspectedObjects, isPlainObject = ref.isPlainObject, push = ref.push, isString = ref.isString, compactFlatten = ref.compactFlatten, inspect = ref.inspect, pad = ref.pad, upperCamelCase = ref.upperCamelCase, merge = ref.merge;
1650
1651BaseClass = __webpack_require__(1).BaseClass;
1652
1653defineModule(module, ScratchNode = (function(superClass) {
1654 extend(ScratchNode, superClass);
1655
1656 ScratchNode._scatchNodes = [];
1657
1658 ScratchNode._scatchNodesInUse = 0;
1659
1660 ScratchNode.checkout = function(parentNode, ruleVariant) {
1661 if (this._scatchNodesInUse >= this._scatchNodes.length) {
1662 return this._scatchNodes[this._scatchNodesInUse++] = new ScratchNode(parentNode, ruleVariant);
1663 } else {
1664 return this._scatchNodes[this._scatchNodesInUse++].reset(parentNode, ruleVariant);
1665 }
1666 };
1667
1668 ScratchNode.checkin = function(scratchNode) {
1669 if (scratchNode !== this._scatchNodes[--this._scatchNodesInUse]) {
1670 throw new Error("WTF");
1671 }
1672 };
1673
1674 function ScratchNode(parent, ruleVariant) {
1675 this.matches = [];
1676 this.matchPatterns = [];
1677 this.reset(parent, ruleVariant);
1678 }
1679
1680 ScratchNode.prototype.reset = function(parent1, ruleVariant1) {
1681 this.parent = parent1;
1682 this.ruleVariant = ruleVariant1;
1683 this._parser = this.parent._parser;
1684 this.offset = this.parent.getNextOffset() | 0;
1685 this.matchesLength = this.matchPatternsLength = this.matchLength = 0;
1686 this.variantNode = null;
1687 return this;
1688 };
1689
1690 ScratchNode.getter("parser", {
1691 source: function() {
1692 return this._parser.source;
1693 },
1694 nextOffset: function() {
1695 return this.offset + this.matchLength;
1696 },
1697 inspectedObjects: function() {
1698 return {
1699 offset: this.offset,
1700 matchLength: this.matchLength,
1701 matches: toInspectedObjects(this.matches),
1702 matchPatterns: toInspectedObjects(this.matchPatterns)
1703 };
1704 }
1705 });
1706
1707 ScratchNode.prototype.getNextText = function(length) {
1708 var nextOffset;
1709 nextOffset = this.getNextOffset();
1710 return this.source.slice(nextOffset, nextOffset + length);
1711 };
1712
1713 ScratchNode.getter({
1714 firstPartialMatchParent: function() {
1715 return this.realNode.firstPartialMatchParent;
1716 },
1717 realNode: function() {
1718 return this.variantNode || (this.variantNode = new this.ruleVariant.VariantNodeClass(this.parent.realNode || this._parser, {
1719 ruleVariant: this.ruleVariant,
1720 matchLength: this.matchLength,
1721 matches: this.matchesLength > 0 && this.matches.slice(0, this.matchesLength),
1722 matchPatterns: this.matchPatternsLength > 0 && this.matchPatterns.slice(0, this.matchPatternsLength)
1723 }));
1724 }
1725 });
1726
1727 ScratchNode.prototype.checkin = function() {
1728 return ScratchNode.checkin(this);
1729 };
1730
1731 ScratchNode.prototype.subparse = function(subSource, options) {
1732 return this._parser.subparse(subSource, merge(options, {
1733 parentNode: this
1734 }));
1735 };
1736
1737 ScratchNode.prototype.addMatch = function(pattern, match) {
1738 var ref1;
1739 if (!match) {
1740 return false;
1741 }
1742 if ((ref1 = this.variantNode) != null) {
1743 ref1.addMatch(pattern, match);
1744 }
1745 this.matches[this.matchesLength++] = match;
1746 this.matchPatterns[this.matchPatternsLength++] = pattern;
1747 this.matchLength = match.nextOffset - this.offset;
1748 return true;
1749 };
1750
1751 ScratchNode.prototype._addToParentAsNonMatch = function() {
1752 return this.realNode._addToParentAsNonMatch();
1753 };
1754
1755 return ScratchNode;
1756
1757})(BaseClass));
1758
1759/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)(module)))
1760
1761/***/ }),
1762/* 23 */
1763/***/ (function(module, exports, __webpack_require__) {
1764
1765var BabelBridgeCompileError, Node, NonMatch, Parser, Rule, Stats, compactFlatten, formattedInspect, getLineColumn, getLineColumnString, inspect, inspectLean, isClass, isFunction, isPlainArray, isPlainObject, log, max, merge, mergeInto, objectHasKeys, objectLength, objectWithout, peek, pluralize, pushIfNotPresent, ref, ref1, uniqueValues, upperCamelCase,
1766 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1767 hasProp = {}.hasOwnProperty,
1768 slice = [].slice;
1769
1770Rule = __webpack_require__(14);
1771
1772ref = __webpack_require__(16), getLineColumn = ref.getLineColumn, getLineColumnString = ref.getLineColumnString;
1773
1774Node = __webpack_require__(2).Node;
1775
1776NonMatch = __webpack_require__(12);
1777
1778Stats = __webpack_require__(3);
1779
1780ref1 = __webpack_require__(0), isFunction = ref1.isFunction, peek = ref1.peek, log = ref1.log, isPlainObject = ref1.isPlainObject, isPlainArray = ref1.isPlainArray, merge = ref1.merge, compactFlatten = ref1.compactFlatten, objectLength = ref1.objectLength, inspect = ref1.inspect, inspectLean = ref1.inspectLean, pluralize = ref1.pluralize, isClass = ref1.isClass, isPlainArray = ref1.isPlainArray, upperCamelCase = ref1.upperCamelCase, mergeInto = ref1.mergeInto, objectWithout = ref1.objectWithout, uniqueValues = ref1.uniqueValues, formattedInspect = ref1.formattedInspect, max = ref1.max, inspect = ref1.inspect, pushIfNotPresent = ref1.pushIfNotPresent, uniqueValues = ref1.uniqueValues, objectHasKeys = ref1.objectHasKeys;
1781
1782BabelBridgeCompileError = __webpack_require__(8);
1783
1784module.exports = Parser = (function(superClass) {
1785 var addToExpectingInfo, firstLines, instanceRulesFunction, lastLines, rulesFunction;
1786
1787 extend(Parser, superClass);
1788
1789 Parser.repl = function() {
1790 return (__webpack_require__(6)).babelBridgeRepl(this);
1791 };
1792
1793 Parser.parse = function(_source, options) {
1794 this._source = _source;
1795 if (options == null) {
1796 options = {};
1797 }
1798 return (new this).parse(this._source, options);
1799 };
1800
1801 Parser.classGetter({
1802 rootRuleName: function() {
1803 return this._rootRuleName || "root";
1804 },
1805 rootRule: function() {
1806 return this.getRules()[this._rootRuleName];
1807 }
1808 });
1809
1810 Parser.extendableProperty({
1811 rules: {}
1812 }, function(extendableRules, newRules) {
1813 var newRule, ruleName;
1814 for (ruleName in a) {
1815 newRule = a[ruleName];
1816 extendableRules[ruleName] = newRule.clone();
1817 }
1818 return newRule;
1819 });
1820
1821 Parser.addRule = function(ruleName, definitions, nodeBaseClass) {
1822 var array, base, commonNodeProps, definition, i, j, last, len, pattern, patterns, ref2, results, rule;
1823 if (nodeBaseClass == null) {
1824 nodeBaseClass = this.getNodeBaseClass();
1825 }
1826 rule = (base = this.extendRules())[ruleName] || (base[ruleName] = new Rule(ruleName, this));
1827 if (definitions.root) {
1828 if (this._rootRuleName) {
1829 throw new Error("root rule already defined! was: " + this._rootRuleName + ", wanted: " + ruleName);
1830 }
1831 this._rootRuleName = ruleName;
1832 }
1833 if (!isPlainArray(array = definitions)) {
1834 definitions = [definitions];
1835 }
1836 if (definitions.length > 1 && isPlainObject(last = peek(definitions)) && !last.pattern) {
1837 ref2 = definitions, definitions = 2 <= ref2.length ? slice.call(ref2, 0, i = ref2.length - 1) : (i = 0, []), commonNodeProps = ref2[i++];
1838 } else {
1839 commonNodeProps = {};
1840 }
1841 commonNodeProps.nodeBaseClass || (commonNodeProps.nodeBaseClass = nodeBaseClass);
1842 results = [];
1843 for (j = 0, len = definitions.length; j < len; j++) {
1844 definition = definitions[j];
1845 if (!isPlainObject(definition)) {
1846 definition = {
1847 pattern: definition
1848 };
1849 }
1850 if (isPlainArray(patterns = definition.pattern)) {
1851 results.push((function() {
1852 var l, len1, results1;
1853 results1 = [];
1854 for (l = 0, len1 = patterns.length; l < len1; l++) {
1855 pattern = patterns[l];
1856 results1.push(rule.addVariant(merge(commonNodeProps, definition, {
1857 pattern: pattern
1858 })));
1859 }
1860 return results1;
1861 })());
1862 } else {
1863 results.push(rule.addVariant(merge(commonNodeProps, definition)));
1864 }
1865 }
1866 return results;
1867 };
1868
1869
1870 /*
1871 IN:
1872 rules: plain object mapping rule-names to definitions
1873 nodeClass: optional, must extend BabelBridge.Node or be a plain object
1874 */
1875
1876 Parser.rule = rulesFunction = function(a, b) {
1877 var definition, results, ruleName, rules, sharedNodeBaseClass;
1878 if (isClass(a)) {
1879 sharedNodeBaseClass = a;
1880 rules = b;
1881 } else {
1882 rules = a;
1883 sharedNodeBaseClass = b;
1884 }
1885 if (isPlainObject(sharedNodeBaseClass)) {
1886 sharedNodeBaseClass = this.getNodeBaseClass().createSubclass(sharedNodeBaseClass);
1887 }
1888 results = [];
1889 for (ruleName in rules) {
1890 definition = rules[ruleName];
1891 results.push(this.addRule(ruleName, definition, sharedNodeBaseClass || this.getNodeBaseClass()));
1892 }
1893 return results;
1894 };
1895
1896 Parser.rules = rulesFunction;
1897
1898 Parser.prototype.rule = instanceRulesFunction = function(a, b) {
1899 return this["class"].rule(a, b);
1900 };
1901
1902 Parser.prototype.rules = instanceRulesFunction;
1903
1904 Parser.getNodeBaseClass = function() {
1905 return this._nodeBaseClass || (this._nodeBaseClass = isPlainObject(this.nodeBaseClass) ? (log({
1906 create: this.getName() + "NodeBaseClass"
1907 }), Node.createSubclass(merge({
1908 name: this.getName() + "NodeBaseClass"
1909 }, this.nodeBaseClass))) : this.nodeBaseClass || Node);
1910 };
1911
1912 Parser.property("subparseInfo options");
1913
1914 Parser.getter("source parser", {
1915 rootRuleName: function() {
1916 return this["class"].getRootRuleName();
1917 },
1918 rootRule: function() {
1919 return this["class"].getRootRule();
1920 },
1921 nextOffset: function() {
1922 return 0;
1923 },
1924 rootParser: function() {
1925 var ref2;
1926 return ((ref2 = this.parentParser) != null ? ref2.rootParser : void 0) || this;
1927 },
1928 ancestors: function(into) {
1929 into.push(this);
1930 return into;
1931 },
1932 parseInfo: function() {
1933 return "Parser";
1934 }
1935 });
1936
1937 function Parser() {
1938 Parser.__super__.constructor.apply(this, arguments);
1939 this._options = null;
1940 this._parser = this;
1941 this._source = null;
1942 this._resetParserTracking();
1943 }
1944
1945 Parser._pluralNames = {};
1946
1947 Parser.pluralize = function(name) {
1948 var base;
1949 return (base = this._pluralNames)[name] || (base[name] = pluralize(name));
1950 };
1951
1952 Parser.prototype.pluralize = function(name) {
1953 return this["class"].pluralize(name);
1954 };
1955
1956
1957 /*
1958 IN:
1959 subsource:
1960 any string what-so-ever
1961 options:
1962 [all of @parse's options plus:]
1963 parentNode: (required)
1964 the resulting Node's parent
1965
1966 originalMatchLength: (required)
1967 matchLength from @source that subsource was generated from.
1968
1969 originalOffset: starting offset in parentParser.source
1970
1971 sourceMap: (subsourceOffset) -> parentSourceOffset
1972
1973 The original source we are sub-parsing from must be:
1974
1975 parentNode.getNextText originalMatchLength
1976
1977 OUT: a Node with offset and matchLength
1978 */
1979
1980 Parser.prototype.subparse = function(subsource, options) {
1981 var failureIndex, k, match, matchLength, nonMatch, offset, originalMatchLength, originalOffset, parentNode, parser, ref2, rootNode, source, sourceMap, subparser;
1982 if (options == null) {
1983 options = {};
1984 }
1985 Stats.add("subparse");
1986 subparser = new this["class"];
1987 originalMatchLength = options.originalMatchLength, parentNode = options.parentNode, sourceMap = options.sourceMap, originalOffset = options.originalOffset;
1988 options.parentParser = this;
1989 if (match = subparser.parse(subsource, merge(options, {
1990 isSubparse: true,
1991 logParsingFailures: this._logParsingFailures
1992 }))) {
1993 offset = match.offset, matchLength = match.matchLength, source = match.source, parser = match.parser;
1994 match.subparseInfo = {
1995 offset: offset,
1996 matchLength: matchLength,
1997 source: source,
1998 parser: parser
1999 };
2000 if (match.matchLength < subsource.length) {
2001 if (match.text !== parentNode.getNextText(match.matchLength)) {
2002 throw new Error("INTERNAL TODO: SubParse was a partial match, but a source-map is required to determine the matchLength in the original source.");
2003 }
2004 originalMatchLength = match.matchLength;
2005 }
2006 match.offset = parentNode.nextOffset;
2007 match.matchLength = originalMatchLength;
2008 match._parent = parentNode;
2009 return match;
2010 } else {
2011 failureIndex = subparser.failureIndexInParentParser;
2012 ref2 = subparser._nonMatches;
2013 for (k in ref2) {
2014 nonMatch = ref2[k];
2015 rootNode = nonMatch.node;
2016 while (rootNode !== parentNode && rootNode.parent instanceof Node) {
2017 rootNode = rootNode.parent;
2018 }
2019 if (rootNode !== parentNode) {
2020 rootNode._parent = parentNode;
2021 }
2022 if (this._logParsingFailures) {
2023 this._addNonMatch(failureIndex, nonMatch);
2024 } else {
2025 this._failureIndex = max(this._failureIndex, failureIndex);
2026 }
2027 }
2028 return null;
2029 }
2030 };
2031
2032 Parser.prototype.offsetInParentParserSource = function(suboffset) {
2033 var originalOffset, ref2, ref3, sourceMap;
2034 ref2 = this.options, sourceMap = ref2.sourceMap, originalOffset = (ref3 = ref2.originalOffset) != null ? ref3 : 0;
2035 if (sourceMap) {
2036 return sourceMap(suboffset);
2037 } else if (this.parentParser) {
2038 return this.options.originalOffset + suboffset;
2039 } else {
2040 return suboffset;
2041 }
2042 };
2043
2044 Parser.prototype.offsetInRootParserSource = function(suboffset) {
2045 if (this.parentParser) {
2046 return this.parentParser.offsetInRootParserSource(this.offsetInParentParserSource(suboffset));
2047 } else {
2048 return suboffset;
2049 }
2050 };
2051
2052 Parser.getter({
2053 failureIndexInParentParser: function() {
2054 return this.offsetInParentParserSource(this._failureIndex);
2055 }
2056 });
2057
2058 Parser.prototype.colorString = function(clr, str) {
2059 if (this.options.color) {
2060 return ("" + str)[clr];
2061 } else {
2062 return str;
2063 }
2064 };
2065
2066
2067 /*
2068 OUT: on success, root Node of the parse tree, else null
2069 options:
2070 allowPartialMatch: true/false
2071 */
2072
2073 Parser.prototype.parse = function(_source, options1) {
2074 var allowPartialMatch, isSubparse, logParsingFailures, ref2, result, rule, startRule;
2075 this._source = _source;
2076 this.options = options1 != null ? options1 : {};
2077 ref2 = this.options, this.parentParser = ref2.parentParser, allowPartialMatch = ref2.allowPartialMatch, rule = ref2.rule, isSubparse = ref2.isSubparse, logParsingFailures = ref2.logParsingFailures;
2078 startRule = this.getRule(rule);
2079 this._resetParserTracking();
2080 this._logParsingFailures = logParsingFailures;
2081 if ((result = startRule.parse(this)) && (result.matchLength === this._source.length || (allowPartialMatch && result.matchLength > 0))) {
2082 if (!isSubparse) {
2083 result.applyLabels();
2084 }
2085 return result;
2086 } else {
2087 if (!isSubparse) {
2088 if (logParsingFailures) {
2089 throw new BabelBridgeCompileError(result ? [this.colorString("gray", (this["class"].name + " only parsed: ") + this.colorString("black", (result.matchLength + " of " + this._source.length + " ") + this.colorString("gray", "characters"))), this.getParseFailureInfo(this.options)].join("\n") : this.getParseFailureInfo(this.options), this.parseFailureInfoObject);
2090 } else {
2091 return this.parse(this._source, merge(this.options, {
2092 logParsingFailures: true
2093 }));
2094 }
2095 }
2096 }
2097 };
2098
2099 Parser.prototype.getRule = function(ruleName) {
2100 var rule;
2101 ruleName || (ruleName = this.rootRuleName);
2102 if (!ruleName) {
2103 throw new Error("No root rule defined.");
2104 }
2105 if (!(rule = this.rules[ruleName])) {
2106 throw new Error("Could not find rule: " + ruleName);
2107 }
2108 return rule;
2109 };
2110
2111 addToExpectingInfo = function(node, into, value) {
2112 var m, name1, p, pm, ref2;
2113 if (node.parent) {
2114 into = addToExpectingInfo(node.parent, into);
2115 }
2116 return into[name1 = node.parseInfo] || (into[name1] = value ? value : (p = {}, ((ref2 = (pm = node.presentMatches)) != null ? ref2.length : void 0) > 0 ? p.matches = (function() {
2117 var i, len, results;
2118 results = [];
2119 for (i = 0, len = pm.length; i < len; i++) {
2120 m = pm[i];
2121 results.push(m.parseInfo);
2122 }
2123 return results;
2124 })() : void 0, p));
2125 };
2126
2127 lastLines = function(string, count) {
2128 var a;
2129 if (count == null) {
2130 count = 5;
2131 }
2132 a = string.split("\n");
2133 return a.slice(max(0, a.length - count), a.length).join("\n");
2134 };
2135
2136 firstLines = function(string, count) {
2137 var a;
2138 if (count == null) {
2139 count = 5;
2140 }
2141 a = string.split("\n");
2142 return a.slice(0, count).join("\n");
2143 };
2144
2145 Parser.getter("nonMatches", {
2146 failureUrl: function() {
2147 return (this.options.sourceFile || '') + ":" + (getLineColumnString(this._source, this._failureIndex));
2148 },
2149 parseFailureInfoObject: function() {
2150 return merge({
2151 sourceFile: this.options.sourceFile,
2152 failureIndex: this._failureIndex,
2153 location: this.failureUrl
2154 }, getLineColumn(this._source, this._failureIndex));
2155 },
2156 parseFailureInfo: function(options) {
2157 var left, out, right, sourceAfter, sourceBefore, verbose;
2158 if (!this._source) {
2159 return;
2160 }
2161 verbose = options != null ? options.verbose : void 0;
2162 sourceBefore = lastLines(left = this._source.slice(0, this._failureIndex));
2163 sourceAfter = firstLines(right = this._source.slice(this._failureIndex));
2164 out = compactFlatten([
2165 "", this.colorString("gray", "Parsing error at " + (this.colorString("red", this.failureUrl))), "", this.colorString("gray", "Source:"), this.colorString("gray", "..."), "" + sourceBefore + (this.colorString("red", "<HERE>")) + (sourceAfter.replace(/[\s\n]+$/, '')), this.colorString("gray", "..."), "", this.getExpectingInfo(options), verbose ? formattedInspect({
2166 "partial-parse-tree": this.partialParseTree
2167 }, options) : void 0, ""
2168 ]);
2169 return out.join("\n");
2170 },
2171 partialParseTreeLeafNodes: function() {
2172 if (this._partialParseTreeNodes) {
2173 return this._partialParseTreeNodes;
2174 }
2175 this.getPartialParseTree();
2176 return this._partialParseTreeNodes;
2177 },
2178 partialParseTree: function() {
2179 var expectingInfoTree, k, n, node, patternElement, rootNode;
2180 if (this._partialParseTree) {
2181 return this._partialParseTree;
2182 }
2183 expectingInfoTree = {};
2184 this._partialParseTreeNodes = (function() {
2185 var ref2, ref3, results;
2186 ref2 = this._nonMatches;
2187 results = [];
2188 for (k in ref2) {
2189 ref3 = ref2[k], patternElement = ref3.patternElement, node = ref3.node;
2190 addToExpectingInfo(node, expectingInfoTree, patternElement.pattern.toString());
2191 n = new Node(node);
2192 n.pattern = patternElement;
2193 rootNode = n._addToParentAsNonMatch();
2194 results.push(n);
2195 }
2196 return results;
2197 }).call(this);
2198 return this._partialParseTree = rootNode;
2199 },
2200 expectingInfo: function(options) {
2201 var child, couldMatchRuleNames, expecting, firstPartialMatchParent, i, j, l, len, len1, len2, node, out, partialMatchingParents, pmp, ref2, ref3, ruleName, v;
2202 if (!(objectLength(this._nonMatches) > 0)) {
2203 return null;
2204 }
2205
2206 /*
2207 I know how to do this right!
2208
2209 1) I want to add all the non-match nodes to the parse-tree
2210 2) I want to further improve the parse-tree inspect
2211 - it may be time to do a custom inspect
2212 */
2213 partialMatchingParents = [];
2214 ref2 = this.partialParseTreeLeafNodes;
2215 for (i = 0, len = ref2.length; i < len; i++) {
2216 node = ref2[i];
2217 firstPartialMatchParent = node.firstPartialMatchParent;
2218 pushIfNotPresent(partialMatchingParents, firstPartialMatchParent);
2219 }
2220 couldMatchRuleNames = [];
2221 expecting = {};
2222 for (j = 0, len1 = partialMatchingParents.length; j < len1; j++) {
2223 pmp = partialMatchingParents[j];
2224 ref3 = pmp.matches;
2225 for (l = 0, len2 = ref3.length; l < len2; l++) {
2226 child = ref3[l];
2227 if (!(child.isNonMatch && child.nonMatchingLeaf)) {
2228 continue;
2229 }
2230 if (ruleName = child.nonMatchingLeaf.ruleNameOrNull) {
2231 couldMatchRuleNames.push(ruleName);
2232 }
2233 expecting[child.nonMatchingLeaf.ruleNameOrPattern] = {
2234 "to-continue": pmp.ruleName,
2235 "started-at": getLineColumnString(this._source, pmp.absoluteOffset)
2236 };
2237 }
2238 }
2239 expecting = (function() {
2240 var len3, len4, o, q, ref4;
2241 if (objectHasKeys(expecting)) {
2242 out = {
2243 expecting: expecting
2244 };
2245 if (couldMatchRuleNames.length > 1) {
2246 out.rules = {};
2247 for (o = 0, len3 = couldMatchRuleNames.length; o < len3; o++) {
2248 ruleName = couldMatchRuleNames[o];
2249 ref4 = this.rules[ruleName]._variants;
2250 for (q = 0, len4 = ref4.length; q < len4; q++) {
2251 v = ref4[q];
2252 out.rules[ruleName] = v.patternString;
2253 }
2254 }
2255 }
2256 return out;
2257 } else {
2258 return {
2259 expecting: "end of input"
2260 };
2261 }
2262 }).call(this);
2263 return formattedInspect(expecting, options);
2264 }
2265 });
2266
2267 Parser.prototype.tryPatternElement = function(patternElement, parseIntoNode, ruleVariant) {
2268 Stats.add("tryPatternElement");
2269 if (patternElement.parseInto(parseIntoNode)) {
2270 return true;
2271 } else {
2272 this._logParsingFailure(parseIntoNode, patternElement);
2273 return false;
2274 }
2275 };
2276
2277 Parser.prototype._getRuleParseCache = function(ruleName) {
2278 var base;
2279 return (base = this._parseCache)[ruleName] || (base[ruleName] = {});
2280 };
2281
2282 Parser.prototype._cached = function(ruleName, offset) {
2283 return this._getRuleParseCache(ruleName)[offset];
2284 };
2285
2286 Parser.prototype._cacheMatch = function(ruleName, matchingNode) {
2287 Stats.add("cacheMatch");
2288 this._getRuleParseCache(ruleName)[matchingNode.offset] = matchingNode;
2289 return matchingNode;
2290 };
2291
2292 Parser.prototype._cacheNoMatch = function(ruleName, offset) {
2293 Stats.add("cacheNoMatch");
2294 this._getRuleParseCache(ruleName)[offset] = "no_match";
2295 return null;
2296 };
2297
2298 Parser.prototype._resetParserTracking = function() {
2299 this._subparseInfo = null;
2300 this._logParsingFailures = false;
2301 this._partialParseTreeNodes = null;
2302 this._partialParseTree = null;
2303 this._matchingNegativeDepth = 0;
2304 this._parsingDidNotMatchEntireInput = false;
2305 this._failureIndex = 0;
2306 this._nonMatches = {};
2307 this._parseCache = {};
2308 return this._parentParserRootOffset = null;
2309 };
2310
2311 Parser.getter({
2312 failureIndex: function() {
2313 return this._failureIndex;
2314 },
2315 isMatchingNegative: function() {
2316 return this._matchingNegativeDepth > 0;
2317 }
2318 });
2319
2320 Parser.prototype._matchNegative = function(f) {
2321 var result;
2322 this._matchingNegativeDepth++;
2323 result = f();
2324 this._matchingNegativeDepth--;
2325 return result;
2326 };
2327
2328 Parser.prototype._logParsingFailure = function(parseIntoNode, patternElement) {
2329 var offset;
2330 if (!(this._matchingNegativeDepth === 0 && parseIntoNode.offset >= this._failureIndex && patternElement.isTokenPattern)) {
2331 return;
2332 }
2333 offset = parseIntoNode.offset;
2334 if (this._logParsingFailures) {
2335 parseIntoNode = parseIntoNode.getRealNode();
2336 return this._addNonMatch(offset, new NonMatch(parseIntoNode, patternElement));
2337 } else {
2338 return this._failureIndex = offset;
2339 }
2340 };
2341
2342 Parser.prototype._addNonMatch = function(offset, nonMatch) {
2343 if (offset > this._failureIndex) {
2344 this._failureIndex = offset;
2345 this._nonMatches = {};
2346 }
2347 return this._nonMatches[nonMatch] = nonMatch;
2348 };
2349
2350 return Parser;
2351
2352})(__webpack_require__(1).BaseClass);
2353
2354
2355/***/ }),
2356/* 24 */
2357/***/ (function(module, exports) {
2358
2359module.exports = require("color");
2360
2361/***/ }),
2362/* 25 */
2363/***/ (function(module, exports) {
2364
2365module.exports = require("neptune-namespaces");
2366
2367/***/ }),
2368/* 26 */
2369/***/ (function(module, exports) {
2370
2371module.exports = require("repl");
2372
2373/***/ }),
2374/* 27 */
2375/***/ (function(module, exports, __webpack_require__) {
2376
2377module.exports = __webpack_require__(17);
2378
2379
2380/***/ })
2381/******/ ]);
\No newline at end of file