ohm-js 16.3.0-dev.unicode-code-point-escape → 16.3.2
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.
- package/README.md +223 -0
- package/dist/ohm-grammar.js +1 -1
- package/dist/ohm.esm.js +407 -432
- package/dist/ohm.js +70 -78
- package/dist/ohm.min.js +1 -1
- package/extras/semantics-toAST.js +3 -16
- package/index.d.ts +0 -7
- package/package.json +13 -11
- package/src/CaseInsensitiveTerminal.js +1 -1
- package/src/MatchState.js +6 -2
- package/src/Semantics.js +1 -18
- package/src/common.js +2 -17
- package/src/errors.js +19 -3
- package/src/main.js +9 -2
- package/src/nodes.js +21 -32
- package/src/ohm-grammar.ohm +2 -1
- package/src/pexprs-eval.js +13 -17
- package/src/pexprs-main.js +3 -0
package/dist/ohm.esm.js
CHANGED
|
@@ -143,7 +143,7 @@ exports.abstract = function(optMethodName) {
|
|
|
143
143
|
|
|
144
144
|
exports.assert = function(cond, message) {
|
|
145
145
|
if (!cond) {
|
|
146
|
-
throw new Error(message);
|
|
146
|
+
throw new Error(message || 'Assertion failed');
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
|
|
@@ -237,24 +237,9 @@ exports.StringBuffer.prototype.contents = function() {
|
|
|
237
237
|
return this.strings.join('');
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
// Character escaping and unescaping
|
|
241
|
-
|
|
242
|
-
exports.escapeChar = function(c, optDelim) {
|
|
243
|
-
const charCode = c.charCodeAt(0);
|
|
244
|
-
if ((c === '"' || c === "'") && optDelim && c !== optDelim) {
|
|
245
|
-
return c;
|
|
246
|
-
} else if (charCode < 128) {
|
|
247
|
-
return escapeStringFor[charCode];
|
|
248
|
-
} else if (128 <= charCode && charCode < 256) {
|
|
249
|
-
return '\\x' + exports.padLeft(charCode.toString(16), 2, '0');
|
|
250
|
-
} else {
|
|
251
|
-
return '\\u' + exports.padLeft(charCode.toString(16), 4, '0');
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
240
|
const escapeUnicode = str => String.fromCodePoint(parseInt(str, 16));
|
|
256
241
|
|
|
257
|
-
exports.
|
|
242
|
+
exports.unescapeCodePoint = function(s) {
|
|
258
243
|
if (s.charAt(0) === '\\') {
|
|
259
244
|
switch (s.charAt(1)) {
|
|
260
245
|
case 'b':
|
|
@@ -308,20 +293,19 @@ exports.unexpectedObjToString = function(obj) {
|
|
|
308
293
|
|
|
309
294
|
const common$k = common$l;
|
|
310
295
|
|
|
311
|
-
// Ensures that the deprecation warning for `primitiveValue` only appears once.
|
|
312
|
-
let didWarnForPrimitiveValue = false;
|
|
313
|
-
|
|
314
296
|
// --------------------------------------------------------------------
|
|
315
297
|
// Private stuff
|
|
316
298
|
// --------------------------------------------------------------------
|
|
317
299
|
|
|
318
300
|
class Node {
|
|
319
|
-
constructor(
|
|
320
|
-
this.grammar = grammar;
|
|
321
|
-
this.ctorName = ctorName;
|
|
301
|
+
constructor(matchLength) {
|
|
322
302
|
this.matchLength = matchLength;
|
|
323
303
|
}
|
|
324
304
|
|
|
305
|
+
get ctorName() {
|
|
306
|
+
throw new Error('subclass responsibility');
|
|
307
|
+
}
|
|
308
|
+
|
|
325
309
|
numChildren() {
|
|
326
310
|
return this.children ? this.children.length : 0;
|
|
327
311
|
}
|
|
@@ -415,52 +399,38 @@ class Node {
|
|
|
415
399
|
isOptional() {
|
|
416
400
|
return false;
|
|
417
401
|
}
|
|
418
|
-
|
|
419
|
-
toJSON() {
|
|
420
|
-
return {[this.ctorName]: this.children};
|
|
421
|
-
}
|
|
422
402
|
}
|
|
423
403
|
|
|
424
404
|
// Terminals
|
|
425
405
|
|
|
426
406
|
class TerminalNode$2 extends Node {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
super(grammar, '_terminal', matchLength);
|
|
430
|
-
this._value = value;
|
|
407
|
+
get ctorName() {
|
|
408
|
+
return '_terminal';
|
|
431
409
|
}
|
|
432
410
|
|
|
433
411
|
isTerminal() {
|
|
434
412
|
return true;
|
|
435
413
|
}
|
|
436
414
|
|
|
437
|
-
toJSON() {
|
|
438
|
-
return {[this.ctorName]: this._value};
|
|
439
|
-
}
|
|
440
|
-
|
|
441
415
|
get primitiveValue() {
|
|
442
|
-
|
|
443
|
-
// eslint-disable-next-line no-console
|
|
444
|
-
console.warn(
|
|
445
|
-
'Warning: primitiveValue is deprecated and will be removed in a future version of Ohm. ' +
|
|
446
|
-
'Use sourceString instead.'
|
|
447
|
-
);
|
|
448
|
-
didWarnForPrimitiveValue = true;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return this._value;
|
|
416
|
+
throw new Error('The `primitiveValue` property was removed in Ohm v17.');
|
|
452
417
|
}
|
|
453
418
|
}
|
|
454
419
|
|
|
455
420
|
// Nonterminals
|
|
456
421
|
|
|
457
422
|
class NonterminalNode$1 extends Node {
|
|
458
|
-
constructor(
|
|
459
|
-
super(
|
|
423
|
+
constructor(ruleName, children, childOffsets, matchLength) {
|
|
424
|
+
super(matchLength);
|
|
425
|
+
this.ruleName = ruleName;
|
|
460
426
|
this.children = children;
|
|
461
427
|
this.childOffsets = childOffsets;
|
|
462
428
|
}
|
|
463
429
|
|
|
430
|
+
get ctorName() {
|
|
431
|
+
return this.ruleName;
|
|
432
|
+
}
|
|
433
|
+
|
|
464
434
|
isNonterminal() {
|
|
465
435
|
return true;
|
|
466
436
|
}
|
|
@@ -477,13 +447,17 @@ class NonterminalNode$1 extends Node {
|
|
|
477
447
|
// Iterations
|
|
478
448
|
|
|
479
449
|
class IterationNode$2 extends Node {
|
|
480
|
-
constructor(
|
|
481
|
-
super(
|
|
450
|
+
constructor(children, childOffsets, matchLength, isOptional) {
|
|
451
|
+
super(matchLength);
|
|
482
452
|
this.children = children;
|
|
483
453
|
this.childOffsets = childOffsets;
|
|
484
454
|
this.optional = isOptional;
|
|
485
455
|
}
|
|
486
456
|
|
|
457
|
+
get ctorName() {
|
|
458
|
+
return '_iter';
|
|
459
|
+
}
|
|
460
|
+
|
|
487
461
|
isIteration() {
|
|
488
462
|
return true;
|
|
489
463
|
}
|
|
@@ -591,6 +565,9 @@ class Range extends PExpr$1 {
|
|
|
591
565
|
super();
|
|
592
566
|
this.from = from;
|
|
593
567
|
this.to = to;
|
|
568
|
+
// If either `from` or `to` is made up of multiple code units, then
|
|
569
|
+
// the range should consume a full code point, not a single code unit.
|
|
570
|
+
this.matchCodePoint = from.length > 1 || to.length > 1;
|
|
594
571
|
}
|
|
595
572
|
}
|
|
596
573
|
|
|
@@ -757,7 +734,7 @@ pexprsMain.UnicodeChar = UnicodeChar;
|
|
|
757
734
|
// --------------------------------------------------------------------
|
|
758
735
|
|
|
759
736
|
const common$i = common$l;
|
|
760
|
-
const pexprs$
|
|
737
|
+
const pexprs$l = pexprsMain;
|
|
761
738
|
|
|
762
739
|
// --------------------------------------------------------------------
|
|
763
740
|
// Operations
|
|
@@ -766,7 +743,7 @@ const pexprs$m = pexprsMain;
|
|
|
766
743
|
/*
|
|
767
744
|
Return true if we should skip spaces preceding this expression in a syntactic context.
|
|
768
745
|
*/
|
|
769
|
-
pexprs$
|
|
746
|
+
pexprs$l.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
770
747
|
'allowsSkippingPrecedingSpace'
|
|
771
748
|
);
|
|
772
749
|
|
|
@@ -774,12 +751,12 @@ pexprs$m.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
|
774
751
|
Generally, these are all first-order expressions and (with the exception of Apply)
|
|
775
752
|
directly read from the input stream.
|
|
776
753
|
*/
|
|
777
|
-
pexprs$
|
|
778
|
-
pexprs$
|
|
779
|
-
pexprs$
|
|
780
|
-
pexprs$
|
|
781
|
-
pexprs$
|
|
782
|
-
pexprs$
|
|
754
|
+
pexprs$l.any.allowsSkippingPrecedingSpace =
|
|
755
|
+
pexprs$l.end.allowsSkippingPrecedingSpace =
|
|
756
|
+
pexprs$l.Apply.prototype.allowsSkippingPrecedingSpace =
|
|
757
|
+
pexprs$l.Terminal.prototype.allowsSkippingPrecedingSpace =
|
|
758
|
+
pexprs$l.Range.prototype.allowsSkippingPrecedingSpace =
|
|
759
|
+
pexprs$l.UnicodeChar.prototype.allowsSkippingPrecedingSpace =
|
|
783
760
|
function() {
|
|
784
761
|
return true;
|
|
785
762
|
};
|
|
@@ -787,13 +764,13 @@ pexprs$m.any.allowsSkippingPrecedingSpace =
|
|
|
787
764
|
/*
|
|
788
765
|
Higher-order expressions that don't directly consume input.
|
|
789
766
|
*/
|
|
790
|
-
pexprs$
|
|
791
|
-
pexprs$
|
|
792
|
-
pexprs$
|
|
793
|
-
pexprs$
|
|
794
|
-
pexprs$
|
|
795
|
-
pexprs$
|
|
796
|
-
pexprs$
|
|
767
|
+
pexprs$l.Alt.prototype.allowsSkippingPrecedingSpace =
|
|
768
|
+
pexprs$l.Iter.prototype.allowsSkippingPrecedingSpace =
|
|
769
|
+
pexprs$l.Lex.prototype.allowsSkippingPrecedingSpace =
|
|
770
|
+
pexprs$l.Lookahead.prototype.allowsSkippingPrecedingSpace =
|
|
771
|
+
pexprs$l.Not.prototype.allowsSkippingPrecedingSpace =
|
|
772
|
+
pexprs$l.Param.prototype.allowsSkippingPrecedingSpace =
|
|
773
|
+
pexprs$l.Seq.prototype.allowsSkippingPrecedingSpace =
|
|
797
774
|
function() {
|
|
798
775
|
return false;
|
|
799
776
|
};
|
|
@@ -850,9 +827,9 @@ var Namespace_1 = Namespace$2;
|
|
|
850
827
|
// Imports
|
|
851
828
|
// --------------------------------------------------------------------
|
|
852
829
|
|
|
853
|
-
const
|
|
854
|
-
|
|
830
|
+
const {assert: assert$3} = common$l;
|
|
855
831
|
const Namespace$1 = Namespace_1;
|
|
832
|
+
const pexprs$k = pexprsMain;
|
|
856
833
|
|
|
857
834
|
// --------------------------------------------------------------------
|
|
858
835
|
// Private stuff
|
|
@@ -982,7 +959,7 @@ function wrongNumberOfArguments(ruleName, expected, actual, expr) {
|
|
|
982
959
|
', got ' +
|
|
983
960
|
actual +
|
|
984
961
|
')',
|
|
985
|
-
expr
|
|
962
|
+
expr
|
|
986
963
|
);
|
|
987
964
|
}
|
|
988
965
|
|
|
@@ -1055,6 +1032,21 @@ function multipleSuperSplices(expr) {
|
|
|
1055
1032
|
return createError("'...' can appear at most once in a rule body", expr.source);
|
|
1056
1033
|
}
|
|
1057
1034
|
|
|
1035
|
+
// Unicode code point escapes
|
|
1036
|
+
|
|
1037
|
+
function invalidCodePoint(applyWrapper) {
|
|
1038
|
+
const node = applyWrapper._node;
|
|
1039
|
+
assert$3(node && node.isNonterminal() && node.ctorName === 'escapeChar_unicodeCodePoint');
|
|
1040
|
+
|
|
1041
|
+
// Get an interval that covers all of the hex digits.
|
|
1042
|
+
const digitIntervals = applyWrapper.children.slice(1, -1).map(d => d.source);
|
|
1043
|
+
const fullInterval = digitIntervals[0].coverageWith(...digitIntervals.slice(1));
|
|
1044
|
+
return createError(
|
|
1045
|
+
`U+${fullInterval.contents} is not a valid Unicode code point`,
|
|
1046
|
+
fullInterval
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1058
1050
|
// ----------------- Kleene operators -----------------
|
|
1059
1051
|
|
|
1060
1052
|
function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
@@ -1069,7 +1061,7 @@ function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
|
1069
1061
|
"' (possible infinite loop)";
|
|
1070
1062
|
if (applicationStack.length > 0) {
|
|
1071
1063
|
const stackTrace = applicationStack
|
|
1072
|
-
.map(app => new pexprs$
|
|
1064
|
+
.map(app => new pexprs$k.Apply(app.ruleName, app.args))
|
|
1073
1065
|
.join('\n');
|
|
1074
1066
|
message += '\nApplication stack (most recent application last):\n' + stackTrace;
|
|
1075
1067
|
}
|
|
@@ -1160,6 +1152,7 @@ var errors$9 = {
|
|
|
1160
1152
|
inconsistentArity,
|
|
1161
1153
|
incorrectArgumentType,
|
|
1162
1154
|
intervalSourcesDontMatch,
|
|
1155
|
+
invalidCodePoint,
|
|
1163
1156
|
invalidConstructorCall,
|
|
1164
1157
|
invalidParameter,
|
|
1165
1158
|
grammarSyntaxError,
|
|
@@ -1371,7 +1364,7 @@ exports.uniqueId = (() => {
|
|
|
1371
1364
|
|
|
1372
1365
|
const {abstract, isSyntactic} = common$l;
|
|
1373
1366
|
const errors$8 = errors$9;
|
|
1374
|
-
const pexprs$
|
|
1367
|
+
const pexprs$j = pexprsMain;
|
|
1375
1368
|
const util$6 = util$7;
|
|
1376
1369
|
|
|
1377
1370
|
let BuiltInRules;
|
|
@@ -1386,51 +1379,51 @@ util$6.awaitBuiltInRules(g => {
|
|
|
1386
1379
|
|
|
1387
1380
|
let lexifyCount;
|
|
1388
1381
|
|
|
1389
|
-
pexprs$
|
|
1382
|
+
pexprs$j.PExpr.prototype.assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1390
1383
|
lexifyCount = 0;
|
|
1391
1384
|
this._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1392
1385
|
};
|
|
1393
1386
|
|
|
1394
|
-
pexprs$
|
|
1387
|
+
pexprs$j.PExpr.prototype._assertAllApplicationsAreValid = abstract(
|
|
1395
1388
|
'_assertAllApplicationsAreValid'
|
|
1396
1389
|
);
|
|
1397
1390
|
|
|
1398
|
-
pexprs$
|
|
1399
|
-
pexprs$
|
|
1400
|
-
pexprs$
|
|
1401
|
-
pexprs$
|
|
1402
|
-
pexprs$
|
|
1403
|
-
pexprs$
|
|
1391
|
+
pexprs$j.any._assertAllApplicationsAreValid =
|
|
1392
|
+
pexprs$j.end._assertAllApplicationsAreValid =
|
|
1393
|
+
pexprs$j.Terminal.prototype._assertAllApplicationsAreValid =
|
|
1394
|
+
pexprs$j.Range.prototype._assertAllApplicationsAreValid =
|
|
1395
|
+
pexprs$j.Param.prototype._assertAllApplicationsAreValid =
|
|
1396
|
+
pexprs$j.UnicodeChar.prototype._assertAllApplicationsAreValid =
|
|
1404
1397
|
function(ruleName, grammar) {
|
|
1405
1398
|
// no-op
|
|
1406
1399
|
};
|
|
1407
1400
|
|
|
1408
|
-
pexprs$
|
|
1401
|
+
pexprs$j.Lex.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1409
1402
|
lexifyCount++;
|
|
1410
1403
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1411
1404
|
lexifyCount--;
|
|
1412
1405
|
};
|
|
1413
1406
|
|
|
1414
|
-
pexprs$
|
|
1407
|
+
pexprs$j.Alt.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1415
1408
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1416
1409
|
this.terms[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1417
1410
|
}
|
|
1418
1411
|
};
|
|
1419
1412
|
|
|
1420
|
-
pexprs$
|
|
1413
|
+
pexprs$j.Seq.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1421
1414
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1422
1415
|
this.factors[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1423
1416
|
}
|
|
1424
1417
|
};
|
|
1425
1418
|
|
|
1426
|
-
pexprs$
|
|
1427
|
-
pexprs$
|
|
1428
|
-
pexprs$
|
|
1419
|
+
pexprs$j.Iter.prototype._assertAllApplicationsAreValid =
|
|
1420
|
+
pexprs$j.Not.prototype._assertAllApplicationsAreValid =
|
|
1421
|
+
pexprs$j.Lookahead.prototype._assertAllApplicationsAreValid =
|
|
1429
1422
|
function(ruleName, grammar) {
|
|
1430
1423
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1431
1424
|
};
|
|
1432
1425
|
|
|
1433
|
-
pexprs$
|
|
1426
|
+
pexprs$j.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
1434
1427
|
ruleName,
|
|
1435
1428
|
grammar,
|
|
1436
1429
|
skipSyntacticCheck = false
|
|
@@ -1462,14 +1455,14 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1462
1455
|
|
|
1463
1456
|
// If it's an application of 'caseInsensitive', ensure that the argument is a Terminal.
|
|
1464
1457
|
if (isBuiltInCaseInsensitive) {
|
|
1465
|
-
if (!(this.args[0] instanceof pexprs$
|
|
1458
|
+
if (!(this.args[0] instanceof pexprs$j.Terminal)) {
|
|
1466
1459
|
throw errors$8.incorrectArgumentType('a Terminal (e.g. "abc")', this.args[0]);
|
|
1467
1460
|
}
|
|
1468
1461
|
}
|
|
1469
1462
|
|
|
1470
1463
|
if (isBuiltInApplySyntactic) {
|
|
1471
1464
|
const arg = this.args[0];
|
|
1472
|
-
if (!(arg instanceof pexprs$
|
|
1465
|
+
if (!(arg instanceof pexprs$j.Apply)) {
|
|
1473
1466
|
throw errors$8.incorrectArgumentType('a syntactic rule application', arg);
|
|
1474
1467
|
}
|
|
1475
1468
|
if (!isSyntactic(arg.ruleName)) {
|
|
@@ -1497,28 +1490,28 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1497
1490
|
|
|
1498
1491
|
const common$h = common$l;
|
|
1499
1492
|
const errors$7 = errors$9;
|
|
1500
|
-
const pexprs$
|
|
1493
|
+
const pexprs$i = pexprsMain;
|
|
1501
1494
|
|
|
1502
1495
|
// --------------------------------------------------------------------
|
|
1503
1496
|
// Operations
|
|
1504
1497
|
// --------------------------------------------------------------------
|
|
1505
1498
|
|
|
1506
|
-
pexprs$
|
|
1499
|
+
pexprs$i.PExpr.prototype.assertChoicesHaveUniformArity = common$h.abstract(
|
|
1507
1500
|
'assertChoicesHaveUniformArity'
|
|
1508
1501
|
);
|
|
1509
1502
|
|
|
1510
|
-
pexprs$
|
|
1511
|
-
pexprs$
|
|
1512
|
-
pexprs$
|
|
1513
|
-
pexprs$
|
|
1514
|
-
pexprs$
|
|
1515
|
-
pexprs$
|
|
1516
|
-
pexprs$
|
|
1503
|
+
pexprs$i.any.assertChoicesHaveUniformArity =
|
|
1504
|
+
pexprs$i.end.assertChoicesHaveUniformArity =
|
|
1505
|
+
pexprs$i.Terminal.prototype.assertChoicesHaveUniformArity =
|
|
1506
|
+
pexprs$i.Range.prototype.assertChoicesHaveUniformArity =
|
|
1507
|
+
pexprs$i.Param.prototype.assertChoicesHaveUniformArity =
|
|
1508
|
+
pexprs$i.Lex.prototype.assertChoicesHaveUniformArity =
|
|
1509
|
+
pexprs$i.UnicodeChar.prototype.assertChoicesHaveUniformArity =
|
|
1517
1510
|
function(ruleName) {
|
|
1518
1511
|
// no-op
|
|
1519
1512
|
};
|
|
1520
1513
|
|
|
1521
|
-
pexprs$
|
|
1514
|
+
pexprs$i.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1522
1515
|
if (this.terms.length === 0) {
|
|
1523
1516
|
return;
|
|
1524
1517
|
}
|
|
@@ -1533,7 +1526,7 @@ pexprs$j.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1533
1526
|
}
|
|
1534
1527
|
};
|
|
1535
1528
|
|
|
1536
|
-
pexprs$
|
|
1529
|
+
pexprs$i.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1537
1530
|
// Extend is a special case of Alt that's guaranteed to have exactly two
|
|
1538
1531
|
// cases: [extensions, origBody].
|
|
1539
1532
|
const actualArity = this.terms[0].getArity();
|
|
@@ -1543,25 +1536,25 @@ pexprs$j.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1543
1536
|
}
|
|
1544
1537
|
};
|
|
1545
1538
|
|
|
1546
|
-
pexprs$
|
|
1539
|
+
pexprs$i.Seq.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1547
1540
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1548
1541
|
this.factors[idx].assertChoicesHaveUniformArity(ruleName);
|
|
1549
1542
|
}
|
|
1550
1543
|
};
|
|
1551
1544
|
|
|
1552
|
-
pexprs$
|
|
1545
|
+
pexprs$i.Iter.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1553
1546
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1554
1547
|
};
|
|
1555
1548
|
|
|
1556
|
-
pexprs$
|
|
1549
|
+
pexprs$i.Not.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1557
1550
|
// no-op (not required b/c the nested expr doesn't show up in the CST)
|
|
1558
1551
|
};
|
|
1559
1552
|
|
|
1560
|
-
pexprs$
|
|
1553
|
+
pexprs$i.Lookahead.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1561
1554
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1562
1555
|
};
|
|
1563
1556
|
|
|
1564
|
-
pexprs$
|
|
1557
|
+
pexprs$i.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1565
1558
|
// The arities of the parameter expressions is required to be 1 by
|
|
1566
1559
|
// `assertAllApplicationsAreValid()`.
|
|
1567
1560
|
};
|
|
@@ -1572,39 +1565,39 @@ pexprs$j.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1572
1565
|
|
|
1573
1566
|
const common$g = common$l;
|
|
1574
1567
|
const errors$6 = errors$9;
|
|
1575
|
-
const pexprs$
|
|
1568
|
+
const pexprs$h = pexprsMain;
|
|
1576
1569
|
|
|
1577
1570
|
// --------------------------------------------------------------------
|
|
1578
1571
|
// Operations
|
|
1579
1572
|
// --------------------------------------------------------------------
|
|
1580
1573
|
|
|
1581
|
-
pexprs$
|
|
1574
|
+
pexprs$h.PExpr.prototype.assertIteratedExprsAreNotNullable = common$g.abstract(
|
|
1582
1575
|
'assertIteratedExprsAreNotNullable'
|
|
1583
1576
|
);
|
|
1584
1577
|
|
|
1585
|
-
pexprs$
|
|
1586
|
-
pexprs$
|
|
1587
|
-
pexprs$
|
|
1588
|
-
pexprs$
|
|
1589
|
-
pexprs$
|
|
1590
|
-
pexprs$
|
|
1578
|
+
pexprs$h.any.assertIteratedExprsAreNotNullable =
|
|
1579
|
+
pexprs$h.end.assertIteratedExprsAreNotNullable =
|
|
1580
|
+
pexprs$h.Terminal.prototype.assertIteratedExprsAreNotNullable =
|
|
1581
|
+
pexprs$h.Range.prototype.assertIteratedExprsAreNotNullable =
|
|
1582
|
+
pexprs$h.Param.prototype.assertIteratedExprsAreNotNullable =
|
|
1583
|
+
pexprs$h.UnicodeChar.prototype.assertIteratedExprsAreNotNullable =
|
|
1591
1584
|
function(grammar) {
|
|
1592
1585
|
// no-op
|
|
1593
1586
|
};
|
|
1594
1587
|
|
|
1595
|
-
pexprs$
|
|
1588
|
+
pexprs$h.Alt.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1596
1589
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1597
1590
|
this.terms[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1598
1591
|
}
|
|
1599
1592
|
};
|
|
1600
1593
|
|
|
1601
|
-
pexprs$
|
|
1594
|
+
pexprs$h.Seq.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1602
1595
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1603
1596
|
this.factors[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1604
1597
|
}
|
|
1605
1598
|
};
|
|
1606
1599
|
|
|
1607
|
-
pexprs$
|
|
1600
|
+
pexprs$h.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1608
1601
|
// Note: this is the implementation of this method for `Star` and `Plus` expressions.
|
|
1609
1602
|
// It is overridden for `Opt` below.
|
|
1610
1603
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
@@ -1613,15 +1606,15 @@ pexprs$i.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
|
1613
1606
|
}
|
|
1614
1607
|
};
|
|
1615
1608
|
|
|
1616
|
-
pexprs$
|
|
1617
|
-
pexprs$
|
|
1618
|
-
pexprs$
|
|
1619
|
-
pexprs$
|
|
1609
|
+
pexprs$h.Opt.prototype.assertIteratedExprsAreNotNullable =
|
|
1610
|
+
pexprs$h.Not.prototype.assertIteratedExprsAreNotNullable =
|
|
1611
|
+
pexprs$h.Lookahead.prototype.assertIteratedExprsAreNotNullable =
|
|
1612
|
+
pexprs$h.Lex.prototype.assertIteratedExprsAreNotNullable =
|
|
1620
1613
|
function(grammar) {
|
|
1621
1614
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
1622
1615
|
};
|
|
1623
1616
|
|
|
1624
|
-
pexprs$
|
|
1617
|
+
pexprs$h.Apply.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1625
1618
|
this.args.forEach(arg => {
|
|
1626
1619
|
arg.assertIteratedExprsAreNotNullable(grammar);
|
|
1627
1620
|
});
|
|
@@ -1986,7 +1979,7 @@ const Trace$1 = Trace_1;
|
|
|
1986
1979
|
const common$e = common$l;
|
|
1987
1980
|
const errors$4 = errors$9;
|
|
1988
1981
|
const nodes = nodes$1;
|
|
1989
|
-
const pexprs$
|
|
1982
|
+
const pexprs$g = pexprsMain;
|
|
1990
1983
|
|
|
1991
1984
|
const {TerminalNode: TerminalNode$1} = nodes;
|
|
1992
1985
|
const {NonterminalNode} = nodes;
|
|
@@ -2012,14 +2005,14 @@ const {IterationNode: IterationNode$1} = nodes;
|
|
|
2012
2005
|
Note that `State.prototype.eval(expr)`, unlike this method, guarantees that neither the state
|
|
2013
2006
|
object's bindings nor its input stream's position will change if the expression fails to match.
|
|
2014
2007
|
*/
|
|
2015
|
-
pexprs$
|
|
2008
|
+
pexprs$g.PExpr.prototype.eval = common$e.abstract('eval'); // function(state) { ... }
|
|
2016
2009
|
|
|
2017
|
-
pexprs$
|
|
2010
|
+
pexprs$g.any.eval = function(state) {
|
|
2018
2011
|
const {inputStream} = state;
|
|
2019
2012
|
const origPos = inputStream.pos;
|
|
2020
2013
|
const ch = inputStream.next();
|
|
2021
2014
|
if (ch) {
|
|
2022
|
-
state.pushBinding(new TerminalNode$1(
|
|
2015
|
+
state.pushBinding(new TerminalNode$1(ch.length), origPos);
|
|
2023
2016
|
return true;
|
|
2024
2017
|
} else {
|
|
2025
2018
|
state.processFailure(origPos, this);
|
|
@@ -2027,11 +2020,11 @@ pexprs$h.any.eval = function(state) {
|
|
|
2027
2020
|
}
|
|
2028
2021
|
};
|
|
2029
2022
|
|
|
2030
|
-
pexprs$
|
|
2023
|
+
pexprs$g.end.eval = function(state) {
|
|
2031
2024
|
const {inputStream} = state;
|
|
2032
2025
|
const origPos = inputStream.pos;
|
|
2033
2026
|
if (inputStream.atEnd()) {
|
|
2034
|
-
state.pushBinding(new TerminalNode$1(
|
|
2027
|
+
state.pushBinding(new TerminalNode$1(0), origPos);
|
|
2035
2028
|
return true;
|
|
2036
2029
|
} else {
|
|
2037
2030
|
state.processFailure(origPos, this);
|
|
@@ -2039,31 +2032,30 @@ pexprs$h.end.eval = function(state) {
|
|
|
2039
2032
|
}
|
|
2040
2033
|
};
|
|
2041
2034
|
|
|
2042
|
-
pexprs$
|
|
2035
|
+
pexprs$g.Terminal.prototype.eval = function(state) {
|
|
2043
2036
|
const {inputStream} = state;
|
|
2044
2037
|
const origPos = inputStream.pos;
|
|
2045
2038
|
if (!inputStream.matchString(this.obj)) {
|
|
2046
2039
|
state.processFailure(origPos, this);
|
|
2047
2040
|
return false;
|
|
2048
2041
|
} else {
|
|
2049
|
-
state.pushBinding(new TerminalNode$1(
|
|
2042
|
+
state.pushBinding(new TerminalNode$1(this.obj.length), origPos);
|
|
2050
2043
|
return true;
|
|
2051
2044
|
}
|
|
2052
2045
|
};
|
|
2053
2046
|
|
|
2054
|
-
pexprs$
|
|
2047
|
+
pexprs$g.Range.prototype.eval = function(state) {
|
|
2055
2048
|
const {inputStream} = state;
|
|
2056
2049
|
const origPos = inputStream.pos;
|
|
2057
2050
|
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
} else {
|
|
2062
|
-
cp = inputStream.atEnd() ? undefined : inputStream.next().codePointAt(0);
|
|
2063
|
-
}
|
|
2051
|
+
// A range can operate in one of two modes: matching a single, 16-bit _code unit_,
|
|
2052
|
+
// or matching a _code point_. (Code points over 0xFFFF take up two 16-bit code units.)
|
|
2053
|
+
const cp = this.matchCodePoint ? inputStream.nextCodePoint() : inputStream.nextCharCode();
|
|
2064
2054
|
|
|
2055
|
+
// Always compare by code point value to get the correct result in all scenarios.
|
|
2056
|
+
// Note that for strings of length 1, codePointAt(0) and charPointAt(0) are equivalent.
|
|
2065
2057
|
if (cp !== undefined && this.from.codePointAt(0) <= cp && cp <= this.to.codePointAt(0)) {
|
|
2066
|
-
state.pushBinding(new TerminalNode$1(
|
|
2058
|
+
state.pushBinding(new TerminalNode$1(String.fromCodePoint(cp).length), origPos);
|
|
2067
2059
|
return true;
|
|
2068
2060
|
} else {
|
|
2069
2061
|
state.processFailure(origPos, this);
|
|
@@ -2071,18 +2063,18 @@ pexprs$h.Range.prototype.eval = function(state) {
|
|
|
2071
2063
|
}
|
|
2072
2064
|
};
|
|
2073
2065
|
|
|
2074
|
-
pexprs$
|
|
2066
|
+
pexprs$g.Param.prototype.eval = function(state) {
|
|
2075
2067
|
return state.eval(state.currentApplication().args[this.index]);
|
|
2076
2068
|
};
|
|
2077
2069
|
|
|
2078
|
-
pexprs$
|
|
2070
|
+
pexprs$g.Lex.prototype.eval = function(state) {
|
|
2079
2071
|
state.enterLexifiedContext();
|
|
2080
2072
|
const ans = state.eval(this.expr);
|
|
2081
2073
|
state.exitLexifiedContext();
|
|
2082
2074
|
return ans;
|
|
2083
2075
|
};
|
|
2084
2076
|
|
|
2085
|
-
pexprs$
|
|
2077
|
+
pexprs$g.Alt.prototype.eval = function(state) {
|
|
2086
2078
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
2087
2079
|
if (state.eval(this.terms[idx])) {
|
|
2088
2080
|
return true;
|
|
@@ -2091,7 +2083,7 @@ pexprs$h.Alt.prototype.eval = function(state) {
|
|
|
2091
2083
|
return false;
|
|
2092
2084
|
};
|
|
2093
2085
|
|
|
2094
|
-
pexprs$
|
|
2086
|
+
pexprs$g.Seq.prototype.eval = function(state) {
|
|
2095
2087
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2096
2088
|
const factor = this.factors[idx];
|
|
2097
2089
|
if (!state.eval(factor)) {
|
|
@@ -2101,7 +2093,7 @@ pexprs$h.Seq.prototype.eval = function(state) {
|
|
|
2101
2093
|
return true;
|
|
2102
2094
|
};
|
|
2103
2095
|
|
|
2104
|
-
pexprs$
|
|
2096
|
+
pexprs$g.Iter.prototype.eval = function(state) {
|
|
2105
2097
|
const {inputStream} = state;
|
|
2106
2098
|
const origPos = inputStream.pos;
|
|
2107
2099
|
const arity = this.getArity();
|
|
@@ -2145,17 +2137,17 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2145
2137
|
offset = colOffsets[0][0];
|
|
2146
2138
|
matchLength = endOffset - offset;
|
|
2147
2139
|
}
|
|
2148
|
-
const isOptional = this instanceof pexprs$
|
|
2140
|
+
const isOptional = this instanceof pexprs$g.Opt;
|
|
2149
2141
|
for (idx = 0; idx < cols.length; idx++) {
|
|
2150
2142
|
state._bindings.push(
|
|
2151
|
-
new IterationNode$1(
|
|
2143
|
+
new IterationNode$1(cols[idx], colOffsets[idx], matchLength, isOptional)
|
|
2152
2144
|
);
|
|
2153
2145
|
state._bindingOffsets.push(offset);
|
|
2154
2146
|
}
|
|
2155
2147
|
return true;
|
|
2156
2148
|
};
|
|
2157
2149
|
|
|
2158
|
-
pexprs$
|
|
2150
|
+
pexprs$g.Not.prototype.eval = function(state) {
|
|
2159
2151
|
/*
|
|
2160
2152
|
TODO:
|
|
2161
2153
|
- Right now we're just throwing away all of the failures that happen inside a `not`, and
|
|
@@ -2181,7 +2173,7 @@ pexprs$h.Not.prototype.eval = function(state) {
|
|
|
2181
2173
|
return true;
|
|
2182
2174
|
};
|
|
2183
2175
|
|
|
2184
|
-
pexprs$
|
|
2176
|
+
pexprs$g.Lookahead.prototype.eval = function(state) {
|
|
2185
2177
|
const {inputStream} = state;
|
|
2186
2178
|
const origPos = inputStream.pos;
|
|
2187
2179
|
if (state.eval(this.expr)) {
|
|
@@ -2192,7 +2184,7 @@ pexprs$h.Lookahead.prototype.eval = function(state) {
|
|
|
2192
2184
|
}
|
|
2193
2185
|
};
|
|
2194
2186
|
|
|
2195
|
-
pexprs$
|
|
2187
|
+
pexprs$g.Apply.prototype.eval = function(state) {
|
|
2196
2188
|
const caller = state.currentApplication();
|
|
2197
2189
|
const actuals = caller ? caller.args : [];
|
|
2198
2190
|
const app = this.substituteParams(actuals);
|
|
@@ -2215,7 +2207,7 @@ pexprs$h.Apply.prototype.eval = function(state) {
|
|
|
2215
2207
|
return app.reallyEval(state);
|
|
2216
2208
|
};
|
|
2217
2209
|
|
|
2218
|
-
pexprs$
|
|
2210
|
+
pexprs$g.Apply.prototype.handleCycle = function(state) {
|
|
2219
2211
|
const posInfo = state.getCurrentPosInfo();
|
|
2220
2212
|
const {currentLeftRecursion} = posInfo;
|
|
2221
2213
|
const memoKey = this.toMemoKey();
|
|
@@ -2238,7 +2230,7 @@ pexprs$h.Apply.prototype.handleCycle = function(state) {
|
|
|
2238
2230
|
return state.useMemoizedResult(state.inputStream.pos, memoRec);
|
|
2239
2231
|
};
|
|
2240
2232
|
|
|
2241
|
-
pexprs$
|
|
2233
|
+
pexprs$g.Apply.prototype.reallyEval = function(state) {
|
|
2242
2234
|
const {inputStream} = state;
|
|
2243
2235
|
const origPos = inputStream.pos;
|
|
2244
2236
|
const origPosInfo = state.getCurrentPosInfo();
|
|
@@ -2315,7 +2307,7 @@ pexprs$h.Apply.prototype.reallyEval = function(state) {
|
|
|
2315
2307
|
return succeeded;
|
|
2316
2308
|
};
|
|
2317
2309
|
|
|
2318
|
-
pexprs$
|
|
2310
|
+
pexprs$g.Apply.prototype.evalOnce = function(expr, state) {
|
|
2319
2311
|
const {inputStream} = state;
|
|
2320
2312
|
const origPos = inputStream.pos;
|
|
2321
2313
|
|
|
@@ -2323,19 +2315,14 @@ pexprs$h.Apply.prototype.evalOnce = function(expr, state) {
|
|
|
2323
2315
|
const arity = expr.getArity();
|
|
2324
2316
|
const bindings = state._bindings.splice(state._bindings.length - arity, arity);
|
|
2325
2317
|
const offsets = state._bindingOffsets.splice(state._bindingOffsets.length - arity, arity);
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
this.ruleName,
|
|
2329
|
-
bindings,
|
|
2330
|
-
offsets,
|
|
2331
|
-
inputStream.pos - origPos
|
|
2332
|
-
);
|
|
2318
|
+
const matchLength = inputStream.pos - origPos;
|
|
2319
|
+
return new NonterminalNode(this.ruleName, bindings, offsets, matchLength);
|
|
2333
2320
|
} else {
|
|
2334
2321
|
return false;
|
|
2335
2322
|
}
|
|
2336
2323
|
};
|
|
2337
2324
|
|
|
2338
|
-
pexprs$
|
|
2325
|
+
pexprs$g.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoRec, newValue) {
|
|
2339
2326
|
if (!newValue) {
|
|
2340
2327
|
return false;
|
|
2341
2328
|
}
|
|
@@ -2379,12 +2366,12 @@ pexprs$h.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoR
|
|
|
2379
2366
|
return lrMemoRec.value;
|
|
2380
2367
|
};
|
|
2381
2368
|
|
|
2382
|
-
pexprs$
|
|
2369
|
+
pexprs$g.UnicodeChar.prototype.eval = function(state) {
|
|
2383
2370
|
const {inputStream} = state;
|
|
2384
2371
|
const origPos = inputStream.pos;
|
|
2385
2372
|
const ch = inputStream.next();
|
|
2386
2373
|
if (ch && this.pattern.test(ch)) {
|
|
2387
|
-
state.pushBinding(new TerminalNode$1(
|
|
2374
|
+
state.pushBinding(new TerminalNode$1(ch.length), origPos);
|
|
2388
2375
|
return true;
|
|
2389
2376
|
} else {
|
|
2390
2377
|
state.processFailure(origPos, this);
|
|
@@ -2397,32 +2384,32 @@ pexprs$h.UnicodeChar.prototype.eval = function(state) {
|
|
|
2397
2384
|
// --------------------------------------------------------------------
|
|
2398
2385
|
|
|
2399
2386
|
const common$d = common$l;
|
|
2400
|
-
const pexprs$
|
|
2387
|
+
const pexprs$f = pexprsMain;
|
|
2401
2388
|
|
|
2402
2389
|
// --------------------------------------------------------------------
|
|
2403
2390
|
// Operations
|
|
2404
2391
|
// --------------------------------------------------------------------
|
|
2405
2392
|
|
|
2406
|
-
pexprs$
|
|
2393
|
+
pexprs$f.PExpr.prototype.getArity = common$d.abstract('getArity');
|
|
2407
2394
|
|
|
2408
|
-
pexprs$
|
|
2409
|
-
pexprs$
|
|
2410
|
-
pexprs$
|
|
2411
|
-
pexprs$
|
|
2412
|
-
pexprs$
|
|
2413
|
-
pexprs$
|
|
2414
|
-
pexprs$
|
|
2395
|
+
pexprs$f.any.getArity =
|
|
2396
|
+
pexprs$f.end.getArity =
|
|
2397
|
+
pexprs$f.Terminal.prototype.getArity =
|
|
2398
|
+
pexprs$f.Range.prototype.getArity =
|
|
2399
|
+
pexprs$f.Param.prototype.getArity =
|
|
2400
|
+
pexprs$f.Apply.prototype.getArity =
|
|
2401
|
+
pexprs$f.UnicodeChar.prototype.getArity =
|
|
2415
2402
|
function() {
|
|
2416
2403
|
return 1;
|
|
2417
2404
|
};
|
|
2418
2405
|
|
|
2419
|
-
pexprs$
|
|
2406
|
+
pexprs$f.Alt.prototype.getArity = function() {
|
|
2420
2407
|
// This is ok b/c all terms must have the same arity -- this property is
|
|
2421
2408
|
// checked by the Grammar constructor.
|
|
2422
2409
|
return this.terms.length === 0 ? 0 : this.terms[0].getArity();
|
|
2423
2410
|
};
|
|
2424
2411
|
|
|
2425
|
-
pexprs$
|
|
2412
|
+
pexprs$f.Seq.prototype.getArity = function() {
|
|
2426
2413
|
let arity = 0;
|
|
2427
2414
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2428
2415
|
arity += this.factors[idx].getArity();
|
|
@@ -2430,15 +2417,15 @@ pexprs$g.Seq.prototype.getArity = function() {
|
|
|
2430
2417
|
return arity;
|
|
2431
2418
|
};
|
|
2432
2419
|
|
|
2433
|
-
pexprs$
|
|
2420
|
+
pexprs$f.Iter.prototype.getArity = function() {
|
|
2434
2421
|
return this.expr.getArity();
|
|
2435
2422
|
};
|
|
2436
2423
|
|
|
2437
|
-
pexprs$
|
|
2424
|
+
pexprs$f.Not.prototype.getArity = function() {
|
|
2438
2425
|
return 0;
|
|
2439
2426
|
};
|
|
2440
2427
|
|
|
2441
|
-
pexprs$
|
|
2428
|
+
pexprs$f.Lookahead.prototype.getArity = pexprs$f.Lex.prototype.getArity = function() {
|
|
2442
2429
|
return this.expr.getArity();
|
|
2443
2430
|
};
|
|
2444
2431
|
|
|
@@ -2447,7 +2434,7 @@ pexprs$g.Lookahead.prototype.getArity = pexprs$g.Lex.prototype.getArity = functi
|
|
|
2447
2434
|
// --------------------------------------------------------------------
|
|
2448
2435
|
|
|
2449
2436
|
const common$c = common$l;
|
|
2450
|
-
const pexprs$
|
|
2437
|
+
const pexprs$e = pexprsMain;
|
|
2451
2438
|
|
|
2452
2439
|
// --------------------------------------------------------------------
|
|
2453
2440
|
// Private stuff
|
|
@@ -2466,40 +2453,40 @@ function getMetaInfo(expr, grammarInterval) {
|
|
|
2466
2453
|
// Operations
|
|
2467
2454
|
// --------------------------------------------------------------------
|
|
2468
2455
|
|
|
2469
|
-
pexprs$
|
|
2456
|
+
pexprs$e.PExpr.prototype.outputRecipe = common$c.abstract('outputRecipe');
|
|
2470
2457
|
|
|
2471
|
-
pexprs$
|
|
2458
|
+
pexprs$e.any.outputRecipe = function(formals, grammarInterval) {
|
|
2472
2459
|
return ['any', getMetaInfo(this, grammarInterval)];
|
|
2473
2460
|
};
|
|
2474
2461
|
|
|
2475
|
-
pexprs$
|
|
2462
|
+
pexprs$e.end.outputRecipe = function(formals, grammarInterval) {
|
|
2476
2463
|
return ['end', getMetaInfo(this, grammarInterval)];
|
|
2477
2464
|
};
|
|
2478
2465
|
|
|
2479
|
-
pexprs$
|
|
2466
|
+
pexprs$e.Terminal.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2480
2467
|
return ['terminal', getMetaInfo(this, grammarInterval), this.obj];
|
|
2481
2468
|
};
|
|
2482
2469
|
|
|
2483
|
-
pexprs$
|
|
2470
|
+
pexprs$e.Range.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2484
2471
|
return ['range', getMetaInfo(this, grammarInterval), this.from, this.to];
|
|
2485
2472
|
};
|
|
2486
2473
|
|
|
2487
|
-
pexprs$
|
|
2474
|
+
pexprs$e.Param.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2488
2475
|
return ['param', getMetaInfo(this, grammarInterval), this.index];
|
|
2489
2476
|
};
|
|
2490
2477
|
|
|
2491
|
-
pexprs$
|
|
2478
|
+
pexprs$e.Alt.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2492
2479
|
return ['alt', getMetaInfo(this, grammarInterval)].concat(
|
|
2493
2480
|
this.terms.map(term => term.outputRecipe(formals, grammarInterval))
|
|
2494
2481
|
);
|
|
2495
2482
|
};
|
|
2496
2483
|
|
|
2497
|
-
pexprs$
|
|
2484
|
+
pexprs$e.Extend.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2498
2485
|
const extension = this.terms[0]; // [extension, original]
|
|
2499
2486
|
return extension.outputRecipe(formals, grammarInterval);
|
|
2500
2487
|
};
|
|
2501
2488
|
|
|
2502
|
-
pexprs$
|
|
2489
|
+
pexprs$e.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2503
2490
|
const beforeTerms = this.terms.slice(0, this.expansionPos);
|
|
2504
2491
|
const afterTerms = this.terms.slice(this.expansionPos + 1);
|
|
2505
2492
|
return [
|
|
@@ -2510,18 +2497,18 @@ pexprs$f.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2510
2497
|
];
|
|
2511
2498
|
};
|
|
2512
2499
|
|
|
2513
|
-
pexprs$
|
|
2500
|
+
pexprs$e.Seq.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2514
2501
|
return ['seq', getMetaInfo(this, grammarInterval)].concat(
|
|
2515
2502
|
this.factors.map(factor => factor.outputRecipe(formals, grammarInterval))
|
|
2516
2503
|
);
|
|
2517
2504
|
};
|
|
2518
2505
|
|
|
2519
|
-
pexprs$
|
|
2520
|
-
pexprs$
|
|
2521
|
-
pexprs$
|
|
2522
|
-
pexprs$
|
|
2523
|
-
pexprs$
|
|
2524
|
-
pexprs$
|
|
2506
|
+
pexprs$e.Star.prototype.outputRecipe =
|
|
2507
|
+
pexprs$e.Plus.prototype.outputRecipe =
|
|
2508
|
+
pexprs$e.Opt.prototype.outputRecipe =
|
|
2509
|
+
pexprs$e.Not.prototype.outputRecipe =
|
|
2510
|
+
pexprs$e.Lookahead.prototype.outputRecipe =
|
|
2511
|
+
pexprs$e.Lex.prototype.outputRecipe =
|
|
2525
2512
|
function(formals, grammarInterval) {
|
|
2526
2513
|
return [
|
|
2527
2514
|
this.constructor.name.toLowerCase(),
|
|
@@ -2530,7 +2517,7 @@ pexprs$f.Star.prototype.outputRecipe =
|
|
|
2530
2517
|
];
|
|
2531
2518
|
};
|
|
2532
2519
|
|
|
2533
|
-
pexprs$
|
|
2520
|
+
pexprs$e.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2534
2521
|
return [
|
|
2535
2522
|
'app',
|
|
2536
2523
|
getMetaInfo(this, grammarInterval),
|
|
@@ -2539,7 +2526,7 @@ pexprs$f.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2539
2526
|
];
|
|
2540
2527
|
};
|
|
2541
2528
|
|
|
2542
|
-
pexprs$
|
|
2529
|
+
pexprs$e.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2543
2530
|
return ['unicodeChar', getMetaInfo(this, grammarInterval), this.category];
|
|
2544
2531
|
};
|
|
2545
2532
|
|
|
@@ -2548,7 +2535,7 @@ pexprs$f.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval)
|
|
|
2548
2535
|
// --------------------------------------------------------------------
|
|
2549
2536
|
|
|
2550
2537
|
const common$b = common$l;
|
|
2551
|
-
const pexprs$
|
|
2538
|
+
const pexprs$d = pexprsMain;
|
|
2552
2539
|
|
|
2553
2540
|
// --------------------------------------------------------------------
|
|
2554
2541
|
// Operations
|
|
@@ -2559,49 +2546,49 @@ const pexprs$e = pexprsMain;
|
|
|
2559
2546
|
parameter with a `Param` node. Returns a PExpr -- either a new one, or the original one if
|
|
2560
2547
|
it was modified in place.
|
|
2561
2548
|
*/
|
|
2562
|
-
pexprs$
|
|
2563
|
-
|
|
2564
|
-
pexprs$
|
|
2565
|
-
pexprs$
|
|
2566
|
-
pexprs$
|
|
2567
|
-
pexprs$
|
|
2568
|
-
pexprs$
|
|
2569
|
-
pexprs$
|
|
2549
|
+
pexprs$d.PExpr.prototype.introduceParams = common$b.abstract('introduceParams');
|
|
2550
|
+
|
|
2551
|
+
pexprs$d.any.introduceParams =
|
|
2552
|
+
pexprs$d.end.introduceParams =
|
|
2553
|
+
pexprs$d.Terminal.prototype.introduceParams =
|
|
2554
|
+
pexprs$d.Range.prototype.introduceParams =
|
|
2555
|
+
pexprs$d.Param.prototype.introduceParams =
|
|
2556
|
+
pexprs$d.UnicodeChar.prototype.introduceParams =
|
|
2570
2557
|
function(formals) {
|
|
2571
2558
|
return this;
|
|
2572
2559
|
};
|
|
2573
2560
|
|
|
2574
|
-
pexprs$
|
|
2561
|
+
pexprs$d.Alt.prototype.introduceParams = function(formals) {
|
|
2575
2562
|
this.terms.forEach((term, idx, terms) => {
|
|
2576
2563
|
terms[idx] = term.introduceParams(formals);
|
|
2577
2564
|
});
|
|
2578
2565
|
return this;
|
|
2579
2566
|
};
|
|
2580
2567
|
|
|
2581
|
-
pexprs$
|
|
2568
|
+
pexprs$d.Seq.prototype.introduceParams = function(formals) {
|
|
2582
2569
|
this.factors.forEach((factor, idx, factors) => {
|
|
2583
2570
|
factors[idx] = factor.introduceParams(formals);
|
|
2584
2571
|
});
|
|
2585
2572
|
return this;
|
|
2586
2573
|
};
|
|
2587
2574
|
|
|
2588
|
-
pexprs$
|
|
2589
|
-
pexprs$
|
|
2590
|
-
pexprs$
|
|
2591
|
-
pexprs$
|
|
2575
|
+
pexprs$d.Iter.prototype.introduceParams =
|
|
2576
|
+
pexprs$d.Not.prototype.introduceParams =
|
|
2577
|
+
pexprs$d.Lookahead.prototype.introduceParams =
|
|
2578
|
+
pexprs$d.Lex.prototype.introduceParams =
|
|
2592
2579
|
function(formals) {
|
|
2593
2580
|
this.expr = this.expr.introduceParams(formals);
|
|
2594
2581
|
return this;
|
|
2595
2582
|
};
|
|
2596
2583
|
|
|
2597
|
-
pexprs$
|
|
2584
|
+
pexprs$d.Apply.prototype.introduceParams = function(formals) {
|
|
2598
2585
|
const index = formals.indexOf(this.ruleName);
|
|
2599
2586
|
if (index >= 0) {
|
|
2600
2587
|
if (this.args.length > 0) {
|
|
2601
2588
|
// TODO: Should this be supported? See issue #64.
|
|
2602
2589
|
throw new Error('Parameterized rules cannot be passed as arguments to another rule.');
|
|
2603
2590
|
}
|
|
2604
|
-
return new pexprs$
|
|
2591
|
+
return new pexprs$d.Param(index).withSource(this.source);
|
|
2605
2592
|
} else {
|
|
2606
2593
|
this.args.forEach((arg, idx, args) => {
|
|
2607
2594
|
args[idx] = arg.introduceParams(formals);
|
|
@@ -2615,33 +2602,33 @@ pexprs$e.Apply.prototype.introduceParams = function(formals) {
|
|
|
2615
2602
|
// --------------------------------------------------------------------
|
|
2616
2603
|
|
|
2617
2604
|
const common$a = common$l;
|
|
2618
|
-
const pexprs$
|
|
2605
|
+
const pexprs$c = pexprsMain;
|
|
2619
2606
|
|
|
2620
2607
|
// --------------------------------------------------------------------
|
|
2621
2608
|
// Operations
|
|
2622
2609
|
// --------------------------------------------------------------------
|
|
2623
2610
|
|
|
2624
2611
|
// Returns `true` if this parsing expression may accept without consuming any input.
|
|
2625
|
-
pexprs$
|
|
2612
|
+
pexprs$c.PExpr.prototype.isNullable = function(grammar) {
|
|
2626
2613
|
return this._isNullable(grammar, Object.create(null));
|
|
2627
2614
|
};
|
|
2628
2615
|
|
|
2629
|
-
pexprs$
|
|
2616
|
+
pexprs$c.PExpr.prototype._isNullable = common$a.abstract('_isNullable');
|
|
2630
2617
|
|
|
2631
|
-
pexprs$
|
|
2632
|
-
pexprs$
|
|
2633
|
-
pexprs$
|
|
2634
|
-
pexprs$
|
|
2635
|
-
pexprs$
|
|
2618
|
+
pexprs$c.any._isNullable =
|
|
2619
|
+
pexprs$c.Range.prototype._isNullable =
|
|
2620
|
+
pexprs$c.Param.prototype._isNullable =
|
|
2621
|
+
pexprs$c.Plus.prototype._isNullable =
|
|
2622
|
+
pexprs$c.UnicodeChar.prototype._isNullable =
|
|
2636
2623
|
function(grammar, memo) {
|
|
2637
2624
|
return false;
|
|
2638
2625
|
};
|
|
2639
2626
|
|
|
2640
|
-
pexprs$
|
|
2627
|
+
pexprs$c.end._isNullable = function(grammar, memo) {
|
|
2641
2628
|
return true;
|
|
2642
2629
|
};
|
|
2643
2630
|
|
|
2644
|
-
pexprs$
|
|
2631
|
+
pexprs$c.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
2645
2632
|
if (typeof this.obj === 'string') {
|
|
2646
2633
|
// This is an over-simplification: it's only correct if the input is a string. If it's an array
|
|
2647
2634
|
// or an object, then the empty string parsing expression is not nullable.
|
|
@@ -2651,27 +2638,27 @@ pexprs$d.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
|
2651
2638
|
}
|
|
2652
2639
|
};
|
|
2653
2640
|
|
|
2654
|
-
pexprs$
|
|
2641
|
+
pexprs$c.Alt.prototype._isNullable = function(grammar, memo) {
|
|
2655
2642
|
return this.terms.length === 0 || this.terms.some(term => term._isNullable(grammar, memo));
|
|
2656
2643
|
};
|
|
2657
2644
|
|
|
2658
|
-
pexprs$
|
|
2645
|
+
pexprs$c.Seq.prototype._isNullable = function(grammar, memo) {
|
|
2659
2646
|
return this.factors.every(factor => factor._isNullable(grammar, memo));
|
|
2660
2647
|
};
|
|
2661
2648
|
|
|
2662
|
-
pexprs$
|
|
2663
|
-
pexprs$
|
|
2664
|
-
pexprs$
|
|
2665
|
-
pexprs$
|
|
2649
|
+
pexprs$c.Star.prototype._isNullable =
|
|
2650
|
+
pexprs$c.Opt.prototype._isNullable =
|
|
2651
|
+
pexprs$c.Not.prototype._isNullable =
|
|
2652
|
+
pexprs$c.Lookahead.prototype._isNullable =
|
|
2666
2653
|
function(grammar, memo) {
|
|
2667
2654
|
return true;
|
|
2668
2655
|
};
|
|
2669
2656
|
|
|
2670
|
-
pexprs$
|
|
2657
|
+
pexprs$c.Lex.prototype._isNullable = function(grammar, memo) {
|
|
2671
2658
|
return this.expr._isNullable(grammar, memo);
|
|
2672
2659
|
};
|
|
2673
2660
|
|
|
2674
|
-
pexprs$
|
|
2661
|
+
pexprs$c.Apply.prototype._isNullable = function(grammar, memo) {
|
|
2675
2662
|
const key = this.toMemoKey();
|
|
2676
2663
|
if (!Object.prototype.hasOwnProperty.call(memo, key)) {
|
|
2677
2664
|
const {body} = grammar.rules[this.ruleName];
|
|
@@ -2687,7 +2674,7 @@ pexprs$d.Apply.prototype._isNullable = function(grammar, memo) {
|
|
|
2687
2674
|
// --------------------------------------------------------------------
|
|
2688
2675
|
|
|
2689
2676
|
const common$9 = common$l;
|
|
2690
|
-
const pexprs$
|
|
2677
|
+
const pexprs$b = pexprsMain;
|
|
2691
2678
|
|
|
2692
2679
|
// --------------------------------------------------------------------
|
|
2693
2680
|
// Operations
|
|
@@ -2700,44 +2687,44 @@ const pexprs$c = pexprsMain;
|
|
|
2700
2687
|
The receiver must not be modified; a new PExpr must be returned if any replacement is necessary.
|
|
2701
2688
|
*/
|
|
2702
2689
|
// function(actuals) { ... }
|
|
2703
|
-
pexprs$
|
|
2690
|
+
pexprs$b.PExpr.prototype.substituteParams = common$9.abstract('substituteParams');
|
|
2704
2691
|
|
|
2705
|
-
pexprs$
|
|
2706
|
-
pexprs$
|
|
2707
|
-
pexprs$
|
|
2708
|
-
pexprs$
|
|
2709
|
-
pexprs$
|
|
2692
|
+
pexprs$b.any.substituteParams =
|
|
2693
|
+
pexprs$b.end.substituteParams =
|
|
2694
|
+
pexprs$b.Terminal.prototype.substituteParams =
|
|
2695
|
+
pexprs$b.Range.prototype.substituteParams =
|
|
2696
|
+
pexprs$b.UnicodeChar.prototype.substituteParams =
|
|
2710
2697
|
function(actuals) {
|
|
2711
2698
|
return this;
|
|
2712
2699
|
};
|
|
2713
2700
|
|
|
2714
|
-
pexprs$
|
|
2701
|
+
pexprs$b.Param.prototype.substituteParams = function(actuals) {
|
|
2715
2702
|
return actuals[this.index];
|
|
2716
2703
|
};
|
|
2717
2704
|
|
|
2718
|
-
pexprs$
|
|
2719
|
-
return new pexprs$
|
|
2705
|
+
pexprs$b.Alt.prototype.substituteParams = function(actuals) {
|
|
2706
|
+
return new pexprs$b.Alt(this.terms.map(term => term.substituteParams(actuals)));
|
|
2720
2707
|
};
|
|
2721
2708
|
|
|
2722
|
-
pexprs$
|
|
2723
|
-
return new pexprs$
|
|
2709
|
+
pexprs$b.Seq.prototype.substituteParams = function(actuals) {
|
|
2710
|
+
return new pexprs$b.Seq(this.factors.map(factor => factor.substituteParams(actuals)));
|
|
2724
2711
|
};
|
|
2725
2712
|
|
|
2726
|
-
pexprs$
|
|
2727
|
-
pexprs$
|
|
2728
|
-
pexprs$
|
|
2729
|
-
pexprs$
|
|
2713
|
+
pexprs$b.Iter.prototype.substituteParams =
|
|
2714
|
+
pexprs$b.Not.prototype.substituteParams =
|
|
2715
|
+
pexprs$b.Lookahead.prototype.substituteParams =
|
|
2716
|
+
pexprs$b.Lex.prototype.substituteParams =
|
|
2730
2717
|
function(actuals) {
|
|
2731
2718
|
return new this.constructor(this.expr.substituteParams(actuals));
|
|
2732
2719
|
};
|
|
2733
2720
|
|
|
2734
|
-
pexprs$
|
|
2721
|
+
pexprs$b.Apply.prototype.substituteParams = function(actuals) {
|
|
2735
2722
|
if (this.args.length === 0) {
|
|
2736
2723
|
// Avoid making a copy of this application, as an optimization
|
|
2737
2724
|
return this;
|
|
2738
2725
|
} else {
|
|
2739
2726
|
const args = this.args.map(arg => arg.substituteParams(actuals));
|
|
2740
|
-
return new pexprs$
|
|
2727
|
+
return new pexprs$b.Apply(this.ruleName, args);
|
|
2741
2728
|
}
|
|
2742
2729
|
};
|
|
2743
2730
|
|
|
@@ -2746,7 +2733,7 @@ pexprs$c.Apply.prototype.substituteParams = function(actuals) {
|
|
|
2746
2733
|
// --------------------------------------------------------------------
|
|
2747
2734
|
|
|
2748
2735
|
const common$8 = common$l;
|
|
2749
|
-
const pexprs$
|
|
2736
|
+
const pexprs$a = pexprsMain;
|
|
2750
2737
|
|
|
2751
2738
|
const {copyWithoutDuplicates} = common$8;
|
|
2752
2739
|
|
|
@@ -2812,17 +2799,17 @@ function resolveDuplicatedNames(argumentNameList) {
|
|
|
2812
2799
|
* e.getArity() === e.toArgumentNameList(1).length
|
|
2813
2800
|
*/
|
|
2814
2801
|
// function(firstArgIndex, noDupCheck) { ... }
|
|
2815
|
-
pexprs$
|
|
2802
|
+
pexprs$a.PExpr.prototype.toArgumentNameList = common$8.abstract('toArgumentNameList');
|
|
2816
2803
|
|
|
2817
|
-
pexprs$
|
|
2804
|
+
pexprs$a.any.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2818
2805
|
return ['any'];
|
|
2819
2806
|
};
|
|
2820
2807
|
|
|
2821
|
-
pexprs$
|
|
2808
|
+
pexprs$a.end.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2822
2809
|
return ['end'];
|
|
2823
2810
|
};
|
|
2824
2811
|
|
|
2825
|
-
pexprs$
|
|
2812
|
+
pexprs$a.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2826
2813
|
if (typeof this.obj === 'string' && /^[_a-zA-Z0-9]+$/.test(this.obj)) {
|
|
2827
2814
|
// If this terminal is a valid suffix for a JS identifier, just prepend it with '_'
|
|
2828
2815
|
return ['_' + this.obj];
|
|
@@ -2832,7 +2819,7 @@ pexprs$b.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCh
|
|
|
2832
2819
|
}
|
|
2833
2820
|
};
|
|
2834
2821
|
|
|
2835
|
-
pexprs$
|
|
2822
|
+
pexprs$a.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2836
2823
|
let argName = this.from + '_to_' + this.to;
|
|
2837
2824
|
// If the `argName` is not valid then try to prepend a `_`.
|
|
2838
2825
|
if (!isRestrictedJSIdentifier(argName)) {
|
|
@@ -2845,7 +2832,7 @@ pexprs$b.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2845
2832
|
return [argName];
|
|
2846
2833
|
};
|
|
2847
2834
|
|
|
2848
|
-
pexprs$
|
|
2835
|
+
pexprs$a.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2849
2836
|
// `termArgNameLists` is an array of arrays where each row is the
|
|
2850
2837
|
// argument name list that corresponds to a term in this alternation.
|
|
2851
2838
|
const termArgNameLists = this.terms.map(term =>
|
|
@@ -2869,7 +2856,7 @@ pexprs$b.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2869
2856
|
return argumentNameList;
|
|
2870
2857
|
};
|
|
2871
2858
|
|
|
2872
|
-
pexprs$
|
|
2859
|
+
pexprs$a.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2873
2860
|
// Generate the argument name list, without worrying about duplicates.
|
|
2874
2861
|
let argumentNameList = [];
|
|
2875
2862
|
this.factors.forEach(factor => {
|
|
@@ -2885,7 +2872,7 @@ pexprs$b.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2885
2872
|
return argumentNameList;
|
|
2886
2873
|
};
|
|
2887
2874
|
|
|
2888
|
-
pexprs$
|
|
2875
|
+
pexprs$a.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2889
2876
|
const argumentNameList = this.expr
|
|
2890
2877
|
.toArgumentNameList(firstArgIndex, noDupCheck)
|
|
2891
2878
|
.map(exprArgumentString =>
|
|
@@ -2899,30 +2886,30 @@ pexprs$b.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2899
2886
|
return argumentNameList;
|
|
2900
2887
|
};
|
|
2901
2888
|
|
|
2902
|
-
pexprs$
|
|
2889
|
+
pexprs$a.Opt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2903
2890
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck).map(argName => {
|
|
2904
2891
|
return 'opt' + argName[0].toUpperCase() + argName.slice(1);
|
|
2905
2892
|
});
|
|
2906
2893
|
};
|
|
2907
2894
|
|
|
2908
|
-
pexprs$
|
|
2895
|
+
pexprs$a.Not.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2909
2896
|
return [];
|
|
2910
2897
|
};
|
|
2911
2898
|
|
|
2912
|
-
pexprs$
|
|
2899
|
+
pexprs$a.Lookahead.prototype.toArgumentNameList = pexprs$a.Lex.prototype.toArgumentNameList =
|
|
2913
2900
|
function(firstArgIndex, noDupCheck) {
|
|
2914
2901
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck);
|
|
2915
2902
|
};
|
|
2916
2903
|
|
|
2917
|
-
pexprs$
|
|
2904
|
+
pexprs$a.Apply.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2918
2905
|
return [this.ruleName];
|
|
2919
2906
|
};
|
|
2920
2907
|
|
|
2921
|
-
pexprs$
|
|
2908
|
+
pexprs$a.UnicodeChar.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2922
2909
|
return ['$' + firstArgIndex];
|
|
2923
2910
|
};
|
|
2924
2911
|
|
|
2925
|
-
pexprs$
|
|
2912
|
+
pexprs$a.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2926
2913
|
return ['param' + this.index];
|
|
2927
2914
|
};
|
|
2928
2915
|
|
|
@@ -2931,36 +2918,36 @@ pexprs$b.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2931
2918
|
// --------------------------------------------------------------------
|
|
2932
2919
|
|
|
2933
2920
|
const common$7 = common$l;
|
|
2934
|
-
const pexprs$
|
|
2921
|
+
const pexprs$9 = pexprsMain;
|
|
2935
2922
|
|
|
2936
2923
|
// --------------------------------------------------------------------
|
|
2937
2924
|
// Operations
|
|
2938
2925
|
// --------------------------------------------------------------------
|
|
2939
2926
|
|
|
2940
2927
|
// Returns a string representing the PExpr, for use as a UI label, etc.
|
|
2941
|
-
pexprs$
|
|
2928
|
+
pexprs$9.PExpr.prototype.toDisplayString = common$7.abstract('toDisplayString');
|
|
2942
2929
|
|
|
2943
|
-
pexprs$
|
|
2930
|
+
pexprs$9.Alt.prototype.toDisplayString = pexprs$9.Seq.prototype.toDisplayString = function() {
|
|
2944
2931
|
if (this.source) {
|
|
2945
2932
|
return this.source.trimmed().contents;
|
|
2946
2933
|
}
|
|
2947
2934
|
return '[' + this.constructor.name + ']';
|
|
2948
2935
|
};
|
|
2949
2936
|
|
|
2950
|
-
pexprs$
|
|
2951
|
-
pexprs$
|
|
2952
|
-
pexprs$
|
|
2953
|
-
pexprs$
|
|
2954
|
-
pexprs$
|
|
2955
|
-
pexprs$
|
|
2956
|
-
pexprs$
|
|
2957
|
-
pexprs$
|
|
2958
|
-
pexprs$
|
|
2937
|
+
pexprs$9.any.toDisplayString =
|
|
2938
|
+
pexprs$9.end.toDisplayString =
|
|
2939
|
+
pexprs$9.Iter.prototype.toDisplayString =
|
|
2940
|
+
pexprs$9.Not.prototype.toDisplayString =
|
|
2941
|
+
pexprs$9.Lookahead.prototype.toDisplayString =
|
|
2942
|
+
pexprs$9.Lex.prototype.toDisplayString =
|
|
2943
|
+
pexprs$9.Terminal.prototype.toDisplayString =
|
|
2944
|
+
pexprs$9.Range.prototype.toDisplayString =
|
|
2945
|
+
pexprs$9.Param.prototype.toDisplayString =
|
|
2959
2946
|
function() {
|
|
2960
2947
|
return this.toString();
|
|
2961
2948
|
};
|
|
2962
2949
|
|
|
2963
|
-
pexprs$
|
|
2950
|
+
pexprs$9.Apply.prototype.toDisplayString = function() {
|
|
2964
2951
|
if (this.args.length > 0) {
|
|
2965
2952
|
const ps = this.args.map(arg => arg.toDisplayString());
|
|
2966
2953
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -2969,7 +2956,7 @@ pexprs$a.Apply.prototype.toDisplayString = function() {
|
|
|
2969
2956
|
}
|
|
2970
2957
|
};
|
|
2971
2958
|
|
|
2972
|
-
pexprs$
|
|
2959
|
+
pexprs$9.UnicodeChar.prototype.toDisplayString = function() {
|
|
2973
2960
|
return 'Unicode [' + this.category + '] character';
|
|
2974
2961
|
};
|
|
2975
2962
|
|
|
@@ -2979,42 +2966,42 @@ pexprs$a.UnicodeChar.prototype.toDisplayString = function() {
|
|
|
2979
2966
|
|
|
2980
2967
|
const Failure$1 = Failure_1;
|
|
2981
2968
|
const common$6 = common$l;
|
|
2982
|
-
const pexprs$
|
|
2969
|
+
const pexprs$8 = pexprsMain;
|
|
2983
2970
|
|
|
2984
2971
|
// --------------------------------------------------------------------
|
|
2985
2972
|
// Operations
|
|
2986
2973
|
// --------------------------------------------------------------------
|
|
2987
2974
|
|
|
2988
|
-
pexprs$
|
|
2975
|
+
pexprs$8.PExpr.prototype.toFailure = common$6.abstract('toFailure');
|
|
2989
2976
|
|
|
2990
|
-
pexprs$
|
|
2977
|
+
pexprs$8.any.toFailure = function(grammar) {
|
|
2991
2978
|
return new Failure$1(this, 'any object', 'description');
|
|
2992
2979
|
};
|
|
2993
2980
|
|
|
2994
|
-
pexprs$
|
|
2981
|
+
pexprs$8.end.toFailure = function(grammar) {
|
|
2995
2982
|
return new Failure$1(this, 'end of input', 'description');
|
|
2996
2983
|
};
|
|
2997
2984
|
|
|
2998
|
-
pexprs$
|
|
2985
|
+
pexprs$8.Terminal.prototype.toFailure = function(grammar) {
|
|
2999
2986
|
return new Failure$1(this, this.obj, 'string');
|
|
3000
2987
|
};
|
|
3001
2988
|
|
|
3002
|
-
pexprs$
|
|
2989
|
+
pexprs$8.Range.prototype.toFailure = function(grammar) {
|
|
3003
2990
|
// TODO: come up with something better
|
|
3004
2991
|
return new Failure$1(this, JSON.stringify(this.from) + '..' + JSON.stringify(this.to), 'code');
|
|
3005
2992
|
};
|
|
3006
2993
|
|
|
3007
|
-
pexprs$
|
|
2994
|
+
pexprs$8.Not.prototype.toFailure = function(grammar) {
|
|
3008
2995
|
const description =
|
|
3009
|
-
this.expr === pexprs$
|
|
2996
|
+
this.expr === pexprs$8.any ? 'nothing' : 'not ' + this.expr.toFailure(grammar);
|
|
3010
2997
|
return new Failure$1(this, description, 'description');
|
|
3011
2998
|
};
|
|
3012
2999
|
|
|
3013
|
-
pexprs$
|
|
3000
|
+
pexprs$8.Lookahead.prototype.toFailure = function(grammar) {
|
|
3014
3001
|
return this.expr.toFailure(grammar);
|
|
3015
3002
|
};
|
|
3016
3003
|
|
|
3017
|
-
pexprs$
|
|
3004
|
+
pexprs$8.Apply.prototype.toFailure = function(grammar) {
|
|
3018
3005
|
let {description} = grammar.rules[this.ruleName];
|
|
3019
3006
|
if (!description) {
|
|
3020
3007
|
const article = /^[aeiouAEIOU]/.test(this.ruleName) ? 'an' : 'a';
|
|
@@ -3023,23 +3010,23 @@ pexprs$9.Apply.prototype.toFailure = function(grammar) {
|
|
|
3023
3010
|
return new Failure$1(this, description, 'description');
|
|
3024
3011
|
};
|
|
3025
3012
|
|
|
3026
|
-
pexprs$
|
|
3013
|
+
pexprs$8.UnicodeChar.prototype.toFailure = function(grammar) {
|
|
3027
3014
|
return new Failure$1(this, 'a Unicode [' + this.category + '] character', 'description');
|
|
3028
3015
|
};
|
|
3029
3016
|
|
|
3030
|
-
pexprs$
|
|
3017
|
+
pexprs$8.Alt.prototype.toFailure = function(grammar) {
|
|
3031
3018
|
const fs = this.terms.map(t => t.toFailure(grammar));
|
|
3032
3019
|
const description = '(' + fs.join(' or ') + ')';
|
|
3033
3020
|
return new Failure$1(this, description, 'description');
|
|
3034
3021
|
};
|
|
3035
3022
|
|
|
3036
|
-
pexprs$
|
|
3023
|
+
pexprs$8.Seq.prototype.toFailure = function(grammar) {
|
|
3037
3024
|
const fs = this.factors.map(f => f.toFailure(grammar));
|
|
3038
3025
|
const description = '(' + fs.join(' ') + ')';
|
|
3039
3026
|
return new Failure$1(this, description, 'description');
|
|
3040
3027
|
};
|
|
3041
3028
|
|
|
3042
|
-
pexprs$
|
|
3029
|
+
pexprs$8.Iter.prototype.toFailure = function(grammar) {
|
|
3043
3030
|
const description = '(' + this.expr.toFailure(grammar) + this.operator + ')';
|
|
3044
3031
|
return new Failure$1(this, description, 'description');
|
|
3045
3032
|
};
|
|
@@ -3049,7 +3036,7 @@ pexprs$9.Iter.prototype.toFailure = function(grammar) {
|
|
|
3049
3036
|
// --------------------------------------------------------------------
|
|
3050
3037
|
|
|
3051
3038
|
const common$5 = common$l;
|
|
3052
|
-
const pexprs$
|
|
3039
|
+
const pexprs$7 = pexprsMain;
|
|
3053
3040
|
|
|
3054
3041
|
// --------------------------------------------------------------------
|
|
3055
3042
|
// Operations
|
|
@@ -3062,57 +3049,57 @@ const pexprs$8 = pexprsMain;
|
|
|
3062
3049
|
~"b" "a" and "a" are interchangeable in any grammar,
|
|
3063
3050
|
both in terms of the languages they accept and their arities.
|
|
3064
3051
|
*/
|
|
3065
|
-
pexprs$
|
|
3052
|
+
pexprs$7.PExpr.prototype.toString = common$5.abstract('toString');
|
|
3066
3053
|
|
|
3067
|
-
pexprs$
|
|
3054
|
+
pexprs$7.any.toString = function() {
|
|
3068
3055
|
return 'any';
|
|
3069
3056
|
};
|
|
3070
3057
|
|
|
3071
|
-
pexprs$
|
|
3058
|
+
pexprs$7.end.toString = function() {
|
|
3072
3059
|
return 'end';
|
|
3073
3060
|
};
|
|
3074
3061
|
|
|
3075
|
-
pexprs$
|
|
3062
|
+
pexprs$7.Terminal.prototype.toString = function() {
|
|
3076
3063
|
return JSON.stringify(this.obj);
|
|
3077
3064
|
};
|
|
3078
3065
|
|
|
3079
|
-
pexprs$
|
|
3066
|
+
pexprs$7.Range.prototype.toString = function() {
|
|
3080
3067
|
return JSON.stringify(this.from) + '..' + JSON.stringify(this.to);
|
|
3081
3068
|
};
|
|
3082
3069
|
|
|
3083
|
-
pexprs$
|
|
3070
|
+
pexprs$7.Param.prototype.toString = function() {
|
|
3084
3071
|
return '$' + this.index;
|
|
3085
3072
|
};
|
|
3086
3073
|
|
|
3087
|
-
pexprs$
|
|
3074
|
+
pexprs$7.Lex.prototype.toString = function() {
|
|
3088
3075
|
return '#(' + this.expr.toString() + ')';
|
|
3089
3076
|
};
|
|
3090
3077
|
|
|
3091
|
-
pexprs$
|
|
3078
|
+
pexprs$7.Alt.prototype.toString = function() {
|
|
3092
3079
|
return this.terms.length === 1 ?
|
|
3093
3080
|
this.terms[0].toString() :
|
|
3094
3081
|
'(' + this.terms.map(term => term.toString()).join(' | ') + ')';
|
|
3095
3082
|
};
|
|
3096
3083
|
|
|
3097
|
-
pexprs$
|
|
3084
|
+
pexprs$7.Seq.prototype.toString = function() {
|
|
3098
3085
|
return this.factors.length === 1 ?
|
|
3099
3086
|
this.factors[0].toString() :
|
|
3100
3087
|
'(' + this.factors.map(factor => factor.toString()).join(' ') + ')';
|
|
3101
3088
|
};
|
|
3102
3089
|
|
|
3103
|
-
pexprs$
|
|
3090
|
+
pexprs$7.Iter.prototype.toString = function() {
|
|
3104
3091
|
return this.expr + this.operator;
|
|
3105
3092
|
};
|
|
3106
3093
|
|
|
3107
|
-
pexprs$
|
|
3094
|
+
pexprs$7.Not.prototype.toString = function() {
|
|
3108
3095
|
return '~' + this.expr;
|
|
3109
3096
|
};
|
|
3110
3097
|
|
|
3111
|
-
pexprs$
|
|
3098
|
+
pexprs$7.Lookahead.prototype.toString = function() {
|
|
3112
3099
|
return '&' + this.expr;
|
|
3113
3100
|
};
|
|
3114
3101
|
|
|
3115
|
-
pexprs$
|
|
3102
|
+
pexprs$7.Apply.prototype.toString = function() {
|
|
3116
3103
|
if (this.args.length > 0) {
|
|
3117
3104
|
const ps = this.args.map(arg => arg.toString());
|
|
3118
3105
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -3121,7 +3108,7 @@ pexprs$8.Apply.prototype.toString = function() {
|
|
|
3121
3108
|
}
|
|
3122
3109
|
};
|
|
3123
3110
|
|
|
3124
|
-
pexprs$
|
|
3111
|
+
pexprs$7.UnicodeChar.prototype.toString = function() {
|
|
3125
3112
|
return '\\p{' + this.category + '}';
|
|
3126
3113
|
};
|
|
3127
3114
|
|
|
@@ -3129,7 +3116,7 @@ pexprs$8.UnicodeChar.prototype.toString = function() {
|
|
|
3129
3116
|
// Re-export classes
|
|
3130
3117
|
// --------------------------------------------------------------------
|
|
3131
3118
|
|
|
3132
|
-
var pexprs$
|
|
3119
|
+
var pexprs$6 = pexprsMain;
|
|
3133
3120
|
|
|
3134
3121
|
// --------------------------------------------------------------------
|
|
3135
3122
|
// Imports
|
|
@@ -3138,7 +3125,7 @@ var pexprs$7 = pexprsMain;
|
|
|
3138
3125
|
const Failure = Failure_1;
|
|
3139
3126
|
const {TerminalNode} = nodes$1;
|
|
3140
3127
|
const {assert: assert$1} = common$l;
|
|
3141
|
-
const {PExpr, Terminal} = pexprs$
|
|
3128
|
+
const {PExpr, Terminal} = pexprs$6;
|
|
3142
3129
|
|
|
3143
3130
|
class CaseInsensitiveTerminal$1 extends PExpr {
|
|
3144
3131
|
constructor(param) {
|
|
@@ -3166,7 +3153,7 @@ class CaseInsensitiveTerminal$1 extends PExpr {
|
|
|
3166
3153
|
state.processFailure(origPos, this);
|
|
3167
3154
|
return false;
|
|
3168
3155
|
} else {
|
|
3169
|
-
state.pushBinding(new TerminalNode(
|
|
3156
|
+
state.pushBinding(new TerminalNode(matchStr.length), origPos);
|
|
3170
3157
|
return true;
|
|
3171
3158
|
}
|
|
3172
3159
|
}
|
|
@@ -3227,7 +3214,12 @@ InputStream$3.prototype = {
|
|
|
3227
3214
|
return ans;
|
|
3228
3215
|
},
|
|
3229
3216
|
|
|
3230
|
-
|
|
3217
|
+
nextCharCode() {
|
|
3218
|
+
const nextChar = this.next();
|
|
3219
|
+
return nextChar && nextChar.charCodeAt(0);
|
|
3220
|
+
},
|
|
3221
|
+
|
|
3222
|
+
nextCodePoint() {
|
|
3231
3223
|
const cp = this.source.slice(this.pos++).codePointAt(0);
|
|
3232
3224
|
// If the code point is beyond plane 0, it takes up two characters.
|
|
3233
3225
|
if (cp > 0xffff) {
|
|
@@ -3293,7 +3285,7 @@ const Interval = Interval_1;
|
|
|
3293
3285
|
// Private stuff
|
|
3294
3286
|
// --------------------------------------------------------------------
|
|
3295
3287
|
|
|
3296
|
-
function MatchResult$
|
|
3288
|
+
function MatchResult$2(
|
|
3297
3289
|
matcher,
|
|
3298
3290
|
input,
|
|
3299
3291
|
startExpr,
|
|
@@ -3327,19 +3319,19 @@ function MatchResult$3(
|
|
|
3327
3319
|
}
|
|
3328
3320
|
}
|
|
3329
3321
|
|
|
3330
|
-
MatchResult$
|
|
3322
|
+
MatchResult$2.prototype.succeeded = function() {
|
|
3331
3323
|
return !!this._cst;
|
|
3332
3324
|
};
|
|
3333
3325
|
|
|
3334
|
-
MatchResult$
|
|
3326
|
+
MatchResult$2.prototype.failed = function() {
|
|
3335
3327
|
return !this.succeeded();
|
|
3336
3328
|
};
|
|
3337
3329
|
|
|
3338
|
-
MatchResult$
|
|
3330
|
+
MatchResult$2.prototype.getRightmostFailurePosition = function() {
|
|
3339
3331
|
return this._rightmostFailurePosition;
|
|
3340
3332
|
};
|
|
3341
3333
|
|
|
3342
|
-
MatchResult$
|
|
3334
|
+
MatchResult$2.prototype.getRightmostFailures = function() {
|
|
3343
3335
|
if (!this._rightmostFailures) {
|
|
3344
3336
|
this.matcher.setInput(this.input);
|
|
3345
3337
|
const matchResultWithFailures = this.matcher._match(
|
|
@@ -3352,7 +3344,7 @@ MatchResult$3.prototype.getRightmostFailures = function() {
|
|
|
3352
3344
|
return this._rightmostFailures;
|
|
3353
3345
|
};
|
|
3354
3346
|
|
|
3355
|
-
MatchResult$
|
|
3347
|
+
MatchResult$2.prototype.toString = function() {
|
|
3356
3348
|
return this.succeeded() ?
|
|
3357
3349
|
'[match succeeded]' :
|
|
3358
3350
|
'[match failed at position ' + this.getRightmostFailurePosition() + ']';
|
|
@@ -3360,7 +3352,7 @@ MatchResult$3.prototype.toString = function() {
|
|
|
3360
3352
|
|
|
3361
3353
|
// Return a string summarizing the expected contents of the input stream when
|
|
3362
3354
|
// the match failure occurred.
|
|
3363
|
-
MatchResult$
|
|
3355
|
+
MatchResult$2.prototype.getExpectedText = function() {
|
|
3364
3356
|
if (this.succeeded()) {
|
|
3365
3357
|
throw new Error('cannot get expected text of a successful MatchResult');
|
|
3366
3358
|
}
|
|
@@ -3384,7 +3376,7 @@ MatchResult$3.prototype.getExpectedText = function() {
|
|
|
3384
3376
|
return sb.contents();
|
|
3385
3377
|
};
|
|
3386
3378
|
|
|
3387
|
-
MatchResult$
|
|
3379
|
+
MatchResult$2.prototype.getInterval = function() {
|
|
3388
3380
|
const pos = this.getRightmostFailurePosition();
|
|
3389
3381
|
return new Interval(this.input, pos, pos);
|
|
3390
3382
|
};
|
|
@@ -3393,7 +3385,7 @@ MatchResult$3.prototype.getInterval = function() {
|
|
|
3393
3385
|
// Exports
|
|
3394
3386
|
// --------------------------------------------------------------------
|
|
3395
3387
|
|
|
3396
|
-
var MatchResult_1 = MatchResult$
|
|
3388
|
+
var MatchResult_1 = MatchResult$2;
|
|
3397
3389
|
|
|
3398
3390
|
// --------------------------------------------------------------------
|
|
3399
3391
|
// Private stuff
|
|
@@ -3513,10 +3505,10 @@ var PosInfo_1 = PosInfo$1;
|
|
|
3513
3505
|
// --------------------------------------------------------------------
|
|
3514
3506
|
|
|
3515
3507
|
const InputStream$2 = InputStream_1;
|
|
3516
|
-
const MatchResult$
|
|
3508
|
+
const MatchResult$1 = MatchResult_1;
|
|
3517
3509
|
const PosInfo = PosInfo_1;
|
|
3518
3510
|
const Trace = Trace_1;
|
|
3519
|
-
const pexprs$
|
|
3511
|
+
const pexprs$5 = pexprs$6;
|
|
3520
3512
|
const util$3 = util$7;
|
|
3521
3513
|
|
|
3522
3514
|
// --------------------------------------------------------------------
|
|
@@ -3529,7 +3521,7 @@ util$3.awaitBuiltInRules(builtInRules => {
|
|
|
3529
3521
|
builtInApplySyntacticBody = builtInRules.rules.applySyntactic.body;
|
|
3530
3522
|
});
|
|
3531
3523
|
|
|
3532
|
-
const applySpaces = new pexprs$
|
|
3524
|
+
const applySpaces = new pexprs$5.Apply('spaces');
|
|
3533
3525
|
|
|
3534
3526
|
function MatchState$1(matcher, startExpr, optPositionToRecordFailures) {
|
|
3535
3527
|
this.matcher = matcher;
|
|
@@ -3722,7 +3714,7 @@ MatchState$1.prototype = {
|
|
|
3722
3714
|
// Returns the memoized trace entry for `expr` at `pos`, if one exists, `null` otherwise.
|
|
3723
3715
|
getMemoizedTraceEntry(pos, expr) {
|
|
3724
3716
|
const posInfo = this.memoTable[pos];
|
|
3725
|
-
if (posInfo && expr.
|
|
3717
|
+
if (posInfo && expr instanceof pexprs$5.Apply) {
|
|
3726
3718
|
const memoRec = posInfo.memo[expr.toMemoKey()];
|
|
3727
3719
|
if (memoRec && memoRec.traceEntry) {
|
|
3728
3720
|
const entry = memoRec.traceEntry.cloneWithExpr(expr);
|
|
@@ -3735,7 +3727,7 @@ MatchState$1.prototype = {
|
|
|
3735
3727
|
|
|
3736
3728
|
// Returns a new trace entry, with the currently active trace array as its children.
|
|
3737
3729
|
getTraceEntry(pos, expr, succeeded, bindings) {
|
|
3738
|
-
if (expr instanceof pexprs$
|
|
3730
|
+
if (expr instanceof pexprs$5.Apply) {
|
|
3739
3731
|
const app = this.currentApplication();
|
|
3740
3732
|
const actuals = app ? app.args : [];
|
|
3741
3733
|
expr = expr.substituteParams(actuals);
|
|
@@ -3864,11 +3856,15 @@ MatchState$1.prototype = {
|
|
|
3864
3856
|
key => this.recordedFailures[key]
|
|
3865
3857
|
);
|
|
3866
3858
|
}
|
|
3867
|
-
|
|
3859
|
+
const cst = this._bindings[0];
|
|
3860
|
+
if (cst) {
|
|
3861
|
+
cst.grammar = this.grammar;
|
|
3862
|
+
}
|
|
3863
|
+
return new MatchResult$1(
|
|
3868
3864
|
this.matcher,
|
|
3869
3865
|
this.input,
|
|
3870
3866
|
this.startExpr,
|
|
3871
|
-
|
|
3867
|
+
cst,
|
|
3872
3868
|
this._bindingOffsets[0],
|
|
3873
3869
|
this.rightmostFailurePosition,
|
|
3874
3870
|
rightmostFailures
|
|
@@ -3911,7 +3907,7 @@ var MatchState_1 = MatchState$1;
|
|
|
3911
3907
|
|
|
3912
3908
|
const MatchState = MatchState_1;
|
|
3913
3909
|
|
|
3914
|
-
const pexprs$
|
|
3910
|
+
const pexprs$4 = pexprs$6;
|
|
3915
3911
|
|
|
3916
3912
|
// --------------------------------------------------------------------
|
|
3917
3913
|
// Private stuff
|
|
@@ -3995,7 +3991,7 @@ Matcher$1.prototype._getStartExpr = function(optStartApplicationStr) {
|
|
|
3995
3991
|
}
|
|
3996
3992
|
|
|
3997
3993
|
const startApp = this.grammar.parseApplication(applicationStr);
|
|
3998
|
-
return new pexprs$
|
|
3994
|
+
return new pexprs$4.Seq([startApp, pexprs$4.end]);
|
|
3999
3995
|
};
|
|
4000
3996
|
|
|
4001
3997
|
// --------------------------------------------------------------------
|
|
@@ -4010,7 +4006,7 @@ var Matcher_1 = Matcher$1;
|
|
|
4010
4006
|
|
|
4011
4007
|
const InputStream$1 = InputStream_1;
|
|
4012
4008
|
const {IterationNode} = nodes$1;
|
|
4013
|
-
const MatchResult
|
|
4009
|
+
const MatchResult = MatchResult_1;
|
|
4014
4010
|
const common$3 = common$l;
|
|
4015
4011
|
const errors$3 = errors$9;
|
|
4016
4012
|
const util$2 = util$7;
|
|
@@ -4051,11 +4047,6 @@ class Wrapper {
|
|
|
4051
4047
|
return '[semantics wrapper for ' + this._node.grammar.name + ']';
|
|
4052
4048
|
}
|
|
4053
4049
|
|
|
4054
|
-
// This is used by ohm editor to display a node wrapper appropriately.
|
|
4055
|
-
toJSON() {
|
|
4056
|
-
return this.toString();
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
4050
|
_forgetMemoizedResultFor(attributeName) {
|
|
4060
4051
|
// Remove the memoized attribute from the cstNode and all its children.
|
|
4061
4052
|
delete this._node[this._semantics.attributeKeys[attributeName]];
|
|
@@ -4135,7 +4126,7 @@ class Wrapper {
|
|
|
4135
4126
|
const childWrappers = optChildWrappers || [];
|
|
4136
4127
|
|
|
4137
4128
|
const childNodes = childWrappers.map(c => c._node);
|
|
4138
|
-
const iter = new IterationNode(
|
|
4129
|
+
const iter = new IterationNode(childNodes, [], -1, false);
|
|
4139
4130
|
|
|
4140
4131
|
const wrapper = this._semantics.wrap(iter, null, null);
|
|
4141
4132
|
wrapper._childWrappers = childWrappers;
|
|
@@ -4162,18 +4153,6 @@ class Wrapper {
|
|
|
4162
4153
|
return this._node.numChildren();
|
|
4163
4154
|
}
|
|
4164
4155
|
|
|
4165
|
-
// Returns the primitive value of this CST node, if it's a terminal node. Otherwise,
|
|
4166
|
-
// throws an exception.
|
|
4167
|
-
// DEPRECATED: Use `sourceString` instead.
|
|
4168
|
-
get primitiveValue() {
|
|
4169
|
-
if (this.isTerminal()) {
|
|
4170
|
-
return this._node.primitiveValue;
|
|
4171
|
-
}
|
|
4172
|
-
throw new TypeError(
|
|
4173
|
-
"tried to access the 'primitiveValue' attribute of a non-terminal CST node"
|
|
4174
|
-
);
|
|
4175
|
-
}
|
|
4176
|
-
|
|
4177
4156
|
// Returns the contents of the input stream consumed by this CST node.
|
|
4178
4157
|
get sourceString() {
|
|
4179
4158
|
return this.source.contents;
|
|
@@ -4539,7 +4518,7 @@ Semantics$2.createSemantics = function(grammar, optSuperSemantics) {
|
|
|
4539
4518
|
// To enable clients to invoke a semantics like a function, return a function that acts as a proxy
|
|
4540
4519
|
// for `s`, which is the real `Semantics` instance.
|
|
4541
4520
|
const proxy = function ASemantics(matchResult) {
|
|
4542
|
-
if (!(matchResult instanceof MatchResult
|
|
4521
|
+
if (!(matchResult instanceof MatchResult)) {
|
|
4543
4522
|
throw new TypeError(
|
|
4544
4523
|
'Semantics expected a MatchResult, but got ' +
|
|
4545
4524
|
common$3.unexpectedObjToString(matchResult)
|
|
@@ -4723,7 +4702,7 @@ const Matcher = Matcher_1;
|
|
|
4723
4702
|
const Semantics$1 = Semantics_1;
|
|
4724
4703
|
const common$2 = common$l;
|
|
4725
4704
|
const errors$2 = errors$9;
|
|
4726
|
-
const pexprs$
|
|
4705
|
+
const pexprs$3 = pexprs$6;
|
|
4727
4706
|
|
|
4728
4707
|
// --------------------------------------------------------------------
|
|
4729
4708
|
// Private stuff
|
|
@@ -4744,7 +4723,7 @@ function getSortedRuleValues(grammar) {
|
|
|
4744
4723
|
// See https://v8.dev/features/subsume-json for more details.
|
|
4745
4724
|
const jsonToJS = str => str.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
4746
4725
|
|
|
4747
|
-
function Grammar$
|
|
4726
|
+
function Grammar$4(name, superGrammar, rules, optDefaultStartRule) {
|
|
4748
4727
|
this.name = name;
|
|
4749
4728
|
this.superGrammar = superGrammar;
|
|
4750
4729
|
this.rules = rules;
|
|
@@ -4766,12 +4745,12 @@ let ohmGrammar$2;
|
|
|
4766
4745
|
let buildGrammar$1;
|
|
4767
4746
|
|
|
4768
4747
|
// This method is called from main.js once Ohm has loaded.
|
|
4769
|
-
Grammar$
|
|
4748
|
+
Grammar$4.initApplicationParser = function(grammar, builderFn) {
|
|
4770
4749
|
ohmGrammar$2 = grammar;
|
|
4771
4750
|
buildGrammar$1 = builderFn;
|
|
4772
4751
|
};
|
|
4773
4752
|
|
|
4774
|
-
Grammar$
|
|
4753
|
+
Grammar$4.prototype = {
|
|
4775
4754
|
matcher() {
|
|
4776
4755
|
return new Matcher(this);
|
|
4777
4756
|
},
|
|
@@ -4779,7 +4758,7 @@ Grammar$5.prototype = {
|
|
|
4779
4758
|
// Return true if the grammar is a built-in grammar, otherwise false.
|
|
4780
4759
|
// NOTE: This might give an unexpected result if called before BuiltInRules is defined!
|
|
4781
4760
|
isBuiltIn() {
|
|
4782
|
-
return this === Grammar$
|
|
4761
|
+
return this === Grammar$4.ProtoBuiltInRules || this === Grammar$4.BuiltInRules;
|
|
4783
4762
|
},
|
|
4784
4763
|
|
|
4785
4764
|
equals(g) {
|
|
@@ -4918,7 +4897,7 @@ Grammar$5.prototype = {
|
|
|
4918
4897
|
if (isDefinition) {
|
|
4919
4898
|
operation = 'define';
|
|
4920
4899
|
} else {
|
|
4921
|
-
operation = body instanceof pexprs$
|
|
4900
|
+
operation = body instanceof pexprs$3.Extend ? 'extend' : 'override';
|
|
4922
4901
|
}
|
|
4923
4902
|
|
|
4924
4903
|
const metaInfo = {};
|
|
@@ -5005,7 +4984,7 @@ Grammar$5.prototype = {
|
|
|
5005
4984
|
let app;
|
|
5006
4985
|
if (str.indexOf('<') === -1) {
|
|
5007
4986
|
// simple application
|
|
5008
|
-
app = new pexprs$
|
|
4987
|
+
app = new pexprs$3.Apply(str);
|
|
5009
4988
|
} else {
|
|
5010
4989
|
// parameterized application
|
|
5011
4990
|
const cst = ohmGrammar$2.match(str, 'Base_application');
|
|
@@ -5035,43 +5014,43 @@ Grammar$5.prototype = {
|
|
|
5035
5014
|
// `BuiltInRules`. That grammar contains several convenience rules, e.g., `letter` and
|
|
5036
5015
|
// `digit`, and is implicitly the super-grammar of any grammar whose super-grammar
|
|
5037
5016
|
// isn't specified.
|
|
5038
|
-
Grammar$
|
|
5017
|
+
Grammar$4.ProtoBuiltInRules = new Grammar$4(
|
|
5039
5018
|
'ProtoBuiltInRules', // name
|
|
5040
5019
|
undefined, // supergrammar
|
|
5041
5020
|
{
|
|
5042
5021
|
any: {
|
|
5043
|
-
body: pexprs$
|
|
5022
|
+
body: pexprs$3.any,
|
|
5044
5023
|
formals: [],
|
|
5045
5024
|
description: 'any character',
|
|
5046
5025
|
primitive: true,
|
|
5047
5026
|
},
|
|
5048
5027
|
end: {
|
|
5049
|
-
body: pexprs$
|
|
5028
|
+
body: pexprs$3.end,
|
|
5050
5029
|
formals: [],
|
|
5051
5030
|
description: 'end of input',
|
|
5052
5031
|
primitive: true,
|
|
5053
5032
|
},
|
|
5054
5033
|
|
|
5055
5034
|
caseInsensitive: {
|
|
5056
|
-
body: new CaseInsensitiveTerminal(new pexprs$
|
|
5035
|
+
body: new CaseInsensitiveTerminal(new pexprs$3.Param(0)),
|
|
5057
5036
|
formals: ['str'],
|
|
5058
5037
|
primitive: true,
|
|
5059
5038
|
},
|
|
5060
5039
|
lower: {
|
|
5061
|
-
body: new pexprs$
|
|
5040
|
+
body: new pexprs$3.UnicodeChar('Ll'),
|
|
5062
5041
|
formals: [],
|
|
5063
5042
|
description: 'a lowercase letter',
|
|
5064
5043
|
primitive: true,
|
|
5065
5044
|
},
|
|
5066
5045
|
upper: {
|
|
5067
|
-
body: new pexprs$
|
|
5046
|
+
body: new pexprs$3.UnicodeChar('Lu'),
|
|
5068
5047
|
formals: [],
|
|
5069
5048
|
description: 'an uppercase letter',
|
|
5070
5049
|
primitive: true,
|
|
5071
5050
|
},
|
|
5072
5051
|
// Union of Lt (titlecase), Lm (modifier), and Lo (other), i.e. any letter not in Ll or Lu.
|
|
5073
5052
|
unicodeLtmo: {
|
|
5074
|
-
body: new pexprs$
|
|
5053
|
+
body: new pexprs$3.UnicodeChar('Ltmo'),
|
|
5075
5054
|
formals: [],
|
|
5076
5055
|
description: 'a Unicode character in Lt, Lm, or Lo',
|
|
5077
5056
|
primitive: true,
|
|
@@ -5080,11 +5059,11 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5080
5059
|
// These rules are not truly primitive (they could be written in userland) but are defined
|
|
5081
5060
|
// here for bootstrapping purposes.
|
|
5082
5061
|
spaces: {
|
|
5083
|
-
body: new pexprs$
|
|
5062
|
+
body: new pexprs$3.Star(new pexprs$3.Apply('space')),
|
|
5084
5063
|
formals: [],
|
|
5085
5064
|
},
|
|
5086
5065
|
space: {
|
|
5087
|
-
body: new pexprs$
|
|
5066
|
+
body: new pexprs$3.Range('\x00', ' '),
|
|
5088
5067
|
formals: [],
|
|
5089
5068
|
description: 'a space',
|
|
5090
5069
|
},
|
|
@@ -5095,17 +5074,17 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5095
5074
|
// Exports
|
|
5096
5075
|
// --------------------------------------------------------------------
|
|
5097
5076
|
|
|
5098
|
-
var Grammar_1 = Grammar$
|
|
5077
|
+
var Grammar_1 = Grammar$4;
|
|
5099
5078
|
|
|
5100
5079
|
// --------------------------------------------------------------------
|
|
5101
5080
|
// Imports
|
|
5102
5081
|
// --------------------------------------------------------------------
|
|
5103
5082
|
|
|
5104
|
-
const Grammar$
|
|
5083
|
+
const Grammar$3 = Grammar_1;
|
|
5105
5084
|
const InputStream = InputStream_1;
|
|
5106
5085
|
const common$1 = common$l;
|
|
5107
5086
|
const errors$1 = errors$9;
|
|
5108
|
-
const pexprs$
|
|
5087
|
+
const pexprs$2 = pexprs$6;
|
|
5109
5088
|
|
|
5110
5089
|
// --------------------------------------------------------------------
|
|
5111
5090
|
// Private Stuff
|
|
@@ -5129,7 +5108,7 @@ GrammarDecl$1.prototype.ensureSuperGrammar = function() {
|
|
|
5129
5108
|
// TODO: The conditional expression below is an ugly hack. It's kind of ok because
|
|
5130
5109
|
// I doubt anyone will ever try to declare a grammar called `BuiltInRules`. Still,
|
|
5131
5110
|
// we should try to find a better way to do this.
|
|
5132
|
-
this.name === 'BuiltInRules' ? Grammar$
|
|
5111
|
+
this.name === 'BuiltInRules' ? Grammar$3.ProtoBuiltInRules : Grammar$3.BuiltInRules
|
|
5133
5112
|
);
|
|
5134
5113
|
}
|
|
5135
5114
|
return this.superGrammar;
|
|
@@ -5200,7 +5179,7 @@ GrammarDecl$1.prototype.withSource = function(source) {
|
|
|
5200
5179
|
|
|
5201
5180
|
// Creates a Grammar instance, and if it passes the sanity checks, returns it.
|
|
5202
5181
|
GrammarDecl$1.prototype.build = function() {
|
|
5203
|
-
const grammar = new Grammar$
|
|
5182
|
+
const grammar = new Grammar$3(
|
|
5204
5183
|
this.name,
|
|
5205
5184
|
this.ensureSuperGrammar(),
|
|
5206
5185
|
this.rules,
|
|
@@ -5276,7 +5255,7 @@ GrammarDecl$1.prototype.extend = function(name, formals, fragment, descIgnored,
|
|
|
5276
5255
|
if (!ruleInfo) {
|
|
5277
5256
|
throw errors$1.cannotExtendUndeclaredRule(name, this.superGrammar.name, source);
|
|
5278
5257
|
}
|
|
5279
|
-
const body = new pexprs$
|
|
5258
|
+
const body = new pexprs$2.Extend(this.superGrammar, name, fragment);
|
|
5280
5259
|
body.source = fragment.source;
|
|
5281
5260
|
this.installOverriddenOrExtendedRule(name, formals, body, source);
|
|
5282
5261
|
return this;
|
|
@@ -5292,9 +5271,9 @@ var GrammarDecl_1 = GrammarDecl$1;
|
|
|
5292
5271
|
// Imports
|
|
5293
5272
|
// --------------------------------------------------------------------
|
|
5294
5273
|
|
|
5295
|
-
const Grammar$
|
|
5274
|
+
const Grammar$2 = Grammar_1;
|
|
5296
5275
|
const GrammarDecl = GrammarDecl_1;
|
|
5297
|
-
const pexprs$
|
|
5276
|
+
const pexprs$1 = pexprs$6;
|
|
5298
5277
|
|
|
5299
5278
|
// --------------------------------------------------------------------
|
|
5300
5279
|
// Private stuff
|
|
@@ -5315,7 +5294,7 @@ Builder$2.prototype = {
|
|
|
5315
5294
|
if (superGrammar) {
|
|
5316
5295
|
// `superGrammar` may be a recipe (i.e. an Array), or an actual grammar instance.
|
|
5317
5296
|
gDecl.withSuperGrammar(
|
|
5318
|
-
superGrammar instanceof Grammar$
|
|
5297
|
+
superGrammar instanceof Grammar$2 ? superGrammar : this.fromRecipe(superGrammar)
|
|
5319
5298
|
);
|
|
5320
5299
|
}
|
|
5321
5300
|
if (defaultStartRule) {
|
|
@@ -5350,73 +5329,73 @@ Builder$2.prototype = {
|
|
|
5350
5329
|
},
|
|
5351
5330
|
|
|
5352
5331
|
terminal(x) {
|
|
5353
|
-
return new pexprs$
|
|
5332
|
+
return new pexprs$1.Terminal(x);
|
|
5354
5333
|
},
|
|
5355
5334
|
|
|
5356
5335
|
range(from, to) {
|
|
5357
|
-
return new pexprs$
|
|
5336
|
+
return new pexprs$1.Range(from, to);
|
|
5358
5337
|
},
|
|
5359
5338
|
|
|
5360
5339
|
param(index) {
|
|
5361
|
-
return new pexprs$
|
|
5340
|
+
return new pexprs$1.Param(index);
|
|
5362
5341
|
},
|
|
5363
5342
|
|
|
5364
5343
|
alt(...termArgs) {
|
|
5365
5344
|
let terms = [];
|
|
5366
5345
|
for (let arg of termArgs) {
|
|
5367
|
-
if (!(arg instanceof pexprs$
|
|
5346
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5368
5347
|
arg = this.fromRecipe(arg);
|
|
5369
5348
|
}
|
|
5370
|
-
if (arg instanceof pexprs$
|
|
5349
|
+
if (arg instanceof pexprs$1.Alt) {
|
|
5371
5350
|
terms = terms.concat(arg.terms);
|
|
5372
5351
|
} else {
|
|
5373
5352
|
terms.push(arg);
|
|
5374
5353
|
}
|
|
5375
5354
|
}
|
|
5376
|
-
return terms.length === 1 ? terms[0] : new pexprs$
|
|
5355
|
+
return terms.length === 1 ? terms[0] : new pexprs$1.Alt(terms);
|
|
5377
5356
|
},
|
|
5378
5357
|
|
|
5379
5358
|
seq(...factorArgs) {
|
|
5380
5359
|
let factors = [];
|
|
5381
5360
|
for (let arg of factorArgs) {
|
|
5382
|
-
if (!(arg instanceof pexprs$
|
|
5361
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5383
5362
|
arg = this.fromRecipe(arg);
|
|
5384
5363
|
}
|
|
5385
|
-
if (arg instanceof pexprs$
|
|
5364
|
+
if (arg instanceof pexprs$1.Seq) {
|
|
5386
5365
|
factors = factors.concat(arg.factors);
|
|
5387
5366
|
} else {
|
|
5388
5367
|
factors.push(arg);
|
|
5389
5368
|
}
|
|
5390
5369
|
}
|
|
5391
|
-
return factors.length === 1 ? factors[0] : new pexprs$
|
|
5370
|
+
return factors.length === 1 ? factors[0] : new pexprs$1.Seq(factors);
|
|
5392
5371
|
},
|
|
5393
5372
|
|
|
5394
5373
|
star(expr) {
|
|
5395
|
-
if (!(expr instanceof pexprs$
|
|
5374
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5396
5375
|
expr = this.fromRecipe(expr);
|
|
5397
5376
|
}
|
|
5398
|
-
return new pexprs$
|
|
5377
|
+
return new pexprs$1.Star(expr);
|
|
5399
5378
|
},
|
|
5400
5379
|
|
|
5401
5380
|
plus(expr) {
|
|
5402
|
-
if (!(expr instanceof pexprs$
|
|
5381
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5403
5382
|
expr = this.fromRecipe(expr);
|
|
5404
5383
|
}
|
|
5405
|
-
return new pexprs$
|
|
5384
|
+
return new pexprs$1.Plus(expr);
|
|
5406
5385
|
},
|
|
5407
5386
|
|
|
5408
5387
|
opt(expr) {
|
|
5409
|
-
if (!(expr instanceof pexprs$
|
|
5388
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5410
5389
|
expr = this.fromRecipe(expr);
|
|
5411
5390
|
}
|
|
5412
|
-
return new pexprs$
|
|
5391
|
+
return new pexprs$1.Opt(expr);
|
|
5413
5392
|
},
|
|
5414
5393
|
|
|
5415
5394
|
not(expr) {
|
|
5416
|
-
if (!(expr instanceof pexprs$
|
|
5395
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5417
5396
|
expr = this.fromRecipe(expr);
|
|
5418
5397
|
}
|
|
5419
|
-
return new pexprs$
|
|
5398
|
+
return new pexprs$1.Not(expr);
|
|
5420
5399
|
},
|
|
5421
5400
|
|
|
5422
5401
|
la(expr) {
|
|
@@ -5425,33 +5404,33 @@ Builder$2.prototype = {
|
|
|
5425
5404
|
},
|
|
5426
5405
|
|
|
5427
5406
|
lookahead(expr) {
|
|
5428
|
-
if (!(expr instanceof pexprs$
|
|
5407
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5429
5408
|
expr = this.fromRecipe(expr);
|
|
5430
5409
|
}
|
|
5431
|
-
return new pexprs$
|
|
5410
|
+
return new pexprs$1.Lookahead(expr);
|
|
5432
5411
|
},
|
|
5433
5412
|
|
|
5434
5413
|
lex(expr) {
|
|
5435
|
-
if (!(expr instanceof pexprs$
|
|
5414
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5436
5415
|
expr = this.fromRecipe(expr);
|
|
5437
5416
|
}
|
|
5438
|
-
return new pexprs$
|
|
5417
|
+
return new pexprs$1.Lex(expr);
|
|
5439
5418
|
},
|
|
5440
5419
|
|
|
5441
5420
|
app(ruleName, optParams) {
|
|
5442
5421
|
if (optParams && optParams.length > 0) {
|
|
5443
5422
|
optParams = optParams.map(function(param) {
|
|
5444
|
-
return param instanceof pexprs$
|
|
5423
|
+
return param instanceof pexprs$1.PExpr ? param : this.fromRecipe(param);
|
|
5445
5424
|
}, this);
|
|
5446
5425
|
}
|
|
5447
|
-
return new pexprs$
|
|
5426
|
+
return new pexprs$1.Apply(ruleName, optParams);
|
|
5448
5427
|
},
|
|
5449
5428
|
|
|
5450
5429
|
// Note that unlike other methods in this class, this method cannot be used as a
|
|
5451
5430
|
// convenience constructor. It only works with recipes, because it relies on
|
|
5452
5431
|
// `this.currentDecl` and `this.currentRuleName` being set.
|
|
5453
5432
|
splice(beforeTerms, afterTerms) {
|
|
5454
|
-
return new pexprs$
|
|
5433
|
+
return new pexprs$1.Splice(
|
|
5455
5434
|
this.currentDecl.superGrammar,
|
|
5456
5435
|
this.currentRuleName,
|
|
5457
5436
|
beforeTerms.map(term => this.fromRecipe(term)),
|
|
@@ -5481,7 +5460,7 @@ Builder$2.prototype = {
|
|
|
5481
5460
|
var Builder_1 = Builder$2;
|
|
5482
5461
|
|
|
5483
5462
|
var name = "ohm-js";
|
|
5484
|
-
var version$2 = "16.
|
|
5463
|
+
var version$2 = "16.3.2";
|
|
5485
5464
|
var description = "An object-oriented language for parsing and pattern matching";
|
|
5486
5465
|
var repository = "https://github.com/harc/ohm";
|
|
5487
5466
|
var keywords = [
|
|
@@ -5496,7 +5475,7 @@ var keywords = [
|
|
|
5496
5475
|
"rapid",
|
|
5497
5476
|
"prototyping"
|
|
5498
5477
|
];
|
|
5499
|
-
var homepage = "https://
|
|
5478
|
+
var homepage = "https://ohmjs.org";
|
|
5500
5479
|
var bugs = "https://github.com/harc/ohm/issues";
|
|
5501
5480
|
var main = "index.js";
|
|
5502
5481
|
var module = "dist/ohm.esm.js";
|
|
@@ -5540,33 +5519,35 @@ var contributors = [
|
|
|
5540
5519
|
"Jason Merrill <jwmerrill@gmail.com>",
|
|
5541
5520
|
"Ray Toal <rtoal@lmu.edu>",
|
|
5542
5521
|
"Yoshiki Ohshima <Yoshiki.Ohshima@acm.org>",
|
|
5522
|
+
"megabuz <3299889+megabuz@users.noreply.github.com>",
|
|
5543
5523
|
"stagas <gstagas@gmail.com>",
|
|
5544
5524
|
"Jonathan Edwards <JonathanMEdwards@gmail.com>",
|
|
5545
5525
|
"Milan Lajtoš <milan.lajtos@me.com>",
|
|
5546
5526
|
"Neil Jewers <njjewers@uwaterloo.ca>",
|
|
5547
|
-
"megabuz <3299889+megabuz@users.noreply.github.com>",
|
|
5548
5527
|
"Mike Niebling <(none)>",
|
|
5549
|
-
"
|
|
5550
|
-
"
|
|
5528
|
+
"AngryPowman <angrypowman@qq.com>",
|
|
5529
|
+
"Patrick Dubroy <patrick@sourcegraph.com>",
|
|
5530
|
+
"Leslie Ying <acetophore@users.noreply.github.com>",
|
|
5551
5531
|
"Pierre Donias <pierre.donias@gmail.com>",
|
|
5532
|
+
"Justin Chase <justin.m.chase@gmail.com>",
|
|
5552
5533
|
"Ian Harris <ian@fofgof.xyz>",
|
|
5553
|
-
"Daniel Tomlinson <DanielTomlinson@me.com>",
|
|
5554
5534
|
"Stan Rozenraukh <stan@stanistan.com>",
|
|
5555
5535
|
"Stephan Seidt <stephan.seidt@gmail.com>",
|
|
5556
5536
|
"Steve Phillips <steve@tryingtobeawesome.com>",
|
|
5557
5537
|
"Szymon Kaliski <kaliskiszymon@gmail.com>",
|
|
5558
5538
|
"Thomas Nyberg <tomnyberg@gmail.com>",
|
|
5559
|
-
"
|
|
5539
|
+
"Daniel Tomlinson <DanielTomlinson@me.com>",
|
|
5560
5540
|
"Vse Mozhet Byt <vsemozhetbyt@gmail.com>",
|
|
5561
5541
|
"Wil Chung <10446+iamwilhelm@users.noreply.github.com>",
|
|
5562
|
-
"
|
|
5542
|
+
"Casey Olson <casey.m.olson@gmail.com>",
|
|
5563
5543
|
"abego <ub@abego-software.de>",
|
|
5564
5544
|
"acslk <d_vd415@hotmail.com>",
|
|
5565
5545
|
"codeZeilen <codeZeilen@users.noreply.github.com>",
|
|
5566
|
-
"
|
|
5546
|
+
"kassadin <kassadin@foxmail.com>",
|
|
5547
|
+
"Arthur Carabott <arthurc@gmail.com>",
|
|
5548
|
+
"owch <bowenrainyday@gmail.com>",
|
|
5567
5549
|
"Luca Guzzon <luca.guzzon@gmail.com>",
|
|
5568
|
-
"
|
|
5569
|
-
"owch <bowenrainyday@gmail.com>"
|
|
5550
|
+
"sfinnie <scott.finnie@gmail.com>"
|
|
5570
5551
|
];
|
|
5571
5552
|
var dependencies = {
|
|
5572
5553
|
};
|
|
@@ -5667,13 +5648,13 @@ var builtInRules = makeRecipe$3(["grammar",{"source":"BuiltInRules {\n\n alnum
|
|
|
5667
5648
|
// Imports
|
|
5668
5649
|
// --------------------------------------------------------------------
|
|
5669
5650
|
|
|
5670
|
-
const Grammar$
|
|
5651
|
+
const Grammar$1 = Grammar_1;
|
|
5671
5652
|
|
|
5672
5653
|
// --------------------------------------------------------------------
|
|
5673
5654
|
// Private stuff
|
|
5674
5655
|
// --------------------------------------------------------------------
|
|
5675
5656
|
|
|
5676
|
-
Grammar$
|
|
5657
|
+
Grammar$1.BuiltInRules = builtInRules;
|
|
5677
5658
|
|
|
5678
5659
|
var {makeRecipe: makeRecipe$2} = makeRecipe$5;
|
|
5679
5660
|
var operationsAndAttributes = makeRecipe$2(["grammar",{"source":"OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = \"(\" ListOf<name, \",\"> \")\"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n}"},"OperationsAndAttributes",null,"AttributeSignature",{"AttributeSignature":["define",{"sourceInterval":[29,58]},null,[],["app",{"sourceInterval":[54,58]},"name",[]]],"OperationSignature":["define",{"sourceInterval":[62,100]},null,[],["seq",{"sourceInterval":[87,100]},["app",{"sourceInterval":[87,91]},"name",[]],["opt",{"sourceInterval":[92,100]},["app",{"sourceInterval":[92,99]},"Formals",[]]]]],"Formals":["define",{"sourceInterval":[104,143]},null,[],["seq",{"sourceInterval":[118,143]},["terminal",{"sourceInterval":[118,121]},"("],["app",{"sourceInterval":[122,139]},"ListOf",[["app",{"sourceInterval":[129,133]},"name",[]],["terminal",{"sourceInterval":[135,138]},","]]],["terminal",{"sourceInterval":[140,143]},")"]]],"name":["define",{"sourceInterval":[147,187]},"a name",[],["seq",{"sourceInterval":[168,187]},["app",{"sourceInterval":[168,177]},"nameFirst",[]],["star",{"sourceInterval":[178,187]},["app",{"sourceInterval":[178,186]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[191,223]},null,[],["alt",{"sourceInterval":[207,223]},["terminal",{"sourceInterval":[207,210]},"_"],["app",{"sourceInterval":[217,223]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[227,257]},null,[],["alt",{"sourceInterval":[242,257]},["terminal",{"sourceInterval":[242,245]},"_"],["app",{"sourceInterval":[252,257]},"alnum",[]]]]}]);
|
|
@@ -5739,18 +5720,18 @@ function initPrototypeParser(grammar) {
|
|
|
5739
5720
|
}
|
|
5740
5721
|
|
|
5741
5722
|
var {makeRecipe: makeRecipe$1} = makeRecipe$5;
|
|
5742
|
-
var ohmGrammar$1 = makeRecipe$1(["grammar",{"source":"Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? \"{\" Rule* \"}\"\n\n SuperGrammar\n = \"<:\" ident\n\n Rule\n = ident Formals? ruleDescr? \"=\" RuleBody -- define\n | ident Formals? \":=\" OverrideRuleBody -- override\n | ident Formals? \"+=\" RuleBody -- extend\n\n RuleBody\n = \"|\"? NonemptyListOf<TopLevelTerm, \"|\">\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n OverrideRuleBody\n = \"|\"? NonemptyListOf<OverrideTopLevelTerm, \"|\">\n\n OverrideTopLevelTerm\n = \"...\" -- superSplice\n | TopLevelTerm\n\n Formals\n = \"<\" ListOf<ident, \",\"> \">\"\n\n Params\n = \"<\" ListOf<Seq, \",\"> \">\"\n\n Alt\n = NonemptyListOf<Seq, \"|\">\n\n Seq\n = Iter*\n\n Iter\n = Pred \"*\" -- star\n | Pred \"+\" -- plus\n | Pred \"?\" -- opt\n | Pred\n\n Pred\n = \"~\" Lex -- not\n | \"&\" Lex -- lookahead\n | Lex\n\n Lex\n = \"#\" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? \"=\" | \":=\" | \"+=\") -- application\n | oneCharTerminal \"..\" oneCharTerminal -- range\n | terminal -- terminal\n | \"(\" Alt \")\" -- paren\n\n ruleDescr (a rule description)\n = \"(\" ruleDescrText \")\"\n\n ruleDescrText\n = (~\")\" any)*\n\n caseName\n = \"--\" (~\"\\n\" space)* name (~\"\\n\" space)* (\"\\n\" | &\"}\")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = \"\\\"\" terminalChar* \"\\\"\"\n\n oneCharTerminal\n = \"\\\"\" terminalChar \"\\\"\"\n\n terminalChar\n = escapeChar\n// | ~\"\\\\\" ~\"\\\"\" ~\"\\n\" any\n | ~\"\\\\\" ~\"\\\"\" ~\"\\n\" \"\\u{0}\"..\"\\u{10FFFF}\"\n\n escapeChar (an escape sequence)\n = \"\\\\\\\\\" -- backslash\n | \"\\\\\\\"\" -- doubleQuote\n | \"\\\\\\'\" -- singleQuote\n | \"\\\\b\" -- backspace\n | \"\\\\n\" -- lineFeed\n | \"\\\\r\" -- carriageReturn\n | \"\\\\t\" -- tab\n | \"\\\\u{\" hexDigit+ \"}\" -- unicodeCodePoint\n | \"\\\\u\" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | \"\\\\x\" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = \"//\" (~\"\\n\" any)* &(\"\\n\" | end) -- singleLine\n | \"/*\" (~\"*/\" any)* \"*/\" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = \"<:\" | \"=\" | \":=\" | \"+=\" | \"*\" | \"+\" | \"?\" | \"~\" | \"&\"\n\n punctuation = \"<\" | \">\" | \",\" | \"--\"\n}"},"Ohm",null,"Grammars",{"Grammars":["define",{"sourceInterval":[9,32]},null,[],["star",{"sourceInterval":[24,32]},["app",{"sourceInterval":[24,31]},"Grammar",[]]]],"Grammar":["define",{"sourceInterval":[36,83]},null,[],["seq",{"sourceInterval":[50,83]},["app",{"sourceInterval":[50,55]},"ident",[]],["opt",{"sourceInterval":[56,69]},["app",{"sourceInterval":[56,68]},"SuperGrammar",[]]],["terminal",{"sourceInterval":[70,73]},"{"],["star",{"sourceInterval":[74,79]},["app",{"sourceInterval":[74,78]},"Rule",[]]],["terminal",{"sourceInterval":[80,83]},"}"]]],"SuperGrammar":["define",{"sourceInterval":[87,116]},null,[],["seq",{"sourceInterval":[106,116]},["terminal",{"sourceInterval":[106,110]},"<:"],["app",{"sourceInterval":[111,116]},"ident",[]]]],"Rule_define":["define",{"sourceInterval":[131,181]},null,[],["seq",{"sourceInterval":[131,170]},["app",{"sourceInterval":[131,136]},"ident",[]],["opt",{"sourceInterval":[137,145]},["app",{"sourceInterval":[137,144]},"Formals",[]]],["opt",{"sourceInterval":[146,156]},["app",{"sourceInterval":[146,155]},"ruleDescr",[]]],["terminal",{"sourceInterval":[157,160]},"="],["app",{"sourceInterval":[162,170]},"RuleBody",[]]]],"Rule_override":["define",{"sourceInterval":[188,248]},null,[],["seq",{"sourceInterval":[188,235]},["app",{"sourceInterval":[188,193]},"ident",[]],["opt",{"sourceInterval":[194,202]},["app",{"sourceInterval":[194,201]},"Formals",[]]],["terminal",{"sourceInterval":[214,218]},":="],["app",{"sourceInterval":[219,235]},"OverrideRuleBody",[]]]],"Rule_extend":["define",{"sourceInterval":[255,305]},null,[],["seq",{"sourceInterval":[255,294]},["app",{"sourceInterval":[255,260]},"ident",[]],["opt",{"sourceInterval":[261,269]},["app",{"sourceInterval":[261,268]},"Formals",[]]],["terminal",{"sourceInterval":[281,285]},"+="],["app",{"sourceInterval":[286,294]},"RuleBody",[]]]],"Rule":["define",{"sourceInterval":[120,305]},null,[],["alt",{"sourceInterval":[131,305]},["app",{"sourceInterval":[131,170]},"Rule_define",[]],["app",{"sourceInterval":[188,235]},"Rule_override",[]],["app",{"sourceInterval":[255,294]},"Rule_extend",[]]]],"RuleBody":["define",{"sourceInterval":[309,362]},null,[],["seq",{"sourceInterval":[324,362]},["opt",{"sourceInterval":[324,328]},["terminal",{"sourceInterval":[324,327]},"|"]],["app",{"sourceInterval":[329,362]},"NonemptyListOf",[["app",{"sourceInterval":[344,356]},"TopLevelTerm",[]],["terminal",{"sourceInterval":[358,361]},"|"]]]]],"TopLevelTerm_inline":["define",{"sourceInterval":[385,408]},null,[],["seq",{"sourceInterval":[385,397]},["app",{"sourceInterval":[385,388]},"Seq",[]],["app",{"sourceInterval":[389,397]},"caseName",[]]]],"TopLevelTerm":["define",{"sourceInterval":[366,418]},null,[],["alt",{"sourceInterval":[385,418]},["app",{"sourceInterval":[385,397]},"TopLevelTerm_inline",[]],["app",{"sourceInterval":[415,418]},"Seq",[]]]],"OverrideRuleBody":["define",{"sourceInterval":[422,491]},null,[],["seq",{"sourceInterval":[445,491]},["opt",{"sourceInterval":[445,449]},["terminal",{"sourceInterval":[445,448]},"|"]],["app",{"sourceInterval":[450,491]},"NonemptyListOf",[["app",{"sourceInterval":[465,485]},"OverrideTopLevelTerm",[]],["terminal",{"sourceInterval":[487,490]},"|"]]]]],"OverrideTopLevelTerm_superSplice":["define",{"sourceInterval":[522,543]},null,[],["terminal",{"sourceInterval":[522,527]},"..."]],"OverrideTopLevelTerm":["define",{"sourceInterval":[495,562]},null,[],["alt",{"sourceInterval":[522,562]},["app",{"sourceInterval":[522,527]},"OverrideTopLevelTerm_superSplice",[]],["app",{"sourceInterval":[550,562]},"TopLevelTerm",[]]]],"Formals":["define",{"sourceInterval":[566,606]},null,[],["seq",{"sourceInterval":[580,606]},["terminal",{"sourceInterval":[580,583]},"<"],["app",{"sourceInterval":[584,602]},"ListOf",[["app",{"sourceInterval":[591,596]},"ident",[]],["terminal",{"sourceInterval":[598,601]},","]]],["terminal",{"sourceInterval":[603,606]},">"]]],"Params":["define",{"sourceInterval":[610,647]},null,[],["seq",{"sourceInterval":[623,647]},["terminal",{"sourceInterval":[623,626]},"<"],["app",{"sourceInterval":[627,643]},"ListOf",[["app",{"sourceInterval":[634,637]},"Seq",[]],["terminal",{"sourceInterval":[639,642]},","]]],["terminal",{"sourceInterval":[644,647]},">"]]],"Alt":["define",{"sourceInterval":[651,685]},null,[],["app",{"sourceInterval":[661,685]},"NonemptyListOf",[["app",{"sourceInterval":[676,679]},"Seq",[]],["terminal",{"sourceInterval":[681,684]},"|"]]]],"Seq":["define",{"sourceInterval":[689,704]},null,[],["star",{"sourceInterval":[699,704]},["app",{"sourceInterval":[699,703]},"Iter",[]]]],"Iter_star":["define",{"sourceInterval":[719,736]},null,[],["seq",{"sourceInterval":[719,727]},["app",{"sourceInterval":[719,723]},"Pred",[]],["terminal",{"sourceInterval":[724,727]},"*"]]],"Iter_plus":["define",{"sourceInterval":[743,760]},null,[],["seq",{"sourceInterval":[743,751]},["app",{"sourceInterval":[743,747]},"Pred",[]],["terminal",{"sourceInterval":[748,751]},"+"]]],"Iter_opt":["define",{"sourceInterval":[767,783]},null,[],["seq",{"sourceInterval":[767,775]},["app",{"sourceInterval":[767,771]},"Pred",[]],["terminal",{"sourceInterval":[772,775]},"?"]]],"Iter":["define",{"sourceInterval":[708,794]},null,[],["alt",{"sourceInterval":[719,794]},["app",{"sourceInterval":[719,727]},"Iter_star",[]],["app",{"sourceInterval":[743,751]},"Iter_plus",[]],["app",{"sourceInterval":[767,775]},"Iter_opt",[]],["app",{"sourceInterval":[790,794]},"Pred",[]]]],"Pred_not":["define",{"sourceInterval":[809,824]},null,[],["seq",{"sourceInterval":[809,816]},["terminal",{"sourceInterval":[809,812]},"~"],["app",{"sourceInterval":[813,816]},"Lex",[]]]],"Pred_lookahead":["define",{"sourceInterval":[831,852]},null,[],["seq",{"sourceInterval":[831,838]},["terminal",{"sourceInterval":[831,834]},"&"],["app",{"sourceInterval":[835,838]},"Lex",[]]]],"Pred":["define",{"sourceInterval":[798,862]},null,[],["alt",{"sourceInterval":[809,862]},["app",{"sourceInterval":[809,816]},"Pred_not",[]],["app",{"sourceInterval":[831,838]},"Pred_lookahead",[]],["app",{"sourceInterval":[859,862]},"Lex",[]]]],"Lex_lex":["define",{"sourceInterval":[876,892]},null,[],["seq",{"sourceInterval":[876,884]},["terminal",{"sourceInterval":[876,879]},"#"],["app",{"sourceInterval":[880,884]},"Base",[]]]],"Lex":["define",{"sourceInterval":[866,903]},null,[],["alt",{"sourceInterval":[876,903]},["app",{"sourceInterval":[876,884]},"Lex_lex",[]],["app",{"sourceInterval":[899,903]},"Base",[]]]],"Base_application":["define",{"sourceInterval":[918,979]},null,[],["seq",{"sourceInterval":[918,963]},["app",{"sourceInterval":[918,923]},"ident",[]],["opt",{"sourceInterval":[924,931]},["app",{"sourceInterval":[924,930]},"Params",[]]],["not",{"sourceInterval":[932,963]},["alt",{"sourceInterval":[934,962]},["seq",{"sourceInterval":[934,948]},["opt",{"sourceInterval":[934,944]},["app",{"sourceInterval":[934,943]},"ruleDescr",[]]],["terminal",{"sourceInterval":[945,948]},"="]],["terminal",{"sourceInterval":[951,955]},":="],["terminal",{"sourceInterval":[958,962]},"+="]]]]],"Base_range":["define",{"sourceInterval":[986,1041]},null,[],["seq",{"sourceInterval":[986,1022]},["app",{"sourceInterval":[986,1001]},"oneCharTerminal",[]],["terminal",{"sourceInterval":[1002,1006]},".."],["app",{"sourceInterval":[1007,1022]},"oneCharTerminal",[]]]],"Base_terminal":["define",{"sourceInterval":[1048,1106]},null,[],["app",{"sourceInterval":[1048,1056]},"terminal",[]]],"Base_paren":["define",{"sourceInterval":[1113,1168]},null,[],["seq",{"sourceInterval":[1113,1124]},["terminal",{"sourceInterval":[1113,1116]},"("],["app",{"sourceInterval":[1117,1120]},"Alt",[]],["terminal",{"sourceInterval":[1121,1124]},")"]]],"Base":["define",{"sourceInterval":[907,1168]},null,[],["alt",{"sourceInterval":[918,1168]},["app",{"sourceInterval":[918,963]},"Base_application",[]],["app",{"sourceInterval":[986,1022]},"Base_range",[]],["app",{"sourceInterval":[1048,1056]},"Base_terminal",[]],["app",{"sourceInterval":[1113,1124]},"Base_paren",[]]]],"ruleDescr":["define",{"sourceInterval":[1172,1231]},"a rule description",[],["seq",{"sourceInterval":[1210,1231]},["terminal",{"sourceInterval":[1210,1213]},"("],["app",{"sourceInterval":[1214,1227]},"ruleDescrText",[]],["terminal",{"sourceInterval":[1228,1231]},")"]]],"ruleDescrText":["define",{"sourceInterval":[1235,1266]},null,[],["star",{"sourceInterval":[1255,1266]},["seq",{"sourceInterval":[1256,1264]},["not",{"sourceInterval":[1256,1260]},["terminal",{"sourceInterval":[1257,1260]},")"]],["app",{"sourceInterval":[1261,1264]},"any",[]]]]],"caseName":["define",{"sourceInterval":[1270,1338]},null,[],["seq",{"sourceInterval":[1285,1338]},["terminal",{"sourceInterval":[1285,1289]},"--"],["star",{"sourceInterval":[1290,1304]},["seq",{"sourceInterval":[1291,1302]},["not",{"sourceInterval":[1291,1296]},["terminal",{"sourceInterval":[1292,1296]},"\n"]],["app",{"sourceInterval":[1297,1302]},"space",[]]]],["app",{"sourceInterval":[1305,1309]},"name",[]],["star",{"sourceInterval":[1310,1324]},["seq",{"sourceInterval":[1311,1322]},["not",{"sourceInterval":[1311,1316]},["terminal",{"sourceInterval":[1312,1316]},"\n"]],["app",{"sourceInterval":[1317,1322]},"space",[]]]],["alt",{"sourceInterval":[1326,1337]},["terminal",{"sourceInterval":[1326,1330]},"\n"],["lookahead",{"sourceInterval":[1333,1337]},["terminal",{"sourceInterval":[1334,1337]},"}"]]]]],"name":["define",{"sourceInterval":[1342,1382]},"a name",[],["seq",{"sourceInterval":[1363,1382]},["app",{"sourceInterval":[1363,1372]},"nameFirst",[]],["star",{"sourceInterval":[1373,1382]},["app",{"sourceInterval":[1373,1381]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[1386,1418]},null,[],["alt",{"sourceInterval":[1402,1418]},["terminal",{"sourceInterval":[1402,1405]},"_"],["app",{"sourceInterval":[1412,1418]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[1422,1452]},null,[],["alt",{"sourceInterval":[1437,1452]},["terminal",{"sourceInterval":[1437,1440]},"_"],["app",{"sourceInterval":[1447,1452]},"alnum",[]]]],"ident":["define",{"sourceInterval":[1456,1489]},"an identifier",[],["app",{"sourceInterval":[1485,1489]},"name",[]]],"terminal":["define",{"sourceInterval":[1493,1531]},null,[],["seq",{"sourceInterval":[1508,1531]},["terminal",{"sourceInterval":[1508,1512]},"\""],["star",{"sourceInterval":[1513,1526]},["app",{"sourceInterval":[1513,1525]},"terminalChar",[]]],["terminal",{"sourceInterval":[1527,1531]},"\""]]],"oneCharTerminal":["define",{"sourceInterval":[1535,1579]},null,[],["seq",{"sourceInterval":[1557,1579]},["terminal",{"sourceInterval":[1557,1561]},"\""],["app",{"sourceInterval":[1562,1574]},"terminalChar",[]],["terminal",{"sourceInterval":[1575,1579]},"\""]]],"terminalChar":["define",{"sourceInterval":[1583,1690]},null,[],["alt",{"sourceInterval":[1602,1690]},["app",{"sourceInterval":[1602,1612]},"escapeChar",[]],["seq",{"sourceInterval":[1651,1690]},["not",{"sourceInterval":[1651,1656]},["terminal",{"sourceInterval":[1652,1656]},"\\"]],["not",{"sourceInterval":[1657,1662]},["terminal",{"sourceInterval":[1658,1662]},"\""]],["not",{"sourceInterval":[1663,1668]},["terminal",{"sourceInterval":[1664,1668]},"\n"]],["range",{"sourceInterval":[1669,1690]},"\u0000",""]]]],"escapeChar_backslash":["define",{"sourceInterval":[1733,1788]},null,[],["terminal",{"sourceInterval":[1733,1739]},"\\\\"]],"escapeChar_doubleQuote":["define",{"sourceInterval":[1795,1852]},null,[],["terminal",{"sourceInterval":[1795,1801]},"\\\""]],"escapeChar_singleQuote":["define",{"sourceInterval":[1859,1916]},null,[],["terminal",{"sourceInterval":[1859,1865]},"\\'"]],"escapeChar_backspace":["define",{"sourceInterval":[1923,1978]},null,[],["terminal",{"sourceInterval":[1923,1928]},"\\b"]],"escapeChar_lineFeed":["define",{"sourceInterval":[1985,2039]},null,[],["terminal",{"sourceInterval":[1985,1990]},"\\n"]],"escapeChar_carriageReturn":["define",{"sourceInterval":[2046,2106]},null,[],["terminal",{"sourceInterval":[2046,2051]},"\\r"]],"escapeChar_tab":["define",{"sourceInterval":[2113,2162]},null,[],["terminal",{"sourceInterval":[2113,2118]},"\\t"]],"escapeChar_unicodeCodePoint":["define",{"sourceInterval":[2169,2231]},null,[],["seq",{"sourceInterval":[2169,2189]},["terminal",{"sourceInterval":[2169,2175]},"\\u{"],["plus",{"sourceInterval":[2176,2185]},["app",{"sourceInterval":[2176,2184]},"hexDigit",[]]],["terminal",{"sourceInterval":[2186,2189]},"}"]]],"escapeChar_unicodeEscape":["define",{"sourceInterval":[2238,2297]},null,[],["seq",{"sourceInterval":[2238,2279]},["terminal",{"sourceInterval":[2238,2243]},"\\u"],["app",{"sourceInterval":[2244,2252]},"hexDigit",[]],["app",{"sourceInterval":[2253,2261]},"hexDigit",[]],["app",{"sourceInterval":[2262,2270]},"hexDigit",[]],["app",{"sourceInterval":[2271,2279]},"hexDigit",[]]]],"escapeChar_hexEscape":["define",{"sourceInterval":[2304,2359]},null,[],["seq",{"sourceInterval":[2304,2327]},["terminal",{"sourceInterval":[2304,2309]},"\\x"],["app",{"sourceInterval":[2310,2318]},"hexDigit",[]],["app",{"sourceInterval":[2319,2327]},"hexDigit",[]]]],"escapeChar":["define",{"sourceInterval":[1694,2359]},"an escape sequence",[],["alt",{"sourceInterval":[1733,2359]},["app",{"sourceInterval":[1733,1739]},"escapeChar_backslash",[]],["app",{"sourceInterval":[1795,1801]},"escapeChar_doubleQuote",[]],["app",{"sourceInterval":[1859,1865]},"escapeChar_singleQuote",[]],["app",{"sourceInterval":[1923,1928]},"escapeChar_backspace",[]],["app",{"sourceInterval":[1985,1990]},"escapeChar_lineFeed",[]],["app",{"sourceInterval":[2046,2051]},"escapeChar_carriageReturn",[]],["app",{"sourceInterval":[2113,2118]},"escapeChar_tab",[]],["app",{"sourceInterval":[2169,2189]},"escapeChar_unicodeCodePoint",[]],["app",{"sourceInterval":[2238,2279]},"escapeChar_unicodeEscape",[]],["app",{"sourceInterval":[2304,2327]},"escapeChar_hexEscape",[]]]],"space":["extend",{"sourceInterval":[2363,2382]},null,[],["app",{"sourceInterval":[2375,2382]},"comment",[]]],"comment_singleLine":["define",{"sourceInterval":[2400,2446]},null,[],["seq",{"sourceInterval":[2400,2431]},["terminal",{"sourceInterval":[2400,2404]},"//"],["star",{"sourceInterval":[2405,2417]},["seq",{"sourceInterval":[2406,2415]},["not",{"sourceInterval":[2406,2411]},["terminal",{"sourceInterval":[2407,2411]},"\n"]],["app",{"sourceInterval":[2412,2415]},"any",[]]]],["lookahead",{"sourceInterval":[2418,2431]},["alt",{"sourceInterval":[2420,2430]},["terminal",{"sourceInterval":[2420,2424]},"\n"],["app",{"sourceInterval":[2427,2430]},"end",[]]]]]],"comment_multiLine":["define",{"sourceInterval":[2453,2489]},null,[],["seq",{"sourceInterval":[2453,2475]},["terminal",{"sourceInterval":[2453,2457]},"/*"],["star",{"sourceInterval":[2458,2470]},["seq",{"sourceInterval":[2459,2468]},["not",{"sourceInterval":[2459,2464]},["terminal",{"sourceInterval":[2460,2464]},"*/"]],["app",{"sourceInterval":[2465,2468]},"any",[]]]],["terminal",{"sourceInterval":[2471,2475]},"*/"]]],"comment":["define",{"sourceInterval":[2386,2489]},null,[],["alt",{"sourceInterval":[2400,2489]},["app",{"sourceInterval":[2400,2431]},"comment_singleLine",[]],["app",{"sourceInterval":[2453,2475]},"comment_multiLine",[]]]],"tokens":["define",{"sourceInterval":[2493,2508]},null,[],["star",{"sourceInterval":[2502,2508]},["app",{"sourceInterval":[2502,2507]},"token",[]]]],"token":["define",{"sourceInterval":[2512,2588]},null,[],["alt",{"sourceInterval":[2520,2588]},["app",{"sourceInterval":[2520,2528]},"caseName",[]],["app",{"sourceInterval":[2531,2538]},"comment",[]],["app",{"sourceInterval":[2541,2546]},"ident",[]],["app",{"sourceInterval":[2549,2557]},"operator",[]],["app",{"sourceInterval":[2560,2571]},"punctuation",[]],["app",{"sourceInterval":[2574,2582]},"terminal",[]],["app",{"sourceInterval":[2585,2588]},"any",[]]]],"operator":["define",{"sourceInterval":[2592,2657]},null,[],["alt",{"sourceInterval":[2603,2657]},["terminal",{"sourceInterval":[2603,2607]},"<:"],["terminal",{"sourceInterval":[2610,2613]},"="],["terminal",{"sourceInterval":[2616,2620]},":="],["terminal",{"sourceInterval":[2623,2627]},"+="],["terminal",{"sourceInterval":[2630,2633]},"*"],["terminal",{"sourceInterval":[2636,2639]},"+"],["terminal",{"sourceInterval":[2642,2645]},"?"],["terminal",{"sourceInterval":[2648,2651]},"~"],["terminal",{"sourceInterval":[2654,2657]},"&"]]],"punctuation":["define",{"sourceInterval":[2661,2697]},null,[],["alt",{"sourceInterval":[2675,2697]},["terminal",{"sourceInterval":[2675,2678]},"<"],["terminal",{"sourceInterval":[2681,2684]},">"],["terminal",{"sourceInterval":[2687,2690]},","],["terminal",{"sourceInterval":[2693,2697]},"--"]]]}]);
|
|
5723
|
+
var ohmGrammar$1 = makeRecipe$1(["grammar",{"source":"Ohm {\n\n Grammars\n = Grammar*\n\n Grammar\n = ident SuperGrammar? \"{\" Rule* \"}\"\n\n SuperGrammar\n = \"<:\" ident\n\n Rule\n = ident Formals? ruleDescr? \"=\" RuleBody -- define\n | ident Formals? \":=\" OverrideRuleBody -- override\n | ident Formals? \"+=\" RuleBody -- extend\n\n RuleBody\n = \"|\"? NonemptyListOf<TopLevelTerm, \"|\">\n\n TopLevelTerm\n = Seq caseName -- inline\n | Seq\n\n OverrideRuleBody\n = \"|\"? NonemptyListOf<OverrideTopLevelTerm, \"|\">\n\n OverrideTopLevelTerm\n = \"...\" -- superSplice\n | TopLevelTerm\n\n Formals\n = \"<\" ListOf<ident, \",\"> \">\"\n\n Params\n = \"<\" ListOf<Seq, \",\"> \">\"\n\n Alt\n = NonemptyListOf<Seq, \"|\">\n\n Seq\n = Iter*\n\n Iter\n = Pred \"*\" -- star\n | Pred \"+\" -- plus\n | Pred \"?\" -- opt\n | Pred\n\n Pred\n = \"~\" Lex -- not\n | \"&\" Lex -- lookahead\n | Lex\n\n Lex\n = \"#\" Base -- lex\n | Base\n\n Base\n = ident Params? ~(ruleDescr? \"=\" | \":=\" | \"+=\") -- application\n | oneCharTerminal \"..\" oneCharTerminal -- range\n | terminal -- terminal\n | \"(\" Alt \")\" -- paren\n\n ruleDescr (a rule description)\n = \"(\" ruleDescrText \")\"\n\n ruleDescrText\n = (~\")\" any)*\n\n caseName\n = \"--\" (~\"\\n\" space)* name (~\"\\n\" space)* (\"\\n\" | &\"}\")\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n ident (an identifier)\n = name\n\n terminal\n = \"\\\"\" terminalChar* \"\\\"\"\n\n oneCharTerminal\n = \"\\\"\" terminalChar \"\\\"\"\n\n terminalChar\n = escapeChar\n | ~\"\\\\\" ~\"\\\"\" ~\"\\n\" \"\\u{0}\"..\"\\u{10FFFF}\"\n\n escapeChar (an escape sequence)\n = \"\\\\\\\\\" -- backslash\n | \"\\\\\\\"\" -- doubleQuote\n | \"\\\\\\'\" -- singleQuote\n | \"\\\\b\" -- backspace\n | \"\\\\n\" -- lineFeed\n | \"\\\\r\" -- carriageReturn\n | \"\\\\t\" -- tab\n | \"\\\\u{\" hexDigit hexDigit? hexDigit?\n hexDigit? hexDigit? hexDigit? \"}\" -- unicodeCodePoint\n | \"\\\\u\" hexDigit hexDigit hexDigit hexDigit -- unicodeEscape\n | \"\\\\x\" hexDigit hexDigit -- hexEscape\n\n space\n += comment\n\n comment\n = \"//\" (~\"\\n\" any)* &(\"\\n\" | end) -- singleLine\n | \"/*\" (~\"*/\" any)* \"*/\" -- multiLine\n\n tokens = token*\n\n token = caseName | comment | ident | operator | punctuation | terminal | any\n\n operator = \"<:\" | \"=\" | \":=\" | \"+=\" | \"*\" | \"+\" | \"?\" | \"~\" | \"&\"\n\n punctuation = \"<\" | \">\" | \",\" | \"--\"\n}"},"Ohm",null,"Grammars",{"Grammars":["define",{"sourceInterval":[9,32]},null,[],["star",{"sourceInterval":[24,32]},["app",{"sourceInterval":[24,31]},"Grammar",[]]]],"Grammar":["define",{"sourceInterval":[36,83]},null,[],["seq",{"sourceInterval":[50,83]},["app",{"sourceInterval":[50,55]},"ident",[]],["opt",{"sourceInterval":[56,69]},["app",{"sourceInterval":[56,68]},"SuperGrammar",[]]],["terminal",{"sourceInterval":[70,73]},"{"],["star",{"sourceInterval":[74,79]},["app",{"sourceInterval":[74,78]},"Rule",[]]],["terminal",{"sourceInterval":[80,83]},"}"]]],"SuperGrammar":["define",{"sourceInterval":[87,116]},null,[],["seq",{"sourceInterval":[106,116]},["terminal",{"sourceInterval":[106,110]},"<:"],["app",{"sourceInterval":[111,116]},"ident",[]]]],"Rule_define":["define",{"sourceInterval":[131,181]},null,[],["seq",{"sourceInterval":[131,170]},["app",{"sourceInterval":[131,136]},"ident",[]],["opt",{"sourceInterval":[137,145]},["app",{"sourceInterval":[137,144]},"Formals",[]]],["opt",{"sourceInterval":[146,156]},["app",{"sourceInterval":[146,155]},"ruleDescr",[]]],["terminal",{"sourceInterval":[157,160]},"="],["app",{"sourceInterval":[162,170]},"RuleBody",[]]]],"Rule_override":["define",{"sourceInterval":[188,248]},null,[],["seq",{"sourceInterval":[188,235]},["app",{"sourceInterval":[188,193]},"ident",[]],["opt",{"sourceInterval":[194,202]},["app",{"sourceInterval":[194,201]},"Formals",[]]],["terminal",{"sourceInterval":[214,218]},":="],["app",{"sourceInterval":[219,235]},"OverrideRuleBody",[]]]],"Rule_extend":["define",{"sourceInterval":[255,305]},null,[],["seq",{"sourceInterval":[255,294]},["app",{"sourceInterval":[255,260]},"ident",[]],["opt",{"sourceInterval":[261,269]},["app",{"sourceInterval":[261,268]},"Formals",[]]],["terminal",{"sourceInterval":[281,285]},"+="],["app",{"sourceInterval":[286,294]},"RuleBody",[]]]],"Rule":["define",{"sourceInterval":[120,305]},null,[],["alt",{"sourceInterval":[131,305]},["app",{"sourceInterval":[131,170]},"Rule_define",[]],["app",{"sourceInterval":[188,235]},"Rule_override",[]],["app",{"sourceInterval":[255,294]},"Rule_extend",[]]]],"RuleBody":["define",{"sourceInterval":[309,362]},null,[],["seq",{"sourceInterval":[324,362]},["opt",{"sourceInterval":[324,328]},["terminal",{"sourceInterval":[324,327]},"|"]],["app",{"sourceInterval":[329,362]},"NonemptyListOf",[["app",{"sourceInterval":[344,356]},"TopLevelTerm",[]],["terminal",{"sourceInterval":[358,361]},"|"]]]]],"TopLevelTerm_inline":["define",{"sourceInterval":[385,408]},null,[],["seq",{"sourceInterval":[385,397]},["app",{"sourceInterval":[385,388]},"Seq",[]],["app",{"sourceInterval":[389,397]},"caseName",[]]]],"TopLevelTerm":["define",{"sourceInterval":[366,418]},null,[],["alt",{"sourceInterval":[385,418]},["app",{"sourceInterval":[385,397]},"TopLevelTerm_inline",[]],["app",{"sourceInterval":[415,418]},"Seq",[]]]],"OverrideRuleBody":["define",{"sourceInterval":[422,491]},null,[],["seq",{"sourceInterval":[445,491]},["opt",{"sourceInterval":[445,449]},["terminal",{"sourceInterval":[445,448]},"|"]],["app",{"sourceInterval":[450,491]},"NonemptyListOf",[["app",{"sourceInterval":[465,485]},"OverrideTopLevelTerm",[]],["terminal",{"sourceInterval":[487,490]},"|"]]]]],"OverrideTopLevelTerm_superSplice":["define",{"sourceInterval":[522,543]},null,[],["terminal",{"sourceInterval":[522,527]},"..."]],"OverrideTopLevelTerm":["define",{"sourceInterval":[495,562]},null,[],["alt",{"sourceInterval":[522,562]},["app",{"sourceInterval":[522,527]},"OverrideTopLevelTerm_superSplice",[]],["app",{"sourceInterval":[550,562]},"TopLevelTerm",[]]]],"Formals":["define",{"sourceInterval":[566,606]},null,[],["seq",{"sourceInterval":[580,606]},["terminal",{"sourceInterval":[580,583]},"<"],["app",{"sourceInterval":[584,602]},"ListOf",[["app",{"sourceInterval":[591,596]},"ident",[]],["terminal",{"sourceInterval":[598,601]},","]]],["terminal",{"sourceInterval":[603,606]},">"]]],"Params":["define",{"sourceInterval":[610,647]},null,[],["seq",{"sourceInterval":[623,647]},["terminal",{"sourceInterval":[623,626]},"<"],["app",{"sourceInterval":[627,643]},"ListOf",[["app",{"sourceInterval":[634,637]},"Seq",[]],["terminal",{"sourceInterval":[639,642]},","]]],["terminal",{"sourceInterval":[644,647]},">"]]],"Alt":["define",{"sourceInterval":[651,685]},null,[],["app",{"sourceInterval":[661,685]},"NonemptyListOf",[["app",{"sourceInterval":[676,679]},"Seq",[]],["terminal",{"sourceInterval":[681,684]},"|"]]]],"Seq":["define",{"sourceInterval":[689,704]},null,[],["star",{"sourceInterval":[699,704]},["app",{"sourceInterval":[699,703]},"Iter",[]]]],"Iter_star":["define",{"sourceInterval":[719,736]},null,[],["seq",{"sourceInterval":[719,727]},["app",{"sourceInterval":[719,723]},"Pred",[]],["terminal",{"sourceInterval":[724,727]},"*"]]],"Iter_plus":["define",{"sourceInterval":[743,760]},null,[],["seq",{"sourceInterval":[743,751]},["app",{"sourceInterval":[743,747]},"Pred",[]],["terminal",{"sourceInterval":[748,751]},"+"]]],"Iter_opt":["define",{"sourceInterval":[767,783]},null,[],["seq",{"sourceInterval":[767,775]},["app",{"sourceInterval":[767,771]},"Pred",[]],["terminal",{"sourceInterval":[772,775]},"?"]]],"Iter":["define",{"sourceInterval":[708,794]},null,[],["alt",{"sourceInterval":[719,794]},["app",{"sourceInterval":[719,727]},"Iter_star",[]],["app",{"sourceInterval":[743,751]},"Iter_plus",[]],["app",{"sourceInterval":[767,775]},"Iter_opt",[]],["app",{"sourceInterval":[790,794]},"Pred",[]]]],"Pred_not":["define",{"sourceInterval":[809,824]},null,[],["seq",{"sourceInterval":[809,816]},["terminal",{"sourceInterval":[809,812]},"~"],["app",{"sourceInterval":[813,816]},"Lex",[]]]],"Pred_lookahead":["define",{"sourceInterval":[831,852]},null,[],["seq",{"sourceInterval":[831,838]},["terminal",{"sourceInterval":[831,834]},"&"],["app",{"sourceInterval":[835,838]},"Lex",[]]]],"Pred":["define",{"sourceInterval":[798,862]},null,[],["alt",{"sourceInterval":[809,862]},["app",{"sourceInterval":[809,816]},"Pred_not",[]],["app",{"sourceInterval":[831,838]},"Pred_lookahead",[]],["app",{"sourceInterval":[859,862]},"Lex",[]]]],"Lex_lex":["define",{"sourceInterval":[876,892]},null,[],["seq",{"sourceInterval":[876,884]},["terminal",{"sourceInterval":[876,879]},"#"],["app",{"sourceInterval":[880,884]},"Base",[]]]],"Lex":["define",{"sourceInterval":[866,903]},null,[],["alt",{"sourceInterval":[876,903]},["app",{"sourceInterval":[876,884]},"Lex_lex",[]],["app",{"sourceInterval":[899,903]},"Base",[]]]],"Base_application":["define",{"sourceInterval":[918,979]},null,[],["seq",{"sourceInterval":[918,963]},["app",{"sourceInterval":[918,923]},"ident",[]],["opt",{"sourceInterval":[924,931]},["app",{"sourceInterval":[924,930]},"Params",[]]],["not",{"sourceInterval":[932,963]},["alt",{"sourceInterval":[934,962]},["seq",{"sourceInterval":[934,948]},["opt",{"sourceInterval":[934,944]},["app",{"sourceInterval":[934,943]},"ruleDescr",[]]],["terminal",{"sourceInterval":[945,948]},"="]],["terminal",{"sourceInterval":[951,955]},":="],["terminal",{"sourceInterval":[958,962]},"+="]]]]],"Base_range":["define",{"sourceInterval":[986,1041]},null,[],["seq",{"sourceInterval":[986,1022]},["app",{"sourceInterval":[986,1001]},"oneCharTerminal",[]],["terminal",{"sourceInterval":[1002,1006]},".."],["app",{"sourceInterval":[1007,1022]},"oneCharTerminal",[]]]],"Base_terminal":["define",{"sourceInterval":[1048,1106]},null,[],["app",{"sourceInterval":[1048,1056]},"terminal",[]]],"Base_paren":["define",{"sourceInterval":[1113,1168]},null,[],["seq",{"sourceInterval":[1113,1124]},["terminal",{"sourceInterval":[1113,1116]},"("],["app",{"sourceInterval":[1117,1120]},"Alt",[]],["terminal",{"sourceInterval":[1121,1124]},")"]]],"Base":["define",{"sourceInterval":[907,1168]},null,[],["alt",{"sourceInterval":[918,1168]},["app",{"sourceInterval":[918,963]},"Base_application",[]],["app",{"sourceInterval":[986,1022]},"Base_range",[]],["app",{"sourceInterval":[1048,1056]},"Base_terminal",[]],["app",{"sourceInterval":[1113,1124]},"Base_paren",[]]]],"ruleDescr":["define",{"sourceInterval":[1172,1231]},"a rule description",[],["seq",{"sourceInterval":[1210,1231]},["terminal",{"sourceInterval":[1210,1213]},"("],["app",{"sourceInterval":[1214,1227]},"ruleDescrText",[]],["terminal",{"sourceInterval":[1228,1231]},")"]]],"ruleDescrText":["define",{"sourceInterval":[1235,1266]},null,[],["star",{"sourceInterval":[1255,1266]},["seq",{"sourceInterval":[1256,1264]},["not",{"sourceInterval":[1256,1260]},["terminal",{"sourceInterval":[1257,1260]},")"]],["app",{"sourceInterval":[1261,1264]},"any",[]]]]],"caseName":["define",{"sourceInterval":[1270,1338]},null,[],["seq",{"sourceInterval":[1285,1338]},["terminal",{"sourceInterval":[1285,1289]},"--"],["star",{"sourceInterval":[1290,1304]},["seq",{"sourceInterval":[1291,1302]},["not",{"sourceInterval":[1291,1296]},["terminal",{"sourceInterval":[1292,1296]},"\n"]],["app",{"sourceInterval":[1297,1302]},"space",[]]]],["app",{"sourceInterval":[1305,1309]},"name",[]],["star",{"sourceInterval":[1310,1324]},["seq",{"sourceInterval":[1311,1322]},["not",{"sourceInterval":[1311,1316]},["terminal",{"sourceInterval":[1312,1316]},"\n"]],["app",{"sourceInterval":[1317,1322]},"space",[]]]],["alt",{"sourceInterval":[1326,1337]},["terminal",{"sourceInterval":[1326,1330]},"\n"],["lookahead",{"sourceInterval":[1333,1337]},["terminal",{"sourceInterval":[1334,1337]},"}"]]]]],"name":["define",{"sourceInterval":[1342,1382]},"a name",[],["seq",{"sourceInterval":[1363,1382]},["app",{"sourceInterval":[1363,1372]},"nameFirst",[]],["star",{"sourceInterval":[1373,1382]},["app",{"sourceInterval":[1373,1381]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[1386,1418]},null,[],["alt",{"sourceInterval":[1402,1418]},["terminal",{"sourceInterval":[1402,1405]},"_"],["app",{"sourceInterval":[1412,1418]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[1422,1452]},null,[],["alt",{"sourceInterval":[1437,1452]},["terminal",{"sourceInterval":[1437,1440]},"_"],["app",{"sourceInterval":[1447,1452]},"alnum",[]]]],"ident":["define",{"sourceInterval":[1456,1489]},"an identifier",[],["app",{"sourceInterval":[1485,1489]},"name",[]]],"terminal":["define",{"sourceInterval":[1493,1531]},null,[],["seq",{"sourceInterval":[1508,1531]},["terminal",{"sourceInterval":[1508,1512]},"\""],["star",{"sourceInterval":[1513,1526]},["app",{"sourceInterval":[1513,1525]},"terminalChar",[]]],["terminal",{"sourceInterval":[1527,1531]},"\""]]],"oneCharTerminal":["define",{"sourceInterval":[1535,1579]},null,[],["seq",{"sourceInterval":[1557,1579]},["terminal",{"sourceInterval":[1557,1561]},"\""],["app",{"sourceInterval":[1562,1574]},"terminalChar",[]],["terminal",{"sourceInterval":[1575,1579]},"\""]]],"terminalChar":["define",{"sourceInterval":[1583,1660]},null,[],["alt",{"sourceInterval":[1602,1660]},["app",{"sourceInterval":[1602,1612]},"escapeChar",[]],["seq",{"sourceInterval":[1621,1660]},["not",{"sourceInterval":[1621,1626]},["terminal",{"sourceInterval":[1622,1626]},"\\"]],["not",{"sourceInterval":[1627,1632]},["terminal",{"sourceInterval":[1628,1632]},"\""]],["not",{"sourceInterval":[1633,1638]},["terminal",{"sourceInterval":[1634,1638]},"\n"]],["range",{"sourceInterval":[1639,1660]},"\u0000",""]]]],"escapeChar_backslash":["define",{"sourceInterval":[1703,1758]},null,[],["terminal",{"sourceInterval":[1703,1709]},"\\\\"]],"escapeChar_doubleQuote":["define",{"sourceInterval":[1765,1822]},null,[],["terminal",{"sourceInterval":[1765,1771]},"\\\""]],"escapeChar_singleQuote":["define",{"sourceInterval":[1829,1886]},null,[],["terminal",{"sourceInterval":[1829,1835]},"\\'"]],"escapeChar_backspace":["define",{"sourceInterval":[1893,1948]},null,[],["terminal",{"sourceInterval":[1893,1898]},"\\b"]],"escapeChar_lineFeed":["define",{"sourceInterval":[1955,2009]},null,[],["terminal",{"sourceInterval":[1955,1960]},"\\n"]],"escapeChar_carriageReturn":["define",{"sourceInterval":[2016,2076]},null,[],["terminal",{"sourceInterval":[2016,2021]},"\\r"]],"escapeChar_tab":["define",{"sourceInterval":[2083,2132]},null,[],["terminal",{"sourceInterval":[2083,2088]},"\\t"]],"escapeChar_unicodeCodePoint":["define",{"sourceInterval":[2139,2243]},null,[],["seq",{"sourceInterval":[2139,2221]},["terminal",{"sourceInterval":[2139,2145]},"\\u{"],["app",{"sourceInterval":[2146,2154]},"hexDigit",[]],["opt",{"sourceInterval":[2155,2164]},["app",{"sourceInterval":[2155,2163]},"hexDigit",[]]],["opt",{"sourceInterval":[2165,2174]},["app",{"sourceInterval":[2165,2173]},"hexDigit",[]]],["opt",{"sourceInterval":[2188,2197]},["app",{"sourceInterval":[2188,2196]},"hexDigit",[]]],["opt",{"sourceInterval":[2198,2207]},["app",{"sourceInterval":[2198,2206]},"hexDigit",[]]],["opt",{"sourceInterval":[2208,2217]},["app",{"sourceInterval":[2208,2216]},"hexDigit",[]]],["terminal",{"sourceInterval":[2218,2221]},"}"]]],"escapeChar_unicodeEscape":["define",{"sourceInterval":[2250,2309]},null,[],["seq",{"sourceInterval":[2250,2291]},["terminal",{"sourceInterval":[2250,2255]},"\\u"],["app",{"sourceInterval":[2256,2264]},"hexDigit",[]],["app",{"sourceInterval":[2265,2273]},"hexDigit",[]],["app",{"sourceInterval":[2274,2282]},"hexDigit",[]],["app",{"sourceInterval":[2283,2291]},"hexDigit",[]]]],"escapeChar_hexEscape":["define",{"sourceInterval":[2316,2371]},null,[],["seq",{"sourceInterval":[2316,2339]},["terminal",{"sourceInterval":[2316,2321]},"\\x"],["app",{"sourceInterval":[2322,2330]},"hexDigit",[]],["app",{"sourceInterval":[2331,2339]},"hexDigit",[]]]],"escapeChar":["define",{"sourceInterval":[1664,2371]},"an escape sequence",[],["alt",{"sourceInterval":[1703,2371]},["app",{"sourceInterval":[1703,1709]},"escapeChar_backslash",[]],["app",{"sourceInterval":[1765,1771]},"escapeChar_doubleQuote",[]],["app",{"sourceInterval":[1829,1835]},"escapeChar_singleQuote",[]],["app",{"sourceInterval":[1893,1898]},"escapeChar_backspace",[]],["app",{"sourceInterval":[1955,1960]},"escapeChar_lineFeed",[]],["app",{"sourceInterval":[2016,2021]},"escapeChar_carriageReturn",[]],["app",{"sourceInterval":[2083,2088]},"escapeChar_tab",[]],["app",{"sourceInterval":[2139,2221]},"escapeChar_unicodeCodePoint",[]],["app",{"sourceInterval":[2250,2291]},"escapeChar_unicodeEscape",[]],["app",{"sourceInterval":[2316,2339]},"escapeChar_hexEscape",[]]]],"space":["extend",{"sourceInterval":[2375,2394]},null,[],["app",{"sourceInterval":[2387,2394]},"comment",[]]],"comment_singleLine":["define",{"sourceInterval":[2412,2458]},null,[],["seq",{"sourceInterval":[2412,2443]},["terminal",{"sourceInterval":[2412,2416]},"//"],["star",{"sourceInterval":[2417,2429]},["seq",{"sourceInterval":[2418,2427]},["not",{"sourceInterval":[2418,2423]},["terminal",{"sourceInterval":[2419,2423]},"\n"]],["app",{"sourceInterval":[2424,2427]},"any",[]]]],["lookahead",{"sourceInterval":[2430,2443]},["alt",{"sourceInterval":[2432,2442]},["terminal",{"sourceInterval":[2432,2436]},"\n"],["app",{"sourceInterval":[2439,2442]},"end",[]]]]]],"comment_multiLine":["define",{"sourceInterval":[2465,2501]},null,[],["seq",{"sourceInterval":[2465,2487]},["terminal",{"sourceInterval":[2465,2469]},"/*"],["star",{"sourceInterval":[2470,2482]},["seq",{"sourceInterval":[2471,2480]},["not",{"sourceInterval":[2471,2476]},["terminal",{"sourceInterval":[2472,2476]},"*/"]],["app",{"sourceInterval":[2477,2480]},"any",[]]]],["terminal",{"sourceInterval":[2483,2487]},"*/"]]],"comment":["define",{"sourceInterval":[2398,2501]},null,[],["alt",{"sourceInterval":[2412,2501]},["app",{"sourceInterval":[2412,2443]},"comment_singleLine",[]],["app",{"sourceInterval":[2465,2487]},"comment_multiLine",[]]]],"tokens":["define",{"sourceInterval":[2505,2520]},null,[],["star",{"sourceInterval":[2514,2520]},["app",{"sourceInterval":[2514,2519]},"token",[]]]],"token":["define",{"sourceInterval":[2524,2600]},null,[],["alt",{"sourceInterval":[2532,2600]},["app",{"sourceInterval":[2532,2540]},"caseName",[]],["app",{"sourceInterval":[2543,2550]},"comment",[]],["app",{"sourceInterval":[2553,2558]},"ident",[]],["app",{"sourceInterval":[2561,2569]},"operator",[]],["app",{"sourceInterval":[2572,2583]},"punctuation",[]],["app",{"sourceInterval":[2586,2594]},"terminal",[]],["app",{"sourceInterval":[2597,2600]},"any",[]]]],"operator":["define",{"sourceInterval":[2604,2669]},null,[],["alt",{"sourceInterval":[2615,2669]},["terminal",{"sourceInterval":[2615,2619]},"<:"],["terminal",{"sourceInterval":[2622,2625]},"="],["terminal",{"sourceInterval":[2628,2632]},":="],["terminal",{"sourceInterval":[2635,2639]},"+="],["terminal",{"sourceInterval":[2642,2645]},"*"],["terminal",{"sourceInterval":[2648,2651]},"+"],["terminal",{"sourceInterval":[2654,2657]},"?"],["terminal",{"sourceInterval":[2660,2663]},"~"],["terminal",{"sourceInterval":[2666,2669]},"&"]]],"punctuation":["define",{"sourceInterval":[2673,2709]},null,[],["alt",{"sourceInterval":[2687,2709]},["terminal",{"sourceInterval":[2687,2690]},"<"],["terminal",{"sourceInterval":[2693,2696]},">"],["terminal",{"sourceInterval":[2699,2702]},","],["terminal",{"sourceInterval":[2705,2709]},"--"]]]}]);
|
|
5743
5724
|
|
|
5744
5725
|
// --------------------------------------------------------------------
|
|
5745
5726
|
// Imports
|
|
5746
5727
|
// --------------------------------------------------------------------
|
|
5747
5728
|
|
|
5748
5729
|
const Builder = Builder_1;
|
|
5749
|
-
const Grammar
|
|
5730
|
+
const Grammar = Grammar_1;
|
|
5750
5731
|
const Namespace = Namespace_1;
|
|
5751
5732
|
const common = common$l;
|
|
5752
5733
|
const errors = errors$9;
|
|
5753
|
-
const pexprs
|
|
5734
|
+
const pexprs = pexprs$6;
|
|
5754
5735
|
const util = util$7;
|
|
5755
5736
|
const version = version$1;
|
|
5756
5737
|
const {makeRecipe} = makeRecipe$5;
|
|
@@ -5763,7 +5744,7 @@ const {makeRecipe} = makeRecipe$5;
|
|
|
5763
5744
|
// bottom of this file because loading the grammar requires Ohm itself.
|
|
5764
5745
|
let ohmGrammar;
|
|
5765
5746
|
|
|
5766
|
-
const superSplicePlaceholder = Object.create(pexprs
|
|
5747
|
+
const superSplicePlaceholder = Object.create(pexprs.PExpr.prototype);
|
|
5767
5748
|
|
|
5768
5749
|
const isBuffer = obj =>
|
|
5769
5750
|
!!obj.constructor &&
|
|
@@ -5818,7 +5799,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5818
5799
|
currentRuleFormals = fs.children.map(c => c.visit())[0] || [];
|
|
5819
5800
|
// If there is no default start rule yet, set it now. This must be done before visiting
|
|
5820
5801
|
// the body, because it might contain an inline rule definition.
|
|
5821
|
-
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar
|
|
5802
|
+
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar.ProtoBuiltInRules) {
|
|
5822
5803
|
decl.withDefaultStartRule(currentRuleName);
|
|
5823
5804
|
}
|
|
5824
5805
|
const body = b.visit();
|
|
@@ -5862,7 +5843,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5862
5843
|
if (t === superSplicePlaceholder) throw errors.multipleSuperSplices(t);
|
|
5863
5844
|
});
|
|
5864
5845
|
|
|
5865
|
-
return new pexprs
|
|
5846
|
+
return new pexprs.Splice(
|
|
5866
5847
|
decl.superGrammar,
|
|
5867
5848
|
currentRuleName,
|
|
5868
5849
|
beforeTerms,
|
|
@@ -5967,8 +5948,15 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5967
5948
|
return c.visit();
|
|
5968
5949
|
},
|
|
5969
5950
|
|
|
5970
|
-
|
|
5971
|
-
|
|
5951
|
+
escapeChar(c) {
|
|
5952
|
+
try {
|
|
5953
|
+
return common.unescapeCodePoint(this.sourceString);
|
|
5954
|
+
} catch (err) {
|
|
5955
|
+
if (err instanceof RangeError && err.message.startsWith('Invalid code point ')) {
|
|
5956
|
+
throw errors.invalidCodePoint(c);
|
|
5957
|
+
}
|
|
5958
|
+
throw err; // Rethrow
|
|
5959
|
+
}
|
|
5972
5960
|
},
|
|
5973
5961
|
|
|
5974
5962
|
NonemptyListOf(x, _, xs) {
|
|
@@ -6052,7 +6040,7 @@ main$1.exports = {
|
|
|
6052
6040
|
grammarsFromScriptElements,
|
|
6053
6041
|
makeRecipe,
|
|
6054
6042
|
ohmGrammar: null, // Initialized below, after Grammar.BuiltInRules.
|
|
6055
|
-
pexprs
|
|
6043
|
+
pexprs,
|
|
6056
6044
|
util,
|
|
6057
6045
|
version,
|
|
6058
6046
|
};
|
|
@@ -6063,10 +6051,10 @@ main$1.exports._buildGrammar = buildGrammar;
|
|
|
6063
6051
|
// Late initialization for stuff that is bootstrapped.
|
|
6064
6052
|
|
|
6065
6053
|
|
|
6066
|
-
util.announceBuiltInRules(Grammar
|
|
6054
|
+
util.announceBuiltInRules(Grammar.BuiltInRules);
|
|
6067
6055
|
|
|
6068
6056
|
main$1.exports.ohmGrammar = ohmGrammar = ohmGrammar$1;
|
|
6069
|
-
Grammar
|
|
6057
|
+
Grammar.initApplicationParser(ohmGrammar, buildGrammar);
|
|
6070
6058
|
|
|
6071
6059
|
var ohm = main$1.exports;
|
|
6072
6060
|
|
|
@@ -6240,14 +6228,6 @@ VisitorFamily.prototype.addOperation = function(signature, actions) {
|
|
|
6240
6228
|
|
|
6241
6229
|
var VisitorFamily_1 = VisitorFamily;
|
|
6242
6230
|
|
|
6243
|
-
// --------------------------------------------------------------------
|
|
6244
|
-
// Imports
|
|
6245
|
-
// --------------------------------------------------------------------
|
|
6246
|
-
|
|
6247
|
-
const pexprs = pexprs$7;
|
|
6248
|
-
const MatchResult = MatchResult_1;
|
|
6249
|
-
const Grammar = Grammar_1;
|
|
6250
|
-
|
|
6251
6231
|
// --------------------------------------------------------------------
|
|
6252
6232
|
// Operations
|
|
6253
6233
|
// --------------------------------------------------------------------
|
|
@@ -6263,11 +6243,6 @@ const defaultOperation = {
|
|
|
6263
6243
|
|
|
6264
6244
|
// without customization
|
|
6265
6245
|
if (!Object.prototype.hasOwnProperty.call(mapping, ctorName)) {
|
|
6266
|
-
// intermediate node
|
|
6267
|
-
if (this._node instanceof pexprs.Alt || this._node instanceof pexprs.Apply) {
|
|
6268
|
-
return children[0].toAST(mapping);
|
|
6269
|
-
}
|
|
6270
|
-
|
|
6271
6246
|
// lexical rule
|
|
6272
6247
|
if (this.isLexical()) {
|
|
6273
6248
|
return this.sourceString;
|
|
@@ -6351,8 +6326,8 @@ const defaultOperation = {
|
|
|
6351
6326
|
// The optional `mapping` parameter can be used to customize how the nodes of the CST
|
|
6352
6327
|
// are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).
|
|
6353
6328
|
function toAST(res, mapping) {
|
|
6354
|
-
if (
|
|
6355
|
-
throw new Error('toAST() expects a
|
|
6329
|
+
if (typeof res.failed !== 'function' || res.failed()) {
|
|
6330
|
+
throw new Error('toAST() expects a succesful MatchResult as first parameter');
|
|
6356
6331
|
}
|
|
6357
6332
|
|
|
6358
6333
|
mapping = Object.assign({}, mapping);
|
|
@@ -6370,7 +6345,7 @@ function toAST(res, mapping) {
|
|
|
6370
6345
|
|
|
6371
6346
|
// Returns a semantics containg the toAST(mapping) operation for the given grammar g.
|
|
6372
6347
|
function semanticsForToAST(g) {
|
|
6373
|
-
if (
|
|
6348
|
+
if (typeof g.createSemantics !== 'function') {
|
|
6374
6349
|
throw new Error('semanticsToAST() expects a Grammar as parameter');
|
|
6375
6350
|
}
|
|
6376
6351
|
|