ohm-js 16.2.0 → 16.3.1
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 +40 -15
- package/dist/built-in-rules.js.old +2 -0
- package/dist/ohm-grammar.js +1 -1
- package/dist/ohm-grammar.js.old +2 -0
- package/dist/ohm.esm.js +388 -367
- package/dist/ohm.js +56 -33
- package/dist/ohm.min.js +1 -1
- package/extras/semantics-toAST.js +3 -16
- package/package.json +13 -11
- package/src/InputStream.js +15 -0
- package/src/common.js +7 -18
- package/src/errors.js +19 -3
- package/src/main.js +9 -6
- package/src/ohm-grammar.ohm +3 -1
- package/src/pexprs-eval.js +9 -3
- 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,22 +237,9 @@ exports.StringBuffer.prototype.contents = function() {
|
|
|
237
237
|
return this.strings.join('');
|
|
238
238
|
};
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
const escapeUnicode = str => String.fromCodePoint(parseInt(str, 16));
|
|
241
241
|
|
|
242
|
-
exports.
|
|
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
|
-
exports.unescapeChar = function(s) {
|
|
242
|
+
exports.unescapeCodePoint = function(s) {
|
|
256
243
|
if (s.charAt(0) === '\\') {
|
|
257
244
|
switch (s.charAt(1)) {
|
|
258
245
|
case 'b':
|
|
@@ -268,9 +255,11 @@ exports.unescapeChar = function(s) {
|
|
|
268
255
|
case 'v':
|
|
269
256
|
return '\v';
|
|
270
257
|
case 'x':
|
|
271
|
-
return
|
|
258
|
+
return escapeUnicode(s.slice(2, 4));
|
|
272
259
|
case 'u':
|
|
273
|
-
return
|
|
260
|
+
return s.charAt(2) === '{' ?
|
|
261
|
+
escapeUnicode(s.slice(3, -1)) :
|
|
262
|
+
escapeUnicode(s.slice(2, 6));
|
|
274
263
|
default:
|
|
275
264
|
return s.charAt(1);
|
|
276
265
|
}
|
|
@@ -587,6 +576,9 @@ class Range extends PExpr$1 {
|
|
|
587
576
|
super();
|
|
588
577
|
this.from = from;
|
|
589
578
|
this.to = to;
|
|
579
|
+
// If either `from` or `to` is made up of multiple code units, then
|
|
580
|
+
// the range should consume a full code point, not a single code unit.
|
|
581
|
+
this.matchCodePoint = from.length > 1 || to.length > 1;
|
|
590
582
|
}
|
|
591
583
|
}
|
|
592
584
|
|
|
@@ -753,7 +745,7 @@ pexprsMain.UnicodeChar = UnicodeChar;
|
|
|
753
745
|
// --------------------------------------------------------------------
|
|
754
746
|
|
|
755
747
|
const common$i = common$l;
|
|
756
|
-
const pexprs$
|
|
748
|
+
const pexprs$l = pexprsMain;
|
|
757
749
|
|
|
758
750
|
// --------------------------------------------------------------------
|
|
759
751
|
// Operations
|
|
@@ -762,7 +754,7 @@ const pexprs$m = pexprsMain;
|
|
|
762
754
|
/*
|
|
763
755
|
Return true if we should skip spaces preceding this expression in a syntactic context.
|
|
764
756
|
*/
|
|
765
|
-
pexprs$
|
|
757
|
+
pexprs$l.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
766
758
|
'allowsSkippingPrecedingSpace'
|
|
767
759
|
);
|
|
768
760
|
|
|
@@ -770,12 +762,12 @@ pexprs$m.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
|
770
762
|
Generally, these are all first-order expressions and (with the exception of Apply)
|
|
771
763
|
directly read from the input stream.
|
|
772
764
|
*/
|
|
773
|
-
pexprs$
|
|
774
|
-
pexprs$
|
|
775
|
-
pexprs$
|
|
776
|
-
pexprs$
|
|
777
|
-
pexprs$
|
|
778
|
-
pexprs$
|
|
765
|
+
pexprs$l.any.allowsSkippingPrecedingSpace =
|
|
766
|
+
pexprs$l.end.allowsSkippingPrecedingSpace =
|
|
767
|
+
pexprs$l.Apply.prototype.allowsSkippingPrecedingSpace =
|
|
768
|
+
pexprs$l.Terminal.prototype.allowsSkippingPrecedingSpace =
|
|
769
|
+
pexprs$l.Range.prototype.allowsSkippingPrecedingSpace =
|
|
770
|
+
pexprs$l.UnicodeChar.prototype.allowsSkippingPrecedingSpace =
|
|
779
771
|
function() {
|
|
780
772
|
return true;
|
|
781
773
|
};
|
|
@@ -783,13 +775,13 @@ pexprs$m.any.allowsSkippingPrecedingSpace =
|
|
|
783
775
|
/*
|
|
784
776
|
Higher-order expressions that don't directly consume input.
|
|
785
777
|
*/
|
|
786
|
-
pexprs$
|
|
787
|
-
pexprs$
|
|
788
|
-
pexprs$
|
|
789
|
-
pexprs$
|
|
790
|
-
pexprs$
|
|
791
|
-
pexprs$
|
|
792
|
-
pexprs$
|
|
778
|
+
pexprs$l.Alt.prototype.allowsSkippingPrecedingSpace =
|
|
779
|
+
pexprs$l.Iter.prototype.allowsSkippingPrecedingSpace =
|
|
780
|
+
pexprs$l.Lex.prototype.allowsSkippingPrecedingSpace =
|
|
781
|
+
pexprs$l.Lookahead.prototype.allowsSkippingPrecedingSpace =
|
|
782
|
+
pexprs$l.Not.prototype.allowsSkippingPrecedingSpace =
|
|
783
|
+
pexprs$l.Param.prototype.allowsSkippingPrecedingSpace =
|
|
784
|
+
pexprs$l.Seq.prototype.allowsSkippingPrecedingSpace =
|
|
793
785
|
function() {
|
|
794
786
|
return false;
|
|
795
787
|
};
|
|
@@ -846,9 +838,9 @@ var Namespace_1 = Namespace$2;
|
|
|
846
838
|
// Imports
|
|
847
839
|
// --------------------------------------------------------------------
|
|
848
840
|
|
|
849
|
-
const
|
|
850
|
-
|
|
841
|
+
const {assert: assert$3} = common$l;
|
|
851
842
|
const Namespace$1 = Namespace_1;
|
|
843
|
+
const pexprs$k = pexprsMain;
|
|
852
844
|
|
|
853
845
|
// --------------------------------------------------------------------
|
|
854
846
|
// Private stuff
|
|
@@ -978,7 +970,7 @@ function wrongNumberOfArguments(ruleName, expected, actual, expr) {
|
|
|
978
970
|
', got ' +
|
|
979
971
|
actual +
|
|
980
972
|
')',
|
|
981
|
-
expr
|
|
973
|
+
expr
|
|
982
974
|
);
|
|
983
975
|
}
|
|
984
976
|
|
|
@@ -1051,6 +1043,21 @@ function multipleSuperSplices(expr) {
|
|
|
1051
1043
|
return createError("'...' can appear at most once in a rule body", expr.source);
|
|
1052
1044
|
}
|
|
1053
1045
|
|
|
1046
|
+
// Unicode code point escapes
|
|
1047
|
+
|
|
1048
|
+
function invalidCodePoint(applyWrapper) {
|
|
1049
|
+
const node = applyWrapper._node;
|
|
1050
|
+
assert$3(node && node.isNonterminal() && node.ctorName === 'escapeChar_unicodeCodePoint');
|
|
1051
|
+
|
|
1052
|
+
// Get an interval that covers all of the hex digits.
|
|
1053
|
+
const digitIntervals = applyWrapper.children.slice(1, -1).map(d => d.source);
|
|
1054
|
+
const fullInterval = digitIntervals[0].coverageWith(...digitIntervals.slice(1));
|
|
1055
|
+
return createError(
|
|
1056
|
+
`U+${fullInterval.contents} is not a valid Unicode code point`,
|
|
1057
|
+
fullInterval
|
|
1058
|
+
);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1054
1061
|
// ----------------- Kleene operators -----------------
|
|
1055
1062
|
|
|
1056
1063
|
function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
@@ -1065,7 +1072,7 @@ function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
|
1065
1072
|
"' (possible infinite loop)";
|
|
1066
1073
|
if (applicationStack.length > 0) {
|
|
1067
1074
|
const stackTrace = applicationStack
|
|
1068
|
-
.map(app => new pexprs$
|
|
1075
|
+
.map(app => new pexprs$k.Apply(app.ruleName, app.args))
|
|
1069
1076
|
.join('\n');
|
|
1070
1077
|
message += '\nApplication stack (most recent application last):\n' + stackTrace;
|
|
1071
1078
|
}
|
|
@@ -1156,6 +1163,7 @@ var errors$9 = {
|
|
|
1156
1163
|
inconsistentArity,
|
|
1157
1164
|
incorrectArgumentType,
|
|
1158
1165
|
intervalSourcesDontMatch,
|
|
1166
|
+
invalidCodePoint,
|
|
1159
1167
|
invalidConstructorCall,
|
|
1160
1168
|
invalidParameter,
|
|
1161
1169
|
grammarSyntaxError,
|
|
@@ -1367,7 +1375,7 @@ exports.uniqueId = (() => {
|
|
|
1367
1375
|
|
|
1368
1376
|
const {abstract, isSyntactic} = common$l;
|
|
1369
1377
|
const errors$8 = errors$9;
|
|
1370
|
-
const pexprs$
|
|
1378
|
+
const pexprs$j = pexprsMain;
|
|
1371
1379
|
const util$6 = util$7;
|
|
1372
1380
|
|
|
1373
1381
|
let BuiltInRules;
|
|
@@ -1382,51 +1390,51 @@ util$6.awaitBuiltInRules(g => {
|
|
|
1382
1390
|
|
|
1383
1391
|
let lexifyCount;
|
|
1384
1392
|
|
|
1385
|
-
pexprs$
|
|
1393
|
+
pexprs$j.PExpr.prototype.assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1386
1394
|
lexifyCount = 0;
|
|
1387
1395
|
this._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1388
1396
|
};
|
|
1389
1397
|
|
|
1390
|
-
pexprs$
|
|
1398
|
+
pexprs$j.PExpr.prototype._assertAllApplicationsAreValid = abstract(
|
|
1391
1399
|
'_assertAllApplicationsAreValid'
|
|
1392
1400
|
);
|
|
1393
1401
|
|
|
1394
|
-
pexprs$
|
|
1395
|
-
pexprs$
|
|
1396
|
-
pexprs$
|
|
1397
|
-
pexprs$
|
|
1398
|
-
pexprs$
|
|
1399
|
-
pexprs$
|
|
1402
|
+
pexprs$j.any._assertAllApplicationsAreValid =
|
|
1403
|
+
pexprs$j.end._assertAllApplicationsAreValid =
|
|
1404
|
+
pexprs$j.Terminal.prototype._assertAllApplicationsAreValid =
|
|
1405
|
+
pexprs$j.Range.prototype._assertAllApplicationsAreValid =
|
|
1406
|
+
pexprs$j.Param.prototype._assertAllApplicationsAreValid =
|
|
1407
|
+
pexprs$j.UnicodeChar.prototype._assertAllApplicationsAreValid =
|
|
1400
1408
|
function(ruleName, grammar) {
|
|
1401
1409
|
// no-op
|
|
1402
1410
|
};
|
|
1403
1411
|
|
|
1404
|
-
pexprs$
|
|
1412
|
+
pexprs$j.Lex.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1405
1413
|
lexifyCount++;
|
|
1406
1414
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1407
1415
|
lexifyCount--;
|
|
1408
1416
|
};
|
|
1409
1417
|
|
|
1410
|
-
pexprs$
|
|
1418
|
+
pexprs$j.Alt.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1411
1419
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1412
1420
|
this.terms[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1413
1421
|
}
|
|
1414
1422
|
};
|
|
1415
1423
|
|
|
1416
|
-
pexprs$
|
|
1424
|
+
pexprs$j.Seq.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1417
1425
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1418
1426
|
this.factors[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1419
1427
|
}
|
|
1420
1428
|
};
|
|
1421
1429
|
|
|
1422
|
-
pexprs$
|
|
1423
|
-
pexprs$
|
|
1424
|
-
pexprs$
|
|
1430
|
+
pexprs$j.Iter.prototype._assertAllApplicationsAreValid =
|
|
1431
|
+
pexprs$j.Not.prototype._assertAllApplicationsAreValid =
|
|
1432
|
+
pexprs$j.Lookahead.prototype._assertAllApplicationsAreValid =
|
|
1425
1433
|
function(ruleName, grammar) {
|
|
1426
1434
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1427
1435
|
};
|
|
1428
1436
|
|
|
1429
|
-
pexprs$
|
|
1437
|
+
pexprs$j.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
1430
1438
|
ruleName,
|
|
1431
1439
|
grammar,
|
|
1432
1440
|
skipSyntacticCheck = false
|
|
@@ -1458,14 +1466,14 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1458
1466
|
|
|
1459
1467
|
// If it's an application of 'caseInsensitive', ensure that the argument is a Terminal.
|
|
1460
1468
|
if (isBuiltInCaseInsensitive) {
|
|
1461
|
-
if (!(this.args[0] instanceof pexprs$
|
|
1469
|
+
if (!(this.args[0] instanceof pexprs$j.Terminal)) {
|
|
1462
1470
|
throw errors$8.incorrectArgumentType('a Terminal (e.g. "abc")', this.args[0]);
|
|
1463
1471
|
}
|
|
1464
1472
|
}
|
|
1465
1473
|
|
|
1466
1474
|
if (isBuiltInApplySyntactic) {
|
|
1467
1475
|
const arg = this.args[0];
|
|
1468
|
-
if (!(arg instanceof pexprs$
|
|
1476
|
+
if (!(arg instanceof pexprs$j.Apply)) {
|
|
1469
1477
|
throw errors$8.incorrectArgumentType('a syntactic rule application', arg);
|
|
1470
1478
|
}
|
|
1471
1479
|
if (!isSyntactic(arg.ruleName)) {
|
|
@@ -1493,28 +1501,28 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1493
1501
|
|
|
1494
1502
|
const common$h = common$l;
|
|
1495
1503
|
const errors$7 = errors$9;
|
|
1496
|
-
const pexprs$
|
|
1504
|
+
const pexprs$i = pexprsMain;
|
|
1497
1505
|
|
|
1498
1506
|
// --------------------------------------------------------------------
|
|
1499
1507
|
// Operations
|
|
1500
1508
|
// --------------------------------------------------------------------
|
|
1501
1509
|
|
|
1502
|
-
pexprs$
|
|
1510
|
+
pexprs$i.PExpr.prototype.assertChoicesHaveUniformArity = common$h.abstract(
|
|
1503
1511
|
'assertChoicesHaveUniformArity'
|
|
1504
1512
|
);
|
|
1505
1513
|
|
|
1506
|
-
pexprs$
|
|
1507
|
-
pexprs$
|
|
1508
|
-
pexprs$
|
|
1509
|
-
pexprs$
|
|
1510
|
-
pexprs$
|
|
1511
|
-
pexprs$
|
|
1512
|
-
pexprs$
|
|
1514
|
+
pexprs$i.any.assertChoicesHaveUniformArity =
|
|
1515
|
+
pexprs$i.end.assertChoicesHaveUniformArity =
|
|
1516
|
+
pexprs$i.Terminal.prototype.assertChoicesHaveUniformArity =
|
|
1517
|
+
pexprs$i.Range.prototype.assertChoicesHaveUniformArity =
|
|
1518
|
+
pexprs$i.Param.prototype.assertChoicesHaveUniformArity =
|
|
1519
|
+
pexprs$i.Lex.prototype.assertChoicesHaveUniformArity =
|
|
1520
|
+
pexprs$i.UnicodeChar.prototype.assertChoicesHaveUniformArity =
|
|
1513
1521
|
function(ruleName) {
|
|
1514
1522
|
// no-op
|
|
1515
1523
|
};
|
|
1516
1524
|
|
|
1517
|
-
pexprs$
|
|
1525
|
+
pexprs$i.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1518
1526
|
if (this.terms.length === 0) {
|
|
1519
1527
|
return;
|
|
1520
1528
|
}
|
|
@@ -1529,7 +1537,7 @@ pexprs$j.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1529
1537
|
}
|
|
1530
1538
|
};
|
|
1531
1539
|
|
|
1532
|
-
pexprs$
|
|
1540
|
+
pexprs$i.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1533
1541
|
// Extend is a special case of Alt that's guaranteed to have exactly two
|
|
1534
1542
|
// cases: [extensions, origBody].
|
|
1535
1543
|
const actualArity = this.terms[0].getArity();
|
|
@@ -1539,25 +1547,25 @@ pexprs$j.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1539
1547
|
}
|
|
1540
1548
|
};
|
|
1541
1549
|
|
|
1542
|
-
pexprs$
|
|
1550
|
+
pexprs$i.Seq.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1543
1551
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1544
1552
|
this.factors[idx].assertChoicesHaveUniformArity(ruleName);
|
|
1545
1553
|
}
|
|
1546
1554
|
};
|
|
1547
1555
|
|
|
1548
|
-
pexprs$
|
|
1556
|
+
pexprs$i.Iter.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1549
1557
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1550
1558
|
};
|
|
1551
1559
|
|
|
1552
|
-
pexprs$
|
|
1560
|
+
pexprs$i.Not.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1553
1561
|
// no-op (not required b/c the nested expr doesn't show up in the CST)
|
|
1554
1562
|
};
|
|
1555
1563
|
|
|
1556
|
-
pexprs$
|
|
1564
|
+
pexprs$i.Lookahead.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1557
1565
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1558
1566
|
};
|
|
1559
1567
|
|
|
1560
|
-
pexprs$
|
|
1568
|
+
pexprs$i.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1561
1569
|
// The arities of the parameter expressions is required to be 1 by
|
|
1562
1570
|
// `assertAllApplicationsAreValid()`.
|
|
1563
1571
|
};
|
|
@@ -1568,39 +1576,39 @@ pexprs$j.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1568
1576
|
|
|
1569
1577
|
const common$g = common$l;
|
|
1570
1578
|
const errors$6 = errors$9;
|
|
1571
|
-
const pexprs$
|
|
1579
|
+
const pexprs$h = pexprsMain;
|
|
1572
1580
|
|
|
1573
1581
|
// --------------------------------------------------------------------
|
|
1574
1582
|
// Operations
|
|
1575
1583
|
// --------------------------------------------------------------------
|
|
1576
1584
|
|
|
1577
|
-
pexprs$
|
|
1585
|
+
pexprs$h.PExpr.prototype.assertIteratedExprsAreNotNullable = common$g.abstract(
|
|
1578
1586
|
'assertIteratedExprsAreNotNullable'
|
|
1579
1587
|
);
|
|
1580
1588
|
|
|
1581
|
-
pexprs$
|
|
1582
|
-
pexprs$
|
|
1583
|
-
pexprs$
|
|
1584
|
-
pexprs$
|
|
1585
|
-
pexprs$
|
|
1586
|
-
pexprs$
|
|
1589
|
+
pexprs$h.any.assertIteratedExprsAreNotNullable =
|
|
1590
|
+
pexprs$h.end.assertIteratedExprsAreNotNullable =
|
|
1591
|
+
pexprs$h.Terminal.prototype.assertIteratedExprsAreNotNullable =
|
|
1592
|
+
pexprs$h.Range.prototype.assertIteratedExprsAreNotNullable =
|
|
1593
|
+
pexprs$h.Param.prototype.assertIteratedExprsAreNotNullable =
|
|
1594
|
+
pexprs$h.UnicodeChar.prototype.assertIteratedExprsAreNotNullable =
|
|
1587
1595
|
function(grammar) {
|
|
1588
1596
|
// no-op
|
|
1589
1597
|
};
|
|
1590
1598
|
|
|
1591
|
-
pexprs$
|
|
1599
|
+
pexprs$h.Alt.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1592
1600
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1593
1601
|
this.terms[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1594
1602
|
}
|
|
1595
1603
|
};
|
|
1596
1604
|
|
|
1597
|
-
pexprs$
|
|
1605
|
+
pexprs$h.Seq.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1598
1606
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1599
1607
|
this.factors[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1600
1608
|
}
|
|
1601
1609
|
};
|
|
1602
1610
|
|
|
1603
|
-
pexprs$
|
|
1611
|
+
pexprs$h.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1604
1612
|
// Note: this is the implementation of this method for `Star` and `Plus` expressions.
|
|
1605
1613
|
// It is overridden for `Opt` below.
|
|
1606
1614
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
@@ -1609,15 +1617,15 @@ pexprs$i.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
|
1609
1617
|
}
|
|
1610
1618
|
};
|
|
1611
1619
|
|
|
1612
|
-
pexprs$
|
|
1613
|
-
pexprs$
|
|
1614
|
-
pexprs$
|
|
1615
|
-
pexprs$
|
|
1620
|
+
pexprs$h.Opt.prototype.assertIteratedExprsAreNotNullable =
|
|
1621
|
+
pexprs$h.Not.prototype.assertIteratedExprsAreNotNullable =
|
|
1622
|
+
pexprs$h.Lookahead.prototype.assertIteratedExprsAreNotNullable =
|
|
1623
|
+
pexprs$h.Lex.prototype.assertIteratedExprsAreNotNullable =
|
|
1616
1624
|
function(grammar) {
|
|
1617
1625
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
1618
1626
|
};
|
|
1619
1627
|
|
|
1620
|
-
pexprs$
|
|
1628
|
+
pexprs$h.Apply.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1621
1629
|
this.args.forEach(arg => {
|
|
1622
1630
|
arg.assertIteratedExprsAreNotNullable(grammar);
|
|
1623
1631
|
});
|
|
@@ -1982,7 +1990,7 @@ const Trace$1 = Trace_1;
|
|
|
1982
1990
|
const common$e = common$l;
|
|
1983
1991
|
const errors$4 = errors$9;
|
|
1984
1992
|
const nodes = nodes$1;
|
|
1985
|
-
const pexprs$
|
|
1993
|
+
const pexprs$g = pexprsMain;
|
|
1986
1994
|
|
|
1987
1995
|
const {TerminalNode: TerminalNode$1} = nodes;
|
|
1988
1996
|
const {NonterminalNode} = nodes;
|
|
@@ -2008,9 +2016,9 @@ const {IterationNode: IterationNode$1} = nodes;
|
|
|
2008
2016
|
Note that `State.prototype.eval(expr)`, unlike this method, guarantees that neither the state
|
|
2009
2017
|
object's bindings nor its input stream's position will change if the expression fails to match.
|
|
2010
2018
|
*/
|
|
2011
|
-
pexprs$
|
|
2019
|
+
pexprs$g.PExpr.prototype.eval = common$e.abstract('eval'); // function(state) { ... }
|
|
2012
2020
|
|
|
2013
|
-
pexprs$
|
|
2021
|
+
pexprs$g.any.eval = function(state) {
|
|
2014
2022
|
const {inputStream} = state;
|
|
2015
2023
|
const origPos = inputStream.pos;
|
|
2016
2024
|
const ch = inputStream.next();
|
|
@@ -2023,7 +2031,7 @@ pexprs$h.any.eval = function(state) {
|
|
|
2023
2031
|
}
|
|
2024
2032
|
};
|
|
2025
2033
|
|
|
2026
|
-
pexprs$
|
|
2034
|
+
pexprs$g.end.eval = function(state) {
|
|
2027
2035
|
const {inputStream} = state;
|
|
2028
2036
|
const origPos = inputStream.pos;
|
|
2029
2037
|
if (inputStream.atEnd()) {
|
|
@@ -2035,7 +2043,7 @@ pexprs$h.end.eval = function(state) {
|
|
|
2035
2043
|
}
|
|
2036
2044
|
};
|
|
2037
2045
|
|
|
2038
|
-
pexprs$
|
|
2046
|
+
pexprs$g.Terminal.prototype.eval = function(state) {
|
|
2039
2047
|
const {inputStream} = state;
|
|
2040
2048
|
const origPos = inputStream.pos;
|
|
2041
2049
|
if (!inputStream.matchString(this.obj)) {
|
|
@@ -2047,12 +2055,18 @@ pexprs$h.Terminal.prototype.eval = function(state) {
|
|
|
2047
2055
|
}
|
|
2048
2056
|
};
|
|
2049
2057
|
|
|
2050
|
-
pexprs$
|
|
2058
|
+
pexprs$g.Range.prototype.eval = function(state) {
|
|
2051
2059
|
const {inputStream} = state;
|
|
2052
2060
|
const origPos = inputStream.pos;
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2061
|
+
|
|
2062
|
+
// A range can operate in one of two modes: matching a single, 16-bit _code unit_,
|
|
2063
|
+
// or matching a _code point_. (Code points over 0xFFFF take up two 16-bit code units.)
|
|
2064
|
+
const cp = this.matchCodePoint ? inputStream.nextCodePoint() : inputStream.nextCharCode();
|
|
2065
|
+
|
|
2066
|
+
// Always compare by code point value to get the correct result in all scenarios.
|
|
2067
|
+
// Note that for strings of length 1, codePointAt(0) and charPointAt(0) are equivalent.
|
|
2068
|
+
if (cp !== undefined && this.from.codePointAt(0) <= cp && cp <= this.to.codePointAt(0)) {
|
|
2069
|
+
state.pushBinding(new TerminalNode$1(state.grammar, String.fromCodePoint(cp)), origPos);
|
|
2056
2070
|
return true;
|
|
2057
2071
|
} else {
|
|
2058
2072
|
state.processFailure(origPos, this);
|
|
@@ -2060,18 +2074,18 @@ pexprs$h.Range.prototype.eval = function(state) {
|
|
|
2060
2074
|
}
|
|
2061
2075
|
};
|
|
2062
2076
|
|
|
2063
|
-
pexprs$
|
|
2077
|
+
pexprs$g.Param.prototype.eval = function(state) {
|
|
2064
2078
|
return state.eval(state.currentApplication().args[this.index]);
|
|
2065
2079
|
};
|
|
2066
2080
|
|
|
2067
|
-
pexprs$
|
|
2081
|
+
pexprs$g.Lex.prototype.eval = function(state) {
|
|
2068
2082
|
state.enterLexifiedContext();
|
|
2069
2083
|
const ans = state.eval(this.expr);
|
|
2070
2084
|
state.exitLexifiedContext();
|
|
2071
2085
|
return ans;
|
|
2072
2086
|
};
|
|
2073
2087
|
|
|
2074
|
-
pexprs$
|
|
2088
|
+
pexprs$g.Alt.prototype.eval = function(state) {
|
|
2075
2089
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
2076
2090
|
if (state.eval(this.terms[idx])) {
|
|
2077
2091
|
return true;
|
|
@@ -2080,7 +2094,7 @@ pexprs$h.Alt.prototype.eval = function(state) {
|
|
|
2080
2094
|
return false;
|
|
2081
2095
|
};
|
|
2082
2096
|
|
|
2083
|
-
pexprs$
|
|
2097
|
+
pexprs$g.Seq.prototype.eval = function(state) {
|
|
2084
2098
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2085
2099
|
const factor = this.factors[idx];
|
|
2086
2100
|
if (!state.eval(factor)) {
|
|
@@ -2090,7 +2104,7 @@ pexprs$h.Seq.prototype.eval = function(state) {
|
|
|
2090
2104
|
return true;
|
|
2091
2105
|
};
|
|
2092
2106
|
|
|
2093
|
-
pexprs$
|
|
2107
|
+
pexprs$g.Iter.prototype.eval = function(state) {
|
|
2094
2108
|
const {inputStream} = state;
|
|
2095
2109
|
const origPos = inputStream.pos;
|
|
2096
2110
|
const arity = this.getArity();
|
|
@@ -2134,7 +2148,7 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2134
2148
|
offset = colOffsets[0][0];
|
|
2135
2149
|
matchLength = endOffset - offset;
|
|
2136
2150
|
}
|
|
2137
|
-
const isOptional = this instanceof pexprs$
|
|
2151
|
+
const isOptional = this instanceof pexprs$g.Opt;
|
|
2138
2152
|
for (idx = 0; idx < cols.length; idx++) {
|
|
2139
2153
|
state._bindings.push(
|
|
2140
2154
|
new IterationNode$1(state.grammar, cols[idx], colOffsets[idx], matchLength, isOptional)
|
|
@@ -2144,7 +2158,7 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2144
2158
|
return true;
|
|
2145
2159
|
};
|
|
2146
2160
|
|
|
2147
|
-
pexprs$
|
|
2161
|
+
pexprs$g.Not.prototype.eval = function(state) {
|
|
2148
2162
|
/*
|
|
2149
2163
|
TODO:
|
|
2150
2164
|
- Right now we're just throwing away all of the failures that happen inside a `not`, and
|
|
@@ -2170,7 +2184,7 @@ pexprs$h.Not.prototype.eval = function(state) {
|
|
|
2170
2184
|
return true;
|
|
2171
2185
|
};
|
|
2172
2186
|
|
|
2173
|
-
pexprs$
|
|
2187
|
+
pexprs$g.Lookahead.prototype.eval = function(state) {
|
|
2174
2188
|
const {inputStream} = state;
|
|
2175
2189
|
const origPos = inputStream.pos;
|
|
2176
2190
|
if (state.eval(this.expr)) {
|
|
@@ -2181,7 +2195,7 @@ pexprs$h.Lookahead.prototype.eval = function(state) {
|
|
|
2181
2195
|
}
|
|
2182
2196
|
};
|
|
2183
2197
|
|
|
2184
|
-
pexprs$
|
|
2198
|
+
pexprs$g.Apply.prototype.eval = function(state) {
|
|
2185
2199
|
const caller = state.currentApplication();
|
|
2186
2200
|
const actuals = caller ? caller.args : [];
|
|
2187
2201
|
const app = this.substituteParams(actuals);
|
|
@@ -2204,7 +2218,7 @@ pexprs$h.Apply.prototype.eval = function(state) {
|
|
|
2204
2218
|
return app.reallyEval(state);
|
|
2205
2219
|
};
|
|
2206
2220
|
|
|
2207
|
-
pexprs$
|
|
2221
|
+
pexprs$g.Apply.prototype.handleCycle = function(state) {
|
|
2208
2222
|
const posInfo = state.getCurrentPosInfo();
|
|
2209
2223
|
const {currentLeftRecursion} = posInfo;
|
|
2210
2224
|
const memoKey = this.toMemoKey();
|
|
@@ -2227,7 +2241,7 @@ pexprs$h.Apply.prototype.handleCycle = function(state) {
|
|
|
2227
2241
|
return state.useMemoizedResult(state.inputStream.pos, memoRec);
|
|
2228
2242
|
};
|
|
2229
2243
|
|
|
2230
|
-
pexprs$
|
|
2244
|
+
pexprs$g.Apply.prototype.reallyEval = function(state) {
|
|
2231
2245
|
const {inputStream} = state;
|
|
2232
2246
|
const origPos = inputStream.pos;
|
|
2233
2247
|
const origPosInfo = state.getCurrentPosInfo();
|
|
@@ -2304,7 +2318,7 @@ pexprs$h.Apply.prototype.reallyEval = function(state) {
|
|
|
2304
2318
|
return succeeded;
|
|
2305
2319
|
};
|
|
2306
2320
|
|
|
2307
|
-
pexprs$
|
|
2321
|
+
pexprs$g.Apply.prototype.evalOnce = function(expr, state) {
|
|
2308
2322
|
const {inputStream} = state;
|
|
2309
2323
|
const origPos = inputStream.pos;
|
|
2310
2324
|
|
|
@@ -2324,7 +2338,7 @@ pexprs$h.Apply.prototype.evalOnce = function(expr, state) {
|
|
|
2324
2338
|
}
|
|
2325
2339
|
};
|
|
2326
2340
|
|
|
2327
|
-
pexprs$
|
|
2341
|
+
pexprs$g.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoRec, newValue) {
|
|
2328
2342
|
if (!newValue) {
|
|
2329
2343
|
return false;
|
|
2330
2344
|
}
|
|
@@ -2368,7 +2382,7 @@ pexprs$h.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoR
|
|
|
2368
2382
|
return lrMemoRec.value;
|
|
2369
2383
|
};
|
|
2370
2384
|
|
|
2371
|
-
pexprs$
|
|
2385
|
+
pexprs$g.UnicodeChar.prototype.eval = function(state) {
|
|
2372
2386
|
const {inputStream} = state;
|
|
2373
2387
|
const origPos = inputStream.pos;
|
|
2374
2388
|
const ch = inputStream.next();
|
|
@@ -2386,32 +2400,32 @@ pexprs$h.UnicodeChar.prototype.eval = function(state) {
|
|
|
2386
2400
|
// --------------------------------------------------------------------
|
|
2387
2401
|
|
|
2388
2402
|
const common$d = common$l;
|
|
2389
|
-
const pexprs$
|
|
2403
|
+
const pexprs$f = pexprsMain;
|
|
2390
2404
|
|
|
2391
2405
|
// --------------------------------------------------------------------
|
|
2392
2406
|
// Operations
|
|
2393
2407
|
// --------------------------------------------------------------------
|
|
2394
2408
|
|
|
2395
|
-
pexprs$
|
|
2409
|
+
pexprs$f.PExpr.prototype.getArity = common$d.abstract('getArity');
|
|
2396
2410
|
|
|
2397
|
-
pexprs$
|
|
2398
|
-
pexprs$
|
|
2399
|
-
pexprs$
|
|
2400
|
-
pexprs$
|
|
2401
|
-
pexprs$
|
|
2402
|
-
pexprs$
|
|
2403
|
-
pexprs$
|
|
2411
|
+
pexprs$f.any.getArity =
|
|
2412
|
+
pexprs$f.end.getArity =
|
|
2413
|
+
pexprs$f.Terminal.prototype.getArity =
|
|
2414
|
+
pexprs$f.Range.prototype.getArity =
|
|
2415
|
+
pexprs$f.Param.prototype.getArity =
|
|
2416
|
+
pexprs$f.Apply.prototype.getArity =
|
|
2417
|
+
pexprs$f.UnicodeChar.prototype.getArity =
|
|
2404
2418
|
function() {
|
|
2405
2419
|
return 1;
|
|
2406
2420
|
};
|
|
2407
2421
|
|
|
2408
|
-
pexprs$
|
|
2422
|
+
pexprs$f.Alt.prototype.getArity = function() {
|
|
2409
2423
|
// This is ok b/c all terms must have the same arity -- this property is
|
|
2410
2424
|
// checked by the Grammar constructor.
|
|
2411
2425
|
return this.terms.length === 0 ? 0 : this.terms[0].getArity();
|
|
2412
2426
|
};
|
|
2413
2427
|
|
|
2414
|
-
pexprs$
|
|
2428
|
+
pexprs$f.Seq.prototype.getArity = function() {
|
|
2415
2429
|
let arity = 0;
|
|
2416
2430
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2417
2431
|
arity += this.factors[idx].getArity();
|
|
@@ -2419,15 +2433,15 @@ pexprs$g.Seq.prototype.getArity = function() {
|
|
|
2419
2433
|
return arity;
|
|
2420
2434
|
};
|
|
2421
2435
|
|
|
2422
|
-
pexprs$
|
|
2436
|
+
pexprs$f.Iter.prototype.getArity = function() {
|
|
2423
2437
|
return this.expr.getArity();
|
|
2424
2438
|
};
|
|
2425
2439
|
|
|
2426
|
-
pexprs$
|
|
2440
|
+
pexprs$f.Not.prototype.getArity = function() {
|
|
2427
2441
|
return 0;
|
|
2428
2442
|
};
|
|
2429
2443
|
|
|
2430
|
-
pexprs$
|
|
2444
|
+
pexprs$f.Lookahead.prototype.getArity = pexprs$f.Lex.prototype.getArity = function() {
|
|
2431
2445
|
return this.expr.getArity();
|
|
2432
2446
|
};
|
|
2433
2447
|
|
|
@@ -2436,7 +2450,7 @@ pexprs$g.Lookahead.prototype.getArity = pexprs$g.Lex.prototype.getArity = functi
|
|
|
2436
2450
|
// --------------------------------------------------------------------
|
|
2437
2451
|
|
|
2438
2452
|
const common$c = common$l;
|
|
2439
|
-
const pexprs$
|
|
2453
|
+
const pexprs$e = pexprsMain;
|
|
2440
2454
|
|
|
2441
2455
|
// --------------------------------------------------------------------
|
|
2442
2456
|
// Private stuff
|
|
@@ -2455,40 +2469,40 @@ function getMetaInfo(expr, grammarInterval) {
|
|
|
2455
2469
|
// Operations
|
|
2456
2470
|
// --------------------------------------------------------------------
|
|
2457
2471
|
|
|
2458
|
-
pexprs$
|
|
2472
|
+
pexprs$e.PExpr.prototype.outputRecipe = common$c.abstract('outputRecipe');
|
|
2459
2473
|
|
|
2460
|
-
pexprs$
|
|
2474
|
+
pexprs$e.any.outputRecipe = function(formals, grammarInterval) {
|
|
2461
2475
|
return ['any', getMetaInfo(this, grammarInterval)];
|
|
2462
2476
|
};
|
|
2463
2477
|
|
|
2464
|
-
pexprs$
|
|
2478
|
+
pexprs$e.end.outputRecipe = function(formals, grammarInterval) {
|
|
2465
2479
|
return ['end', getMetaInfo(this, grammarInterval)];
|
|
2466
2480
|
};
|
|
2467
2481
|
|
|
2468
|
-
pexprs$
|
|
2482
|
+
pexprs$e.Terminal.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2469
2483
|
return ['terminal', getMetaInfo(this, grammarInterval), this.obj];
|
|
2470
2484
|
};
|
|
2471
2485
|
|
|
2472
|
-
pexprs$
|
|
2486
|
+
pexprs$e.Range.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2473
2487
|
return ['range', getMetaInfo(this, grammarInterval), this.from, this.to];
|
|
2474
2488
|
};
|
|
2475
2489
|
|
|
2476
|
-
pexprs$
|
|
2490
|
+
pexprs$e.Param.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2477
2491
|
return ['param', getMetaInfo(this, grammarInterval), this.index];
|
|
2478
2492
|
};
|
|
2479
2493
|
|
|
2480
|
-
pexprs$
|
|
2494
|
+
pexprs$e.Alt.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2481
2495
|
return ['alt', getMetaInfo(this, grammarInterval)].concat(
|
|
2482
2496
|
this.terms.map(term => term.outputRecipe(formals, grammarInterval))
|
|
2483
2497
|
);
|
|
2484
2498
|
};
|
|
2485
2499
|
|
|
2486
|
-
pexprs$
|
|
2500
|
+
pexprs$e.Extend.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2487
2501
|
const extension = this.terms[0]; // [extension, original]
|
|
2488
2502
|
return extension.outputRecipe(formals, grammarInterval);
|
|
2489
2503
|
};
|
|
2490
2504
|
|
|
2491
|
-
pexprs$
|
|
2505
|
+
pexprs$e.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2492
2506
|
const beforeTerms = this.terms.slice(0, this.expansionPos);
|
|
2493
2507
|
const afterTerms = this.terms.slice(this.expansionPos + 1);
|
|
2494
2508
|
return [
|
|
@@ -2499,18 +2513,18 @@ pexprs$f.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2499
2513
|
];
|
|
2500
2514
|
};
|
|
2501
2515
|
|
|
2502
|
-
pexprs$
|
|
2516
|
+
pexprs$e.Seq.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2503
2517
|
return ['seq', getMetaInfo(this, grammarInterval)].concat(
|
|
2504
2518
|
this.factors.map(factor => factor.outputRecipe(formals, grammarInterval))
|
|
2505
2519
|
);
|
|
2506
2520
|
};
|
|
2507
2521
|
|
|
2508
|
-
pexprs$
|
|
2509
|
-
pexprs$
|
|
2510
|
-
pexprs$
|
|
2511
|
-
pexprs$
|
|
2512
|
-
pexprs$
|
|
2513
|
-
pexprs$
|
|
2522
|
+
pexprs$e.Star.prototype.outputRecipe =
|
|
2523
|
+
pexprs$e.Plus.prototype.outputRecipe =
|
|
2524
|
+
pexprs$e.Opt.prototype.outputRecipe =
|
|
2525
|
+
pexprs$e.Not.prototype.outputRecipe =
|
|
2526
|
+
pexprs$e.Lookahead.prototype.outputRecipe =
|
|
2527
|
+
pexprs$e.Lex.prototype.outputRecipe =
|
|
2514
2528
|
function(formals, grammarInterval) {
|
|
2515
2529
|
return [
|
|
2516
2530
|
this.constructor.name.toLowerCase(),
|
|
@@ -2519,7 +2533,7 @@ pexprs$f.Star.prototype.outputRecipe =
|
|
|
2519
2533
|
];
|
|
2520
2534
|
};
|
|
2521
2535
|
|
|
2522
|
-
pexprs$
|
|
2536
|
+
pexprs$e.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2523
2537
|
return [
|
|
2524
2538
|
'app',
|
|
2525
2539
|
getMetaInfo(this, grammarInterval),
|
|
@@ -2528,7 +2542,7 @@ pexprs$f.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2528
2542
|
];
|
|
2529
2543
|
};
|
|
2530
2544
|
|
|
2531
|
-
pexprs$
|
|
2545
|
+
pexprs$e.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2532
2546
|
return ['unicodeChar', getMetaInfo(this, grammarInterval), this.category];
|
|
2533
2547
|
};
|
|
2534
2548
|
|
|
@@ -2537,7 +2551,7 @@ pexprs$f.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval)
|
|
|
2537
2551
|
// --------------------------------------------------------------------
|
|
2538
2552
|
|
|
2539
2553
|
const common$b = common$l;
|
|
2540
|
-
const pexprs$
|
|
2554
|
+
const pexprs$d = pexprsMain;
|
|
2541
2555
|
|
|
2542
2556
|
// --------------------------------------------------------------------
|
|
2543
2557
|
// Operations
|
|
@@ -2548,49 +2562,49 @@ const pexprs$e = pexprsMain;
|
|
|
2548
2562
|
parameter with a `Param` node. Returns a PExpr -- either a new one, or the original one if
|
|
2549
2563
|
it was modified in place.
|
|
2550
2564
|
*/
|
|
2551
|
-
pexprs$
|
|
2552
|
-
|
|
2553
|
-
pexprs$
|
|
2554
|
-
pexprs$
|
|
2555
|
-
pexprs$
|
|
2556
|
-
pexprs$
|
|
2557
|
-
pexprs$
|
|
2558
|
-
pexprs$
|
|
2565
|
+
pexprs$d.PExpr.prototype.introduceParams = common$b.abstract('introduceParams');
|
|
2566
|
+
|
|
2567
|
+
pexprs$d.any.introduceParams =
|
|
2568
|
+
pexprs$d.end.introduceParams =
|
|
2569
|
+
pexprs$d.Terminal.prototype.introduceParams =
|
|
2570
|
+
pexprs$d.Range.prototype.introduceParams =
|
|
2571
|
+
pexprs$d.Param.prototype.introduceParams =
|
|
2572
|
+
pexprs$d.UnicodeChar.prototype.introduceParams =
|
|
2559
2573
|
function(formals) {
|
|
2560
2574
|
return this;
|
|
2561
2575
|
};
|
|
2562
2576
|
|
|
2563
|
-
pexprs$
|
|
2577
|
+
pexprs$d.Alt.prototype.introduceParams = function(formals) {
|
|
2564
2578
|
this.terms.forEach((term, idx, terms) => {
|
|
2565
2579
|
terms[idx] = term.introduceParams(formals);
|
|
2566
2580
|
});
|
|
2567
2581
|
return this;
|
|
2568
2582
|
};
|
|
2569
2583
|
|
|
2570
|
-
pexprs$
|
|
2584
|
+
pexprs$d.Seq.prototype.introduceParams = function(formals) {
|
|
2571
2585
|
this.factors.forEach((factor, idx, factors) => {
|
|
2572
2586
|
factors[idx] = factor.introduceParams(formals);
|
|
2573
2587
|
});
|
|
2574
2588
|
return this;
|
|
2575
2589
|
};
|
|
2576
2590
|
|
|
2577
|
-
pexprs$
|
|
2578
|
-
pexprs$
|
|
2579
|
-
pexprs$
|
|
2580
|
-
pexprs$
|
|
2591
|
+
pexprs$d.Iter.prototype.introduceParams =
|
|
2592
|
+
pexprs$d.Not.prototype.introduceParams =
|
|
2593
|
+
pexprs$d.Lookahead.prototype.introduceParams =
|
|
2594
|
+
pexprs$d.Lex.prototype.introduceParams =
|
|
2581
2595
|
function(formals) {
|
|
2582
2596
|
this.expr = this.expr.introduceParams(formals);
|
|
2583
2597
|
return this;
|
|
2584
2598
|
};
|
|
2585
2599
|
|
|
2586
|
-
pexprs$
|
|
2600
|
+
pexprs$d.Apply.prototype.introduceParams = function(formals) {
|
|
2587
2601
|
const index = formals.indexOf(this.ruleName);
|
|
2588
2602
|
if (index >= 0) {
|
|
2589
2603
|
if (this.args.length > 0) {
|
|
2590
2604
|
// TODO: Should this be supported? See issue #64.
|
|
2591
2605
|
throw new Error('Parameterized rules cannot be passed as arguments to another rule.');
|
|
2592
2606
|
}
|
|
2593
|
-
return new pexprs$
|
|
2607
|
+
return new pexprs$d.Param(index).withSource(this.source);
|
|
2594
2608
|
} else {
|
|
2595
2609
|
this.args.forEach((arg, idx, args) => {
|
|
2596
2610
|
args[idx] = arg.introduceParams(formals);
|
|
@@ -2604,33 +2618,33 @@ pexprs$e.Apply.prototype.introduceParams = function(formals) {
|
|
|
2604
2618
|
// --------------------------------------------------------------------
|
|
2605
2619
|
|
|
2606
2620
|
const common$a = common$l;
|
|
2607
|
-
const pexprs$
|
|
2621
|
+
const pexprs$c = pexprsMain;
|
|
2608
2622
|
|
|
2609
2623
|
// --------------------------------------------------------------------
|
|
2610
2624
|
// Operations
|
|
2611
2625
|
// --------------------------------------------------------------------
|
|
2612
2626
|
|
|
2613
2627
|
// Returns `true` if this parsing expression may accept without consuming any input.
|
|
2614
|
-
pexprs$
|
|
2628
|
+
pexprs$c.PExpr.prototype.isNullable = function(grammar) {
|
|
2615
2629
|
return this._isNullable(grammar, Object.create(null));
|
|
2616
2630
|
};
|
|
2617
2631
|
|
|
2618
|
-
pexprs$
|
|
2632
|
+
pexprs$c.PExpr.prototype._isNullable = common$a.abstract('_isNullable');
|
|
2619
2633
|
|
|
2620
|
-
pexprs$
|
|
2621
|
-
pexprs$
|
|
2622
|
-
pexprs$
|
|
2623
|
-
pexprs$
|
|
2624
|
-
pexprs$
|
|
2634
|
+
pexprs$c.any._isNullable =
|
|
2635
|
+
pexprs$c.Range.prototype._isNullable =
|
|
2636
|
+
pexprs$c.Param.prototype._isNullable =
|
|
2637
|
+
pexprs$c.Plus.prototype._isNullable =
|
|
2638
|
+
pexprs$c.UnicodeChar.prototype._isNullable =
|
|
2625
2639
|
function(grammar, memo) {
|
|
2626
2640
|
return false;
|
|
2627
2641
|
};
|
|
2628
2642
|
|
|
2629
|
-
pexprs$
|
|
2643
|
+
pexprs$c.end._isNullable = function(grammar, memo) {
|
|
2630
2644
|
return true;
|
|
2631
2645
|
};
|
|
2632
2646
|
|
|
2633
|
-
pexprs$
|
|
2647
|
+
pexprs$c.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
2634
2648
|
if (typeof this.obj === 'string') {
|
|
2635
2649
|
// This is an over-simplification: it's only correct if the input is a string. If it's an array
|
|
2636
2650
|
// or an object, then the empty string parsing expression is not nullable.
|
|
@@ -2640,27 +2654,27 @@ pexprs$d.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
|
2640
2654
|
}
|
|
2641
2655
|
};
|
|
2642
2656
|
|
|
2643
|
-
pexprs$
|
|
2657
|
+
pexprs$c.Alt.prototype._isNullable = function(grammar, memo) {
|
|
2644
2658
|
return this.terms.length === 0 || this.terms.some(term => term._isNullable(grammar, memo));
|
|
2645
2659
|
};
|
|
2646
2660
|
|
|
2647
|
-
pexprs$
|
|
2661
|
+
pexprs$c.Seq.prototype._isNullable = function(grammar, memo) {
|
|
2648
2662
|
return this.factors.every(factor => factor._isNullable(grammar, memo));
|
|
2649
2663
|
};
|
|
2650
2664
|
|
|
2651
|
-
pexprs$
|
|
2652
|
-
pexprs$
|
|
2653
|
-
pexprs$
|
|
2654
|
-
pexprs$
|
|
2665
|
+
pexprs$c.Star.prototype._isNullable =
|
|
2666
|
+
pexprs$c.Opt.prototype._isNullable =
|
|
2667
|
+
pexprs$c.Not.prototype._isNullable =
|
|
2668
|
+
pexprs$c.Lookahead.prototype._isNullable =
|
|
2655
2669
|
function(grammar, memo) {
|
|
2656
2670
|
return true;
|
|
2657
2671
|
};
|
|
2658
2672
|
|
|
2659
|
-
pexprs$
|
|
2673
|
+
pexprs$c.Lex.prototype._isNullable = function(grammar, memo) {
|
|
2660
2674
|
return this.expr._isNullable(grammar, memo);
|
|
2661
2675
|
};
|
|
2662
2676
|
|
|
2663
|
-
pexprs$
|
|
2677
|
+
pexprs$c.Apply.prototype._isNullable = function(grammar, memo) {
|
|
2664
2678
|
const key = this.toMemoKey();
|
|
2665
2679
|
if (!Object.prototype.hasOwnProperty.call(memo, key)) {
|
|
2666
2680
|
const {body} = grammar.rules[this.ruleName];
|
|
@@ -2676,7 +2690,7 @@ pexprs$d.Apply.prototype._isNullable = function(grammar, memo) {
|
|
|
2676
2690
|
// --------------------------------------------------------------------
|
|
2677
2691
|
|
|
2678
2692
|
const common$9 = common$l;
|
|
2679
|
-
const pexprs$
|
|
2693
|
+
const pexprs$b = pexprsMain;
|
|
2680
2694
|
|
|
2681
2695
|
// --------------------------------------------------------------------
|
|
2682
2696
|
// Operations
|
|
@@ -2689,44 +2703,44 @@ const pexprs$c = pexprsMain;
|
|
|
2689
2703
|
The receiver must not be modified; a new PExpr must be returned if any replacement is necessary.
|
|
2690
2704
|
*/
|
|
2691
2705
|
// function(actuals) { ... }
|
|
2692
|
-
pexprs$
|
|
2706
|
+
pexprs$b.PExpr.prototype.substituteParams = common$9.abstract('substituteParams');
|
|
2693
2707
|
|
|
2694
|
-
pexprs$
|
|
2695
|
-
pexprs$
|
|
2696
|
-
pexprs$
|
|
2697
|
-
pexprs$
|
|
2698
|
-
pexprs$
|
|
2708
|
+
pexprs$b.any.substituteParams =
|
|
2709
|
+
pexprs$b.end.substituteParams =
|
|
2710
|
+
pexprs$b.Terminal.prototype.substituteParams =
|
|
2711
|
+
pexprs$b.Range.prototype.substituteParams =
|
|
2712
|
+
pexprs$b.UnicodeChar.prototype.substituteParams =
|
|
2699
2713
|
function(actuals) {
|
|
2700
2714
|
return this;
|
|
2701
2715
|
};
|
|
2702
2716
|
|
|
2703
|
-
pexprs$
|
|
2717
|
+
pexprs$b.Param.prototype.substituteParams = function(actuals) {
|
|
2704
2718
|
return actuals[this.index];
|
|
2705
2719
|
};
|
|
2706
2720
|
|
|
2707
|
-
pexprs$
|
|
2708
|
-
return new pexprs$
|
|
2721
|
+
pexprs$b.Alt.prototype.substituteParams = function(actuals) {
|
|
2722
|
+
return new pexprs$b.Alt(this.terms.map(term => term.substituteParams(actuals)));
|
|
2709
2723
|
};
|
|
2710
2724
|
|
|
2711
|
-
pexprs$
|
|
2712
|
-
return new pexprs$
|
|
2725
|
+
pexprs$b.Seq.prototype.substituteParams = function(actuals) {
|
|
2726
|
+
return new pexprs$b.Seq(this.factors.map(factor => factor.substituteParams(actuals)));
|
|
2713
2727
|
};
|
|
2714
2728
|
|
|
2715
|
-
pexprs$
|
|
2716
|
-
pexprs$
|
|
2717
|
-
pexprs$
|
|
2718
|
-
pexprs$
|
|
2729
|
+
pexprs$b.Iter.prototype.substituteParams =
|
|
2730
|
+
pexprs$b.Not.prototype.substituteParams =
|
|
2731
|
+
pexprs$b.Lookahead.prototype.substituteParams =
|
|
2732
|
+
pexprs$b.Lex.prototype.substituteParams =
|
|
2719
2733
|
function(actuals) {
|
|
2720
2734
|
return new this.constructor(this.expr.substituteParams(actuals));
|
|
2721
2735
|
};
|
|
2722
2736
|
|
|
2723
|
-
pexprs$
|
|
2737
|
+
pexprs$b.Apply.prototype.substituteParams = function(actuals) {
|
|
2724
2738
|
if (this.args.length === 0) {
|
|
2725
2739
|
// Avoid making a copy of this application, as an optimization
|
|
2726
2740
|
return this;
|
|
2727
2741
|
} else {
|
|
2728
2742
|
const args = this.args.map(arg => arg.substituteParams(actuals));
|
|
2729
|
-
return new pexprs$
|
|
2743
|
+
return new pexprs$b.Apply(this.ruleName, args);
|
|
2730
2744
|
}
|
|
2731
2745
|
};
|
|
2732
2746
|
|
|
@@ -2735,7 +2749,7 @@ pexprs$c.Apply.prototype.substituteParams = function(actuals) {
|
|
|
2735
2749
|
// --------------------------------------------------------------------
|
|
2736
2750
|
|
|
2737
2751
|
const common$8 = common$l;
|
|
2738
|
-
const pexprs$
|
|
2752
|
+
const pexprs$a = pexprsMain;
|
|
2739
2753
|
|
|
2740
2754
|
const {copyWithoutDuplicates} = common$8;
|
|
2741
2755
|
|
|
@@ -2801,17 +2815,17 @@ function resolveDuplicatedNames(argumentNameList) {
|
|
|
2801
2815
|
* e.getArity() === e.toArgumentNameList(1).length
|
|
2802
2816
|
*/
|
|
2803
2817
|
// function(firstArgIndex, noDupCheck) { ... }
|
|
2804
|
-
pexprs$
|
|
2818
|
+
pexprs$a.PExpr.prototype.toArgumentNameList = common$8.abstract('toArgumentNameList');
|
|
2805
2819
|
|
|
2806
|
-
pexprs$
|
|
2820
|
+
pexprs$a.any.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2807
2821
|
return ['any'];
|
|
2808
2822
|
};
|
|
2809
2823
|
|
|
2810
|
-
pexprs$
|
|
2824
|
+
pexprs$a.end.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2811
2825
|
return ['end'];
|
|
2812
2826
|
};
|
|
2813
2827
|
|
|
2814
|
-
pexprs$
|
|
2828
|
+
pexprs$a.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2815
2829
|
if (typeof this.obj === 'string' && /^[_a-zA-Z0-9]+$/.test(this.obj)) {
|
|
2816
2830
|
// If this terminal is a valid suffix for a JS identifier, just prepend it with '_'
|
|
2817
2831
|
return ['_' + this.obj];
|
|
@@ -2821,7 +2835,7 @@ pexprs$b.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCh
|
|
|
2821
2835
|
}
|
|
2822
2836
|
};
|
|
2823
2837
|
|
|
2824
|
-
pexprs$
|
|
2838
|
+
pexprs$a.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2825
2839
|
let argName = this.from + '_to_' + this.to;
|
|
2826
2840
|
// If the `argName` is not valid then try to prepend a `_`.
|
|
2827
2841
|
if (!isRestrictedJSIdentifier(argName)) {
|
|
@@ -2834,7 +2848,7 @@ pexprs$b.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2834
2848
|
return [argName];
|
|
2835
2849
|
};
|
|
2836
2850
|
|
|
2837
|
-
pexprs$
|
|
2851
|
+
pexprs$a.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2838
2852
|
// `termArgNameLists` is an array of arrays where each row is the
|
|
2839
2853
|
// argument name list that corresponds to a term in this alternation.
|
|
2840
2854
|
const termArgNameLists = this.terms.map(term =>
|
|
@@ -2858,7 +2872,7 @@ pexprs$b.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2858
2872
|
return argumentNameList;
|
|
2859
2873
|
};
|
|
2860
2874
|
|
|
2861
|
-
pexprs$
|
|
2875
|
+
pexprs$a.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2862
2876
|
// Generate the argument name list, without worrying about duplicates.
|
|
2863
2877
|
let argumentNameList = [];
|
|
2864
2878
|
this.factors.forEach(factor => {
|
|
@@ -2874,7 +2888,7 @@ pexprs$b.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2874
2888
|
return argumentNameList;
|
|
2875
2889
|
};
|
|
2876
2890
|
|
|
2877
|
-
pexprs$
|
|
2891
|
+
pexprs$a.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2878
2892
|
const argumentNameList = this.expr
|
|
2879
2893
|
.toArgumentNameList(firstArgIndex, noDupCheck)
|
|
2880
2894
|
.map(exprArgumentString =>
|
|
@@ -2888,30 +2902,30 @@ pexprs$b.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2888
2902
|
return argumentNameList;
|
|
2889
2903
|
};
|
|
2890
2904
|
|
|
2891
|
-
pexprs$
|
|
2905
|
+
pexprs$a.Opt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2892
2906
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck).map(argName => {
|
|
2893
2907
|
return 'opt' + argName[0].toUpperCase() + argName.slice(1);
|
|
2894
2908
|
});
|
|
2895
2909
|
};
|
|
2896
2910
|
|
|
2897
|
-
pexprs$
|
|
2911
|
+
pexprs$a.Not.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2898
2912
|
return [];
|
|
2899
2913
|
};
|
|
2900
2914
|
|
|
2901
|
-
pexprs$
|
|
2915
|
+
pexprs$a.Lookahead.prototype.toArgumentNameList = pexprs$a.Lex.prototype.toArgumentNameList =
|
|
2902
2916
|
function(firstArgIndex, noDupCheck) {
|
|
2903
2917
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck);
|
|
2904
2918
|
};
|
|
2905
2919
|
|
|
2906
|
-
pexprs$
|
|
2920
|
+
pexprs$a.Apply.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2907
2921
|
return [this.ruleName];
|
|
2908
2922
|
};
|
|
2909
2923
|
|
|
2910
|
-
pexprs$
|
|
2924
|
+
pexprs$a.UnicodeChar.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2911
2925
|
return ['$' + firstArgIndex];
|
|
2912
2926
|
};
|
|
2913
2927
|
|
|
2914
|
-
pexprs$
|
|
2928
|
+
pexprs$a.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2915
2929
|
return ['param' + this.index];
|
|
2916
2930
|
};
|
|
2917
2931
|
|
|
@@ -2920,36 +2934,36 @@ pexprs$b.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2920
2934
|
// --------------------------------------------------------------------
|
|
2921
2935
|
|
|
2922
2936
|
const common$7 = common$l;
|
|
2923
|
-
const pexprs$
|
|
2937
|
+
const pexprs$9 = pexprsMain;
|
|
2924
2938
|
|
|
2925
2939
|
// --------------------------------------------------------------------
|
|
2926
2940
|
// Operations
|
|
2927
2941
|
// --------------------------------------------------------------------
|
|
2928
2942
|
|
|
2929
2943
|
// Returns a string representing the PExpr, for use as a UI label, etc.
|
|
2930
|
-
pexprs$
|
|
2944
|
+
pexprs$9.PExpr.prototype.toDisplayString = common$7.abstract('toDisplayString');
|
|
2931
2945
|
|
|
2932
|
-
pexprs$
|
|
2946
|
+
pexprs$9.Alt.prototype.toDisplayString = pexprs$9.Seq.prototype.toDisplayString = function() {
|
|
2933
2947
|
if (this.source) {
|
|
2934
2948
|
return this.source.trimmed().contents;
|
|
2935
2949
|
}
|
|
2936
2950
|
return '[' + this.constructor.name + ']';
|
|
2937
2951
|
};
|
|
2938
2952
|
|
|
2939
|
-
pexprs$
|
|
2940
|
-
pexprs$
|
|
2941
|
-
pexprs$
|
|
2942
|
-
pexprs$
|
|
2943
|
-
pexprs$
|
|
2944
|
-
pexprs$
|
|
2945
|
-
pexprs$
|
|
2946
|
-
pexprs$
|
|
2947
|
-
pexprs$
|
|
2953
|
+
pexprs$9.any.toDisplayString =
|
|
2954
|
+
pexprs$9.end.toDisplayString =
|
|
2955
|
+
pexprs$9.Iter.prototype.toDisplayString =
|
|
2956
|
+
pexprs$9.Not.prototype.toDisplayString =
|
|
2957
|
+
pexprs$9.Lookahead.prototype.toDisplayString =
|
|
2958
|
+
pexprs$9.Lex.prototype.toDisplayString =
|
|
2959
|
+
pexprs$9.Terminal.prototype.toDisplayString =
|
|
2960
|
+
pexprs$9.Range.prototype.toDisplayString =
|
|
2961
|
+
pexprs$9.Param.prototype.toDisplayString =
|
|
2948
2962
|
function() {
|
|
2949
2963
|
return this.toString();
|
|
2950
2964
|
};
|
|
2951
2965
|
|
|
2952
|
-
pexprs$
|
|
2966
|
+
pexprs$9.Apply.prototype.toDisplayString = function() {
|
|
2953
2967
|
if (this.args.length > 0) {
|
|
2954
2968
|
const ps = this.args.map(arg => arg.toDisplayString());
|
|
2955
2969
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -2958,7 +2972,7 @@ pexprs$a.Apply.prototype.toDisplayString = function() {
|
|
|
2958
2972
|
}
|
|
2959
2973
|
};
|
|
2960
2974
|
|
|
2961
|
-
pexprs$
|
|
2975
|
+
pexprs$9.UnicodeChar.prototype.toDisplayString = function() {
|
|
2962
2976
|
return 'Unicode [' + this.category + '] character';
|
|
2963
2977
|
};
|
|
2964
2978
|
|
|
@@ -2968,42 +2982,42 @@ pexprs$a.UnicodeChar.prototype.toDisplayString = function() {
|
|
|
2968
2982
|
|
|
2969
2983
|
const Failure$1 = Failure_1;
|
|
2970
2984
|
const common$6 = common$l;
|
|
2971
|
-
const pexprs$
|
|
2985
|
+
const pexprs$8 = pexprsMain;
|
|
2972
2986
|
|
|
2973
2987
|
// --------------------------------------------------------------------
|
|
2974
2988
|
// Operations
|
|
2975
2989
|
// --------------------------------------------------------------------
|
|
2976
2990
|
|
|
2977
|
-
pexprs$
|
|
2991
|
+
pexprs$8.PExpr.prototype.toFailure = common$6.abstract('toFailure');
|
|
2978
2992
|
|
|
2979
|
-
pexprs$
|
|
2993
|
+
pexprs$8.any.toFailure = function(grammar) {
|
|
2980
2994
|
return new Failure$1(this, 'any object', 'description');
|
|
2981
2995
|
};
|
|
2982
2996
|
|
|
2983
|
-
pexprs$
|
|
2997
|
+
pexprs$8.end.toFailure = function(grammar) {
|
|
2984
2998
|
return new Failure$1(this, 'end of input', 'description');
|
|
2985
2999
|
};
|
|
2986
3000
|
|
|
2987
|
-
pexprs$
|
|
3001
|
+
pexprs$8.Terminal.prototype.toFailure = function(grammar) {
|
|
2988
3002
|
return new Failure$1(this, this.obj, 'string');
|
|
2989
3003
|
};
|
|
2990
3004
|
|
|
2991
|
-
pexprs$
|
|
3005
|
+
pexprs$8.Range.prototype.toFailure = function(grammar) {
|
|
2992
3006
|
// TODO: come up with something better
|
|
2993
3007
|
return new Failure$1(this, JSON.stringify(this.from) + '..' + JSON.stringify(this.to), 'code');
|
|
2994
3008
|
};
|
|
2995
3009
|
|
|
2996
|
-
pexprs$
|
|
3010
|
+
pexprs$8.Not.prototype.toFailure = function(grammar) {
|
|
2997
3011
|
const description =
|
|
2998
|
-
this.expr === pexprs$
|
|
3012
|
+
this.expr === pexprs$8.any ? 'nothing' : 'not ' + this.expr.toFailure(grammar);
|
|
2999
3013
|
return new Failure$1(this, description, 'description');
|
|
3000
3014
|
};
|
|
3001
3015
|
|
|
3002
|
-
pexprs$
|
|
3016
|
+
pexprs$8.Lookahead.prototype.toFailure = function(grammar) {
|
|
3003
3017
|
return this.expr.toFailure(grammar);
|
|
3004
3018
|
};
|
|
3005
3019
|
|
|
3006
|
-
pexprs$
|
|
3020
|
+
pexprs$8.Apply.prototype.toFailure = function(grammar) {
|
|
3007
3021
|
let {description} = grammar.rules[this.ruleName];
|
|
3008
3022
|
if (!description) {
|
|
3009
3023
|
const article = /^[aeiouAEIOU]/.test(this.ruleName) ? 'an' : 'a';
|
|
@@ -3012,23 +3026,23 @@ pexprs$9.Apply.prototype.toFailure = function(grammar) {
|
|
|
3012
3026
|
return new Failure$1(this, description, 'description');
|
|
3013
3027
|
};
|
|
3014
3028
|
|
|
3015
|
-
pexprs$
|
|
3029
|
+
pexprs$8.UnicodeChar.prototype.toFailure = function(grammar) {
|
|
3016
3030
|
return new Failure$1(this, 'a Unicode [' + this.category + '] character', 'description');
|
|
3017
3031
|
};
|
|
3018
3032
|
|
|
3019
|
-
pexprs$
|
|
3033
|
+
pexprs$8.Alt.prototype.toFailure = function(grammar) {
|
|
3020
3034
|
const fs = this.terms.map(t => t.toFailure(grammar));
|
|
3021
3035
|
const description = '(' + fs.join(' or ') + ')';
|
|
3022
3036
|
return new Failure$1(this, description, 'description');
|
|
3023
3037
|
};
|
|
3024
3038
|
|
|
3025
|
-
pexprs$
|
|
3039
|
+
pexprs$8.Seq.prototype.toFailure = function(grammar) {
|
|
3026
3040
|
const fs = this.factors.map(f => f.toFailure(grammar));
|
|
3027
3041
|
const description = '(' + fs.join(' ') + ')';
|
|
3028
3042
|
return new Failure$1(this, description, 'description');
|
|
3029
3043
|
};
|
|
3030
3044
|
|
|
3031
|
-
pexprs$
|
|
3045
|
+
pexprs$8.Iter.prototype.toFailure = function(grammar) {
|
|
3032
3046
|
const description = '(' + this.expr.toFailure(grammar) + this.operator + ')';
|
|
3033
3047
|
return new Failure$1(this, description, 'description');
|
|
3034
3048
|
};
|
|
@@ -3038,7 +3052,7 @@ pexprs$9.Iter.prototype.toFailure = function(grammar) {
|
|
|
3038
3052
|
// --------------------------------------------------------------------
|
|
3039
3053
|
|
|
3040
3054
|
const common$5 = common$l;
|
|
3041
|
-
const pexprs$
|
|
3055
|
+
const pexprs$7 = pexprsMain;
|
|
3042
3056
|
|
|
3043
3057
|
// --------------------------------------------------------------------
|
|
3044
3058
|
// Operations
|
|
@@ -3051,57 +3065,57 @@ const pexprs$8 = pexprsMain;
|
|
|
3051
3065
|
~"b" "a" and "a" are interchangeable in any grammar,
|
|
3052
3066
|
both in terms of the languages they accept and their arities.
|
|
3053
3067
|
*/
|
|
3054
|
-
pexprs$
|
|
3068
|
+
pexprs$7.PExpr.prototype.toString = common$5.abstract('toString');
|
|
3055
3069
|
|
|
3056
|
-
pexprs$
|
|
3070
|
+
pexprs$7.any.toString = function() {
|
|
3057
3071
|
return 'any';
|
|
3058
3072
|
};
|
|
3059
3073
|
|
|
3060
|
-
pexprs$
|
|
3074
|
+
pexprs$7.end.toString = function() {
|
|
3061
3075
|
return 'end';
|
|
3062
3076
|
};
|
|
3063
3077
|
|
|
3064
|
-
pexprs$
|
|
3078
|
+
pexprs$7.Terminal.prototype.toString = function() {
|
|
3065
3079
|
return JSON.stringify(this.obj);
|
|
3066
3080
|
};
|
|
3067
3081
|
|
|
3068
|
-
pexprs$
|
|
3082
|
+
pexprs$7.Range.prototype.toString = function() {
|
|
3069
3083
|
return JSON.stringify(this.from) + '..' + JSON.stringify(this.to);
|
|
3070
3084
|
};
|
|
3071
3085
|
|
|
3072
|
-
pexprs$
|
|
3086
|
+
pexprs$7.Param.prototype.toString = function() {
|
|
3073
3087
|
return '$' + this.index;
|
|
3074
3088
|
};
|
|
3075
3089
|
|
|
3076
|
-
pexprs$
|
|
3090
|
+
pexprs$7.Lex.prototype.toString = function() {
|
|
3077
3091
|
return '#(' + this.expr.toString() + ')';
|
|
3078
3092
|
};
|
|
3079
3093
|
|
|
3080
|
-
pexprs$
|
|
3094
|
+
pexprs$7.Alt.prototype.toString = function() {
|
|
3081
3095
|
return this.terms.length === 1 ?
|
|
3082
3096
|
this.terms[0].toString() :
|
|
3083
3097
|
'(' + this.terms.map(term => term.toString()).join(' | ') + ')';
|
|
3084
3098
|
};
|
|
3085
3099
|
|
|
3086
|
-
pexprs$
|
|
3100
|
+
pexprs$7.Seq.prototype.toString = function() {
|
|
3087
3101
|
return this.factors.length === 1 ?
|
|
3088
3102
|
this.factors[0].toString() :
|
|
3089
3103
|
'(' + this.factors.map(factor => factor.toString()).join(' ') + ')';
|
|
3090
3104
|
};
|
|
3091
3105
|
|
|
3092
|
-
pexprs$
|
|
3106
|
+
pexprs$7.Iter.prototype.toString = function() {
|
|
3093
3107
|
return this.expr + this.operator;
|
|
3094
3108
|
};
|
|
3095
3109
|
|
|
3096
|
-
pexprs$
|
|
3110
|
+
pexprs$7.Not.prototype.toString = function() {
|
|
3097
3111
|
return '~' + this.expr;
|
|
3098
3112
|
};
|
|
3099
3113
|
|
|
3100
|
-
pexprs$
|
|
3114
|
+
pexprs$7.Lookahead.prototype.toString = function() {
|
|
3101
3115
|
return '&' + this.expr;
|
|
3102
3116
|
};
|
|
3103
3117
|
|
|
3104
|
-
pexprs$
|
|
3118
|
+
pexprs$7.Apply.prototype.toString = function() {
|
|
3105
3119
|
if (this.args.length > 0) {
|
|
3106
3120
|
const ps = this.args.map(arg => arg.toString());
|
|
3107
3121
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -3110,7 +3124,7 @@ pexprs$8.Apply.prototype.toString = function() {
|
|
|
3110
3124
|
}
|
|
3111
3125
|
};
|
|
3112
3126
|
|
|
3113
|
-
pexprs$
|
|
3127
|
+
pexprs$7.UnicodeChar.prototype.toString = function() {
|
|
3114
3128
|
return '\\p{' + this.category + '}';
|
|
3115
3129
|
};
|
|
3116
3130
|
|
|
@@ -3118,7 +3132,7 @@ pexprs$8.UnicodeChar.prototype.toString = function() {
|
|
|
3118
3132
|
// Re-export classes
|
|
3119
3133
|
// --------------------------------------------------------------------
|
|
3120
3134
|
|
|
3121
|
-
var pexprs$
|
|
3135
|
+
var pexprs$6 = pexprsMain;
|
|
3122
3136
|
|
|
3123
3137
|
// --------------------------------------------------------------------
|
|
3124
3138
|
// Imports
|
|
@@ -3127,7 +3141,7 @@ var pexprs$7 = pexprsMain;
|
|
|
3127
3141
|
const Failure = Failure_1;
|
|
3128
3142
|
const {TerminalNode} = nodes$1;
|
|
3129
3143
|
const {assert: assert$1} = common$l;
|
|
3130
|
-
const {PExpr, Terminal} = pexprs$
|
|
3144
|
+
const {PExpr, Terminal} = pexprs$6;
|
|
3131
3145
|
|
|
3132
3146
|
class CaseInsensitiveTerminal$1 extends PExpr {
|
|
3133
3147
|
constructor(param) {
|
|
@@ -3216,6 +3230,21 @@ InputStream$3.prototype = {
|
|
|
3216
3230
|
return ans;
|
|
3217
3231
|
},
|
|
3218
3232
|
|
|
3233
|
+
nextCharCode() {
|
|
3234
|
+
const nextChar = this.next();
|
|
3235
|
+
return nextChar && nextChar.charCodeAt(0);
|
|
3236
|
+
},
|
|
3237
|
+
|
|
3238
|
+
nextCodePoint() {
|
|
3239
|
+
const cp = this.source.slice(this.pos++).codePointAt(0);
|
|
3240
|
+
// If the code point is beyond plane 0, it takes up two characters.
|
|
3241
|
+
if (cp > 0xffff) {
|
|
3242
|
+
this.pos += 1;
|
|
3243
|
+
}
|
|
3244
|
+
this.examinedLength = Math.max(this.examinedLength, this.pos);
|
|
3245
|
+
return cp;
|
|
3246
|
+
},
|
|
3247
|
+
|
|
3219
3248
|
matchString(s, optIgnoreCase) {
|
|
3220
3249
|
let idx;
|
|
3221
3250
|
if (optIgnoreCase) {
|
|
@@ -3272,7 +3301,7 @@ const Interval = Interval_1;
|
|
|
3272
3301
|
// Private stuff
|
|
3273
3302
|
// --------------------------------------------------------------------
|
|
3274
3303
|
|
|
3275
|
-
function MatchResult$
|
|
3304
|
+
function MatchResult$2(
|
|
3276
3305
|
matcher,
|
|
3277
3306
|
input,
|
|
3278
3307
|
startExpr,
|
|
@@ -3306,19 +3335,19 @@ function MatchResult$3(
|
|
|
3306
3335
|
}
|
|
3307
3336
|
}
|
|
3308
3337
|
|
|
3309
|
-
MatchResult$
|
|
3338
|
+
MatchResult$2.prototype.succeeded = function() {
|
|
3310
3339
|
return !!this._cst;
|
|
3311
3340
|
};
|
|
3312
3341
|
|
|
3313
|
-
MatchResult$
|
|
3342
|
+
MatchResult$2.prototype.failed = function() {
|
|
3314
3343
|
return !this.succeeded();
|
|
3315
3344
|
};
|
|
3316
3345
|
|
|
3317
|
-
MatchResult$
|
|
3346
|
+
MatchResult$2.prototype.getRightmostFailurePosition = function() {
|
|
3318
3347
|
return this._rightmostFailurePosition;
|
|
3319
3348
|
};
|
|
3320
3349
|
|
|
3321
|
-
MatchResult$
|
|
3350
|
+
MatchResult$2.prototype.getRightmostFailures = function() {
|
|
3322
3351
|
if (!this._rightmostFailures) {
|
|
3323
3352
|
this.matcher.setInput(this.input);
|
|
3324
3353
|
const matchResultWithFailures = this.matcher._match(
|
|
@@ -3331,7 +3360,7 @@ MatchResult$3.prototype.getRightmostFailures = function() {
|
|
|
3331
3360
|
return this._rightmostFailures;
|
|
3332
3361
|
};
|
|
3333
3362
|
|
|
3334
|
-
MatchResult$
|
|
3363
|
+
MatchResult$2.prototype.toString = function() {
|
|
3335
3364
|
return this.succeeded() ?
|
|
3336
3365
|
'[match succeeded]' :
|
|
3337
3366
|
'[match failed at position ' + this.getRightmostFailurePosition() + ']';
|
|
@@ -3339,7 +3368,7 @@ MatchResult$3.prototype.toString = function() {
|
|
|
3339
3368
|
|
|
3340
3369
|
// Return a string summarizing the expected contents of the input stream when
|
|
3341
3370
|
// the match failure occurred.
|
|
3342
|
-
MatchResult$
|
|
3371
|
+
MatchResult$2.prototype.getExpectedText = function() {
|
|
3343
3372
|
if (this.succeeded()) {
|
|
3344
3373
|
throw new Error('cannot get expected text of a successful MatchResult');
|
|
3345
3374
|
}
|
|
@@ -3363,7 +3392,7 @@ MatchResult$3.prototype.getExpectedText = function() {
|
|
|
3363
3392
|
return sb.contents();
|
|
3364
3393
|
};
|
|
3365
3394
|
|
|
3366
|
-
MatchResult$
|
|
3395
|
+
MatchResult$2.prototype.getInterval = function() {
|
|
3367
3396
|
const pos = this.getRightmostFailurePosition();
|
|
3368
3397
|
return new Interval(this.input, pos, pos);
|
|
3369
3398
|
};
|
|
@@ -3372,7 +3401,7 @@ MatchResult$3.prototype.getInterval = function() {
|
|
|
3372
3401
|
// Exports
|
|
3373
3402
|
// --------------------------------------------------------------------
|
|
3374
3403
|
|
|
3375
|
-
var MatchResult_1 = MatchResult$
|
|
3404
|
+
var MatchResult_1 = MatchResult$2;
|
|
3376
3405
|
|
|
3377
3406
|
// --------------------------------------------------------------------
|
|
3378
3407
|
// Private stuff
|
|
@@ -3492,10 +3521,10 @@ var PosInfo_1 = PosInfo$1;
|
|
|
3492
3521
|
// --------------------------------------------------------------------
|
|
3493
3522
|
|
|
3494
3523
|
const InputStream$2 = InputStream_1;
|
|
3495
|
-
const MatchResult$
|
|
3524
|
+
const MatchResult$1 = MatchResult_1;
|
|
3496
3525
|
const PosInfo = PosInfo_1;
|
|
3497
3526
|
const Trace = Trace_1;
|
|
3498
|
-
const pexprs$
|
|
3527
|
+
const pexprs$5 = pexprs$6;
|
|
3499
3528
|
const util$3 = util$7;
|
|
3500
3529
|
|
|
3501
3530
|
// --------------------------------------------------------------------
|
|
@@ -3508,7 +3537,7 @@ util$3.awaitBuiltInRules(builtInRules => {
|
|
|
3508
3537
|
builtInApplySyntacticBody = builtInRules.rules.applySyntactic.body;
|
|
3509
3538
|
});
|
|
3510
3539
|
|
|
3511
|
-
const applySpaces = new pexprs$
|
|
3540
|
+
const applySpaces = new pexprs$5.Apply('spaces');
|
|
3512
3541
|
|
|
3513
3542
|
function MatchState$1(matcher, startExpr, optPositionToRecordFailures) {
|
|
3514
3543
|
this.matcher = matcher;
|
|
@@ -3714,7 +3743,7 @@ MatchState$1.prototype = {
|
|
|
3714
3743
|
|
|
3715
3744
|
// Returns a new trace entry, with the currently active trace array as its children.
|
|
3716
3745
|
getTraceEntry(pos, expr, succeeded, bindings) {
|
|
3717
|
-
if (expr instanceof pexprs$
|
|
3746
|
+
if (expr instanceof pexprs$5.Apply) {
|
|
3718
3747
|
const app = this.currentApplication();
|
|
3719
3748
|
const actuals = app ? app.args : [];
|
|
3720
3749
|
expr = expr.substituteParams(actuals);
|
|
@@ -3843,7 +3872,7 @@ MatchState$1.prototype = {
|
|
|
3843
3872
|
key => this.recordedFailures[key]
|
|
3844
3873
|
);
|
|
3845
3874
|
}
|
|
3846
|
-
return new MatchResult$
|
|
3875
|
+
return new MatchResult$1(
|
|
3847
3876
|
this.matcher,
|
|
3848
3877
|
this.input,
|
|
3849
3878
|
this.startExpr,
|
|
@@ -3890,7 +3919,7 @@ var MatchState_1 = MatchState$1;
|
|
|
3890
3919
|
|
|
3891
3920
|
const MatchState = MatchState_1;
|
|
3892
3921
|
|
|
3893
|
-
const pexprs$
|
|
3922
|
+
const pexprs$4 = pexprs$6;
|
|
3894
3923
|
|
|
3895
3924
|
// --------------------------------------------------------------------
|
|
3896
3925
|
// Private stuff
|
|
@@ -3974,7 +4003,7 @@ Matcher$1.prototype._getStartExpr = function(optStartApplicationStr) {
|
|
|
3974
4003
|
}
|
|
3975
4004
|
|
|
3976
4005
|
const startApp = this.grammar.parseApplication(applicationStr);
|
|
3977
|
-
return new pexprs$
|
|
4006
|
+
return new pexprs$4.Seq([startApp, pexprs$4.end]);
|
|
3978
4007
|
};
|
|
3979
4008
|
|
|
3980
4009
|
// --------------------------------------------------------------------
|
|
@@ -3989,7 +4018,7 @@ var Matcher_1 = Matcher$1;
|
|
|
3989
4018
|
|
|
3990
4019
|
const InputStream$1 = InputStream_1;
|
|
3991
4020
|
const {IterationNode} = nodes$1;
|
|
3992
|
-
const MatchResult
|
|
4021
|
+
const MatchResult = MatchResult_1;
|
|
3993
4022
|
const common$3 = common$l;
|
|
3994
4023
|
const errors$3 = errors$9;
|
|
3995
4024
|
const util$2 = util$7;
|
|
@@ -4518,7 +4547,7 @@ Semantics$2.createSemantics = function(grammar, optSuperSemantics) {
|
|
|
4518
4547
|
// To enable clients to invoke a semantics like a function, return a function that acts as a proxy
|
|
4519
4548
|
// for `s`, which is the real `Semantics` instance.
|
|
4520
4549
|
const proxy = function ASemantics(matchResult) {
|
|
4521
|
-
if (!(matchResult instanceof MatchResult
|
|
4550
|
+
if (!(matchResult instanceof MatchResult)) {
|
|
4522
4551
|
throw new TypeError(
|
|
4523
4552
|
'Semantics expected a MatchResult, but got ' +
|
|
4524
4553
|
common$3.unexpectedObjToString(matchResult)
|
|
@@ -4702,7 +4731,7 @@ const Matcher = Matcher_1;
|
|
|
4702
4731
|
const Semantics$1 = Semantics_1;
|
|
4703
4732
|
const common$2 = common$l;
|
|
4704
4733
|
const errors$2 = errors$9;
|
|
4705
|
-
const pexprs$
|
|
4734
|
+
const pexprs$3 = pexprs$6;
|
|
4706
4735
|
|
|
4707
4736
|
// --------------------------------------------------------------------
|
|
4708
4737
|
// Private stuff
|
|
@@ -4723,7 +4752,7 @@ function getSortedRuleValues(grammar) {
|
|
|
4723
4752
|
// See https://v8.dev/features/subsume-json for more details.
|
|
4724
4753
|
const jsonToJS = str => str.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
4725
4754
|
|
|
4726
|
-
function Grammar$
|
|
4755
|
+
function Grammar$4(name, superGrammar, rules, optDefaultStartRule) {
|
|
4727
4756
|
this.name = name;
|
|
4728
4757
|
this.superGrammar = superGrammar;
|
|
4729
4758
|
this.rules = rules;
|
|
@@ -4745,12 +4774,12 @@ let ohmGrammar$2;
|
|
|
4745
4774
|
let buildGrammar$1;
|
|
4746
4775
|
|
|
4747
4776
|
// This method is called from main.js once Ohm has loaded.
|
|
4748
|
-
Grammar$
|
|
4777
|
+
Grammar$4.initApplicationParser = function(grammar, builderFn) {
|
|
4749
4778
|
ohmGrammar$2 = grammar;
|
|
4750
4779
|
buildGrammar$1 = builderFn;
|
|
4751
4780
|
};
|
|
4752
4781
|
|
|
4753
|
-
Grammar$
|
|
4782
|
+
Grammar$4.prototype = {
|
|
4754
4783
|
matcher() {
|
|
4755
4784
|
return new Matcher(this);
|
|
4756
4785
|
},
|
|
@@ -4758,7 +4787,7 @@ Grammar$5.prototype = {
|
|
|
4758
4787
|
// Return true if the grammar is a built-in grammar, otherwise false.
|
|
4759
4788
|
// NOTE: This might give an unexpected result if called before BuiltInRules is defined!
|
|
4760
4789
|
isBuiltIn() {
|
|
4761
|
-
return this === Grammar$
|
|
4790
|
+
return this === Grammar$4.ProtoBuiltInRules || this === Grammar$4.BuiltInRules;
|
|
4762
4791
|
},
|
|
4763
4792
|
|
|
4764
4793
|
equals(g) {
|
|
@@ -4897,7 +4926,7 @@ Grammar$5.prototype = {
|
|
|
4897
4926
|
if (isDefinition) {
|
|
4898
4927
|
operation = 'define';
|
|
4899
4928
|
} else {
|
|
4900
|
-
operation = body instanceof pexprs$
|
|
4929
|
+
operation = body instanceof pexprs$3.Extend ? 'extend' : 'override';
|
|
4901
4930
|
}
|
|
4902
4931
|
|
|
4903
4932
|
const metaInfo = {};
|
|
@@ -4984,7 +5013,7 @@ Grammar$5.prototype = {
|
|
|
4984
5013
|
let app;
|
|
4985
5014
|
if (str.indexOf('<') === -1) {
|
|
4986
5015
|
// simple application
|
|
4987
|
-
app = new pexprs$
|
|
5016
|
+
app = new pexprs$3.Apply(str);
|
|
4988
5017
|
} else {
|
|
4989
5018
|
// parameterized application
|
|
4990
5019
|
const cst = ohmGrammar$2.match(str, 'Base_application');
|
|
@@ -5014,43 +5043,43 @@ Grammar$5.prototype = {
|
|
|
5014
5043
|
// `BuiltInRules`. That grammar contains several convenience rules, e.g., `letter` and
|
|
5015
5044
|
// `digit`, and is implicitly the super-grammar of any grammar whose super-grammar
|
|
5016
5045
|
// isn't specified.
|
|
5017
|
-
Grammar$
|
|
5046
|
+
Grammar$4.ProtoBuiltInRules = new Grammar$4(
|
|
5018
5047
|
'ProtoBuiltInRules', // name
|
|
5019
5048
|
undefined, // supergrammar
|
|
5020
5049
|
{
|
|
5021
5050
|
any: {
|
|
5022
|
-
body: pexprs$
|
|
5051
|
+
body: pexprs$3.any,
|
|
5023
5052
|
formals: [],
|
|
5024
5053
|
description: 'any character',
|
|
5025
5054
|
primitive: true,
|
|
5026
5055
|
},
|
|
5027
5056
|
end: {
|
|
5028
|
-
body: pexprs$
|
|
5057
|
+
body: pexprs$3.end,
|
|
5029
5058
|
formals: [],
|
|
5030
5059
|
description: 'end of input',
|
|
5031
5060
|
primitive: true,
|
|
5032
5061
|
},
|
|
5033
5062
|
|
|
5034
5063
|
caseInsensitive: {
|
|
5035
|
-
body: new CaseInsensitiveTerminal(new pexprs$
|
|
5064
|
+
body: new CaseInsensitiveTerminal(new pexprs$3.Param(0)),
|
|
5036
5065
|
formals: ['str'],
|
|
5037
5066
|
primitive: true,
|
|
5038
5067
|
},
|
|
5039
5068
|
lower: {
|
|
5040
|
-
body: new pexprs$
|
|
5069
|
+
body: new pexprs$3.UnicodeChar('Ll'),
|
|
5041
5070
|
formals: [],
|
|
5042
5071
|
description: 'a lowercase letter',
|
|
5043
5072
|
primitive: true,
|
|
5044
5073
|
},
|
|
5045
5074
|
upper: {
|
|
5046
|
-
body: new pexprs$
|
|
5075
|
+
body: new pexprs$3.UnicodeChar('Lu'),
|
|
5047
5076
|
formals: [],
|
|
5048
5077
|
description: 'an uppercase letter',
|
|
5049
5078
|
primitive: true,
|
|
5050
5079
|
},
|
|
5051
5080
|
// Union of Lt (titlecase), Lm (modifier), and Lo (other), i.e. any letter not in Ll or Lu.
|
|
5052
5081
|
unicodeLtmo: {
|
|
5053
|
-
body: new pexprs$
|
|
5082
|
+
body: new pexprs$3.UnicodeChar('Ltmo'),
|
|
5054
5083
|
formals: [],
|
|
5055
5084
|
description: 'a Unicode character in Lt, Lm, or Lo',
|
|
5056
5085
|
primitive: true,
|
|
@@ -5059,11 +5088,11 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5059
5088
|
// These rules are not truly primitive (they could be written in userland) but are defined
|
|
5060
5089
|
// here for bootstrapping purposes.
|
|
5061
5090
|
spaces: {
|
|
5062
|
-
body: new pexprs$
|
|
5091
|
+
body: new pexprs$3.Star(new pexprs$3.Apply('space')),
|
|
5063
5092
|
formals: [],
|
|
5064
5093
|
},
|
|
5065
5094
|
space: {
|
|
5066
|
-
body: new pexprs$
|
|
5095
|
+
body: new pexprs$3.Range('\x00', ' '),
|
|
5067
5096
|
formals: [],
|
|
5068
5097
|
description: 'a space',
|
|
5069
5098
|
},
|
|
@@ -5074,17 +5103,17 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5074
5103
|
// Exports
|
|
5075
5104
|
// --------------------------------------------------------------------
|
|
5076
5105
|
|
|
5077
|
-
var Grammar_1 = Grammar$
|
|
5106
|
+
var Grammar_1 = Grammar$4;
|
|
5078
5107
|
|
|
5079
5108
|
// --------------------------------------------------------------------
|
|
5080
5109
|
// Imports
|
|
5081
5110
|
// --------------------------------------------------------------------
|
|
5082
5111
|
|
|
5083
|
-
const Grammar$
|
|
5112
|
+
const Grammar$3 = Grammar_1;
|
|
5084
5113
|
const InputStream = InputStream_1;
|
|
5085
5114
|
const common$1 = common$l;
|
|
5086
5115
|
const errors$1 = errors$9;
|
|
5087
|
-
const pexprs$
|
|
5116
|
+
const pexprs$2 = pexprs$6;
|
|
5088
5117
|
|
|
5089
5118
|
// --------------------------------------------------------------------
|
|
5090
5119
|
// Private Stuff
|
|
@@ -5108,7 +5137,7 @@ GrammarDecl$1.prototype.ensureSuperGrammar = function() {
|
|
|
5108
5137
|
// TODO: The conditional expression below is an ugly hack. It's kind of ok because
|
|
5109
5138
|
// I doubt anyone will ever try to declare a grammar called `BuiltInRules`. Still,
|
|
5110
5139
|
// we should try to find a better way to do this.
|
|
5111
|
-
this.name === 'BuiltInRules' ? Grammar$
|
|
5140
|
+
this.name === 'BuiltInRules' ? Grammar$3.ProtoBuiltInRules : Grammar$3.BuiltInRules
|
|
5112
5141
|
);
|
|
5113
5142
|
}
|
|
5114
5143
|
return this.superGrammar;
|
|
@@ -5179,7 +5208,7 @@ GrammarDecl$1.prototype.withSource = function(source) {
|
|
|
5179
5208
|
|
|
5180
5209
|
// Creates a Grammar instance, and if it passes the sanity checks, returns it.
|
|
5181
5210
|
GrammarDecl$1.prototype.build = function() {
|
|
5182
|
-
const grammar = new Grammar$
|
|
5211
|
+
const grammar = new Grammar$3(
|
|
5183
5212
|
this.name,
|
|
5184
5213
|
this.ensureSuperGrammar(),
|
|
5185
5214
|
this.rules,
|
|
@@ -5255,7 +5284,7 @@ GrammarDecl$1.prototype.extend = function(name, formals, fragment, descIgnored,
|
|
|
5255
5284
|
if (!ruleInfo) {
|
|
5256
5285
|
throw errors$1.cannotExtendUndeclaredRule(name, this.superGrammar.name, source);
|
|
5257
5286
|
}
|
|
5258
|
-
const body = new pexprs$
|
|
5287
|
+
const body = new pexprs$2.Extend(this.superGrammar, name, fragment);
|
|
5259
5288
|
body.source = fragment.source;
|
|
5260
5289
|
this.installOverriddenOrExtendedRule(name, formals, body, source);
|
|
5261
5290
|
return this;
|
|
@@ -5271,9 +5300,9 @@ var GrammarDecl_1 = GrammarDecl$1;
|
|
|
5271
5300
|
// Imports
|
|
5272
5301
|
// --------------------------------------------------------------------
|
|
5273
5302
|
|
|
5274
|
-
const Grammar$
|
|
5303
|
+
const Grammar$2 = Grammar_1;
|
|
5275
5304
|
const GrammarDecl = GrammarDecl_1;
|
|
5276
|
-
const pexprs$
|
|
5305
|
+
const pexprs$1 = pexprs$6;
|
|
5277
5306
|
|
|
5278
5307
|
// --------------------------------------------------------------------
|
|
5279
5308
|
// Private stuff
|
|
@@ -5294,7 +5323,7 @@ Builder$2.prototype = {
|
|
|
5294
5323
|
if (superGrammar) {
|
|
5295
5324
|
// `superGrammar` may be a recipe (i.e. an Array), or an actual grammar instance.
|
|
5296
5325
|
gDecl.withSuperGrammar(
|
|
5297
|
-
superGrammar instanceof Grammar$
|
|
5326
|
+
superGrammar instanceof Grammar$2 ? superGrammar : this.fromRecipe(superGrammar)
|
|
5298
5327
|
);
|
|
5299
5328
|
}
|
|
5300
5329
|
if (defaultStartRule) {
|
|
@@ -5329,73 +5358,73 @@ Builder$2.prototype = {
|
|
|
5329
5358
|
},
|
|
5330
5359
|
|
|
5331
5360
|
terminal(x) {
|
|
5332
|
-
return new pexprs$
|
|
5361
|
+
return new pexprs$1.Terminal(x);
|
|
5333
5362
|
},
|
|
5334
5363
|
|
|
5335
5364
|
range(from, to) {
|
|
5336
|
-
return new pexprs$
|
|
5365
|
+
return new pexprs$1.Range(from, to);
|
|
5337
5366
|
},
|
|
5338
5367
|
|
|
5339
5368
|
param(index) {
|
|
5340
|
-
return new pexprs$
|
|
5369
|
+
return new pexprs$1.Param(index);
|
|
5341
5370
|
},
|
|
5342
5371
|
|
|
5343
5372
|
alt(...termArgs) {
|
|
5344
5373
|
let terms = [];
|
|
5345
5374
|
for (let arg of termArgs) {
|
|
5346
|
-
if (!(arg instanceof pexprs$
|
|
5375
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5347
5376
|
arg = this.fromRecipe(arg);
|
|
5348
5377
|
}
|
|
5349
|
-
if (arg instanceof pexprs$
|
|
5378
|
+
if (arg instanceof pexprs$1.Alt) {
|
|
5350
5379
|
terms = terms.concat(arg.terms);
|
|
5351
5380
|
} else {
|
|
5352
5381
|
terms.push(arg);
|
|
5353
5382
|
}
|
|
5354
5383
|
}
|
|
5355
|
-
return terms.length === 1 ? terms[0] : new pexprs$
|
|
5384
|
+
return terms.length === 1 ? terms[0] : new pexprs$1.Alt(terms);
|
|
5356
5385
|
},
|
|
5357
5386
|
|
|
5358
5387
|
seq(...factorArgs) {
|
|
5359
5388
|
let factors = [];
|
|
5360
5389
|
for (let arg of factorArgs) {
|
|
5361
|
-
if (!(arg instanceof pexprs$
|
|
5390
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5362
5391
|
arg = this.fromRecipe(arg);
|
|
5363
5392
|
}
|
|
5364
|
-
if (arg instanceof pexprs$
|
|
5393
|
+
if (arg instanceof pexprs$1.Seq) {
|
|
5365
5394
|
factors = factors.concat(arg.factors);
|
|
5366
5395
|
} else {
|
|
5367
5396
|
factors.push(arg);
|
|
5368
5397
|
}
|
|
5369
5398
|
}
|
|
5370
|
-
return factors.length === 1 ? factors[0] : new pexprs$
|
|
5399
|
+
return factors.length === 1 ? factors[0] : new pexprs$1.Seq(factors);
|
|
5371
5400
|
},
|
|
5372
5401
|
|
|
5373
5402
|
star(expr) {
|
|
5374
|
-
if (!(expr instanceof pexprs$
|
|
5403
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5375
5404
|
expr = this.fromRecipe(expr);
|
|
5376
5405
|
}
|
|
5377
|
-
return new pexprs$
|
|
5406
|
+
return new pexprs$1.Star(expr);
|
|
5378
5407
|
},
|
|
5379
5408
|
|
|
5380
5409
|
plus(expr) {
|
|
5381
|
-
if (!(expr instanceof pexprs$
|
|
5410
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5382
5411
|
expr = this.fromRecipe(expr);
|
|
5383
5412
|
}
|
|
5384
|
-
return new pexprs$
|
|
5413
|
+
return new pexprs$1.Plus(expr);
|
|
5385
5414
|
},
|
|
5386
5415
|
|
|
5387
5416
|
opt(expr) {
|
|
5388
|
-
if (!(expr instanceof pexprs$
|
|
5417
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5389
5418
|
expr = this.fromRecipe(expr);
|
|
5390
5419
|
}
|
|
5391
|
-
return new pexprs$
|
|
5420
|
+
return new pexprs$1.Opt(expr);
|
|
5392
5421
|
},
|
|
5393
5422
|
|
|
5394
5423
|
not(expr) {
|
|
5395
|
-
if (!(expr instanceof pexprs$
|
|
5424
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5396
5425
|
expr = this.fromRecipe(expr);
|
|
5397
5426
|
}
|
|
5398
|
-
return new pexprs$
|
|
5427
|
+
return new pexprs$1.Not(expr);
|
|
5399
5428
|
},
|
|
5400
5429
|
|
|
5401
5430
|
la(expr) {
|
|
@@ -5404,33 +5433,33 @@ Builder$2.prototype = {
|
|
|
5404
5433
|
},
|
|
5405
5434
|
|
|
5406
5435
|
lookahead(expr) {
|
|
5407
|
-
if (!(expr instanceof pexprs$
|
|
5436
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5408
5437
|
expr = this.fromRecipe(expr);
|
|
5409
5438
|
}
|
|
5410
|
-
return new pexprs$
|
|
5439
|
+
return new pexprs$1.Lookahead(expr);
|
|
5411
5440
|
},
|
|
5412
5441
|
|
|
5413
5442
|
lex(expr) {
|
|
5414
|
-
if (!(expr instanceof pexprs$
|
|
5443
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5415
5444
|
expr = this.fromRecipe(expr);
|
|
5416
5445
|
}
|
|
5417
|
-
return new pexprs$
|
|
5446
|
+
return new pexprs$1.Lex(expr);
|
|
5418
5447
|
},
|
|
5419
5448
|
|
|
5420
5449
|
app(ruleName, optParams) {
|
|
5421
5450
|
if (optParams && optParams.length > 0) {
|
|
5422
5451
|
optParams = optParams.map(function(param) {
|
|
5423
|
-
return param instanceof pexprs$
|
|
5452
|
+
return param instanceof pexprs$1.PExpr ? param : this.fromRecipe(param);
|
|
5424
5453
|
}, this);
|
|
5425
5454
|
}
|
|
5426
|
-
return new pexprs$
|
|
5455
|
+
return new pexprs$1.Apply(ruleName, optParams);
|
|
5427
5456
|
},
|
|
5428
5457
|
|
|
5429
5458
|
// Note that unlike other methods in this class, this method cannot be used as a
|
|
5430
5459
|
// convenience constructor. It only works with recipes, because it relies on
|
|
5431
5460
|
// `this.currentDecl` and `this.currentRuleName` being set.
|
|
5432
5461
|
splice(beforeTerms, afterTerms) {
|
|
5433
|
-
return new pexprs$
|
|
5462
|
+
return new pexprs$1.Splice(
|
|
5434
5463
|
this.currentDecl.superGrammar,
|
|
5435
5464
|
this.currentRuleName,
|
|
5436
5465
|
beforeTerms.map(term => this.fromRecipe(term)),
|
|
@@ -5460,7 +5489,7 @@ Builder$2.prototype = {
|
|
|
5460
5489
|
var Builder_1 = Builder$2;
|
|
5461
5490
|
|
|
5462
5491
|
var name = "ohm-js";
|
|
5463
|
-
var version$2 = "16.
|
|
5492
|
+
var version$2 = "16.3.1";
|
|
5464
5493
|
var description = "An object-oriented language for parsing and pattern matching";
|
|
5465
5494
|
var repository = "https://github.com/harc/ohm";
|
|
5466
5495
|
var keywords = [
|
|
@@ -5475,7 +5504,7 @@ var keywords = [
|
|
|
5475
5504
|
"rapid",
|
|
5476
5505
|
"prototyping"
|
|
5477
5506
|
];
|
|
5478
|
-
var homepage = "https://
|
|
5507
|
+
var homepage = "https://ohmjs.org";
|
|
5479
5508
|
var bugs = "https://github.com/harc/ohm/issues";
|
|
5480
5509
|
var main = "index.js";
|
|
5481
5510
|
var module = "dist/ohm.esm.js";
|
|
@@ -5519,33 +5548,35 @@ var contributors = [
|
|
|
5519
5548
|
"Jason Merrill <jwmerrill@gmail.com>",
|
|
5520
5549
|
"Ray Toal <rtoal@lmu.edu>",
|
|
5521
5550
|
"Yoshiki Ohshima <Yoshiki.Ohshima@acm.org>",
|
|
5551
|
+
"megabuz <3299889+megabuz@users.noreply.github.com>",
|
|
5522
5552
|
"stagas <gstagas@gmail.com>",
|
|
5523
5553
|
"Jonathan Edwards <JonathanMEdwards@gmail.com>",
|
|
5524
5554
|
"Milan Lajtoš <milan.lajtos@me.com>",
|
|
5525
5555
|
"Neil Jewers <njjewers@uwaterloo.ca>",
|
|
5526
|
-
"megabuz <3299889+megabuz@users.noreply.github.com>",
|
|
5527
5556
|
"Mike Niebling <(none)>",
|
|
5528
|
-
"
|
|
5529
|
-
"
|
|
5557
|
+
"AngryPowman <angrypowman@qq.com>",
|
|
5558
|
+
"Patrick Dubroy <patrick@sourcegraph.com>",
|
|
5559
|
+
"Leslie Ying <acetophore@users.noreply.github.com>",
|
|
5530
5560
|
"Pierre Donias <pierre.donias@gmail.com>",
|
|
5561
|
+
"Justin Chase <justin.m.chase@gmail.com>",
|
|
5531
5562
|
"Ian Harris <ian@fofgof.xyz>",
|
|
5532
|
-
"Daniel Tomlinson <DanielTomlinson@me.com>",
|
|
5533
5563
|
"Stan Rozenraukh <stan@stanistan.com>",
|
|
5534
5564
|
"Stephan Seidt <stephan.seidt@gmail.com>",
|
|
5535
5565
|
"Steve Phillips <steve@tryingtobeawesome.com>",
|
|
5536
5566
|
"Szymon Kaliski <kaliskiszymon@gmail.com>",
|
|
5537
5567
|
"Thomas Nyberg <tomnyberg@gmail.com>",
|
|
5538
|
-
"
|
|
5568
|
+
"Daniel Tomlinson <DanielTomlinson@me.com>",
|
|
5539
5569
|
"Vse Mozhet Byt <vsemozhetbyt@gmail.com>",
|
|
5540
5570
|
"Wil Chung <10446+iamwilhelm@users.noreply.github.com>",
|
|
5541
|
-
"
|
|
5571
|
+
"Casey Olson <casey.m.olson@gmail.com>",
|
|
5542
5572
|
"abego <ub@abego-software.de>",
|
|
5543
5573
|
"acslk <d_vd415@hotmail.com>",
|
|
5544
5574
|
"codeZeilen <codeZeilen@users.noreply.github.com>",
|
|
5545
|
-
"
|
|
5575
|
+
"kassadin <kassadin@foxmail.com>",
|
|
5576
|
+
"Arthur Carabott <arthurc@gmail.com>",
|
|
5577
|
+
"owch <bowenrainyday@gmail.com>",
|
|
5546
5578
|
"Luca Guzzon <luca.guzzon@gmail.com>",
|
|
5547
|
-
"
|
|
5548
|
-
"owch <bowenrainyday@gmail.com>"
|
|
5579
|
+
"sfinnie <scott.finnie@gmail.com>"
|
|
5549
5580
|
];
|
|
5550
5581
|
var dependencies = {
|
|
5551
5582
|
};
|
|
@@ -5646,13 +5677,13 @@ var builtInRules = makeRecipe$3(["grammar",{"source":"BuiltInRules {\n\n alnum
|
|
|
5646
5677
|
// Imports
|
|
5647
5678
|
// --------------------------------------------------------------------
|
|
5648
5679
|
|
|
5649
|
-
const Grammar$
|
|
5680
|
+
const Grammar$1 = Grammar_1;
|
|
5650
5681
|
|
|
5651
5682
|
// --------------------------------------------------------------------
|
|
5652
5683
|
// Private stuff
|
|
5653
5684
|
// --------------------------------------------------------------------
|
|
5654
5685
|
|
|
5655
|
-
Grammar$
|
|
5686
|
+
Grammar$1.BuiltInRules = builtInRules;
|
|
5656
5687
|
|
|
5657
5688
|
var {makeRecipe: makeRecipe$2} = makeRecipe$5;
|
|
5658
5689
|
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",[]]]]}]);
|
|
@@ -5718,18 +5749,18 @@ function initPrototypeParser(grammar) {
|
|
|
5718
5749
|
}
|
|
5719
5750
|
|
|
5720
5751
|
var {makeRecipe: makeRecipe$1} = makeRecipe$5;
|
|
5721
|
-
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 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 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,1640]},null,[],["alt",{"sourceInterval":[1602,1640]},["app",{"sourceInterval":[1602,1612]},"escapeChar",[]],["seq",{"sourceInterval":[1619,1640]},["not",{"sourceInterval":[1619,1624]},["terminal",{"sourceInterval":[1620,1624]},"\\"]],["not",{"sourceInterval":[1625,1630]},["terminal",{"sourceInterval":[1626,1630]},"\""]],["not",{"sourceInterval":[1631,1636]},["terminal",{"sourceInterval":[1632,1636]},"\n"]],["app",{"sourceInterval":[1637,1640]},"any",[]]]]],"escapeChar_backslash":["define",{"sourceInterval":[1683,1738]},null,[],["terminal",{"sourceInterval":[1683,1689]},"\\\\"]],"escapeChar_doubleQuote":["define",{"sourceInterval":[1745,1802]},null,[],["terminal",{"sourceInterval":[1745,1751]},"\\\""]],"escapeChar_singleQuote":["define",{"sourceInterval":[1809,1866]},null,[],["terminal",{"sourceInterval":[1809,1815]},"\\'"]],"escapeChar_backspace":["define",{"sourceInterval":[1873,1928]},null,[],["terminal",{"sourceInterval":[1873,1878]},"\\b"]],"escapeChar_lineFeed":["define",{"sourceInterval":[1935,1989]},null,[],["terminal",{"sourceInterval":[1935,1940]},"\\n"]],"escapeChar_carriageReturn":["define",{"sourceInterval":[1996,2056]},null,[],["terminal",{"sourceInterval":[1996,2001]},"\\r"]],"escapeChar_tab":["define",{"sourceInterval":[2063,2112]},null,[],["terminal",{"sourceInterval":[2063,2068]},"\\t"]],"escapeChar_unicodeEscape":["define",{"sourceInterval":[2119,2178]},null,[],["seq",{"sourceInterval":[2119,2160]},["terminal",{"sourceInterval":[2119,2124]},"\\u"],["app",{"sourceInterval":[2125,2133]},"hexDigit",[]],["app",{"sourceInterval":[2134,2142]},"hexDigit",[]],["app",{"sourceInterval":[2143,2151]},"hexDigit",[]],["app",{"sourceInterval":[2152,2160]},"hexDigit",[]]]],"escapeChar_hexEscape":["define",{"sourceInterval":[2185,2240]},null,[],["seq",{"sourceInterval":[2185,2208]},["terminal",{"sourceInterval":[2185,2190]},"\\x"],["app",{"sourceInterval":[2191,2199]},"hexDigit",[]],["app",{"sourceInterval":[2200,2208]},"hexDigit",[]]]],"escapeChar":["define",{"sourceInterval":[1644,2240]},"an escape sequence",[],["alt",{"sourceInterval":[1683,2240]},["app",{"sourceInterval":[1683,1689]},"escapeChar_backslash",[]],["app",{"sourceInterval":[1745,1751]},"escapeChar_doubleQuote",[]],["app",{"sourceInterval":[1809,1815]},"escapeChar_singleQuote",[]],["app",{"sourceInterval":[1873,1878]},"escapeChar_backspace",[]],["app",{"sourceInterval":[1935,1940]},"escapeChar_lineFeed",[]],["app",{"sourceInterval":[1996,2001]},"escapeChar_carriageReturn",[]],["app",{"sourceInterval":[2063,2068]},"escapeChar_tab",[]],["app",{"sourceInterval":[2119,2160]},"escapeChar_unicodeEscape",[]],["app",{"sourceInterval":[2185,2208]},"escapeChar_hexEscape",[]]]],"space":["extend",{"sourceInterval":[2244,2263]},null,[],["app",{"sourceInterval":[2256,2263]},"comment",[]]],"comment_singleLine":["define",{"sourceInterval":[2281,2327]},null,[],["seq",{"sourceInterval":[2281,2312]},["terminal",{"sourceInterval":[2281,2285]},"//"],["star",{"sourceInterval":[2286,2298]},["seq",{"sourceInterval":[2287,2296]},["not",{"sourceInterval":[2287,2292]},["terminal",{"sourceInterval":[2288,2292]},"\n"]],["app",{"sourceInterval":[2293,2296]},"any",[]]]],["lookahead",{"sourceInterval":[2299,2312]},["alt",{"sourceInterval":[2301,2311]},["terminal",{"sourceInterval":[2301,2305]},"\n"],["app",{"sourceInterval":[2308,2311]},"end",[]]]]]],"comment_multiLine":["define",{"sourceInterval":[2334,2370]},null,[],["seq",{"sourceInterval":[2334,2356]},["terminal",{"sourceInterval":[2334,2338]},"/*"],["star",{"sourceInterval":[2339,2351]},["seq",{"sourceInterval":[2340,2349]},["not",{"sourceInterval":[2340,2345]},["terminal",{"sourceInterval":[2341,2345]},"*/"]],["app",{"sourceInterval":[2346,2349]},"any",[]]]],["terminal",{"sourceInterval":[2352,2356]},"*/"]]],"comment":["define",{"sourceInterval":[2267,2370]},null,[],["alt",{"sourceInterval":[2281,2370]},["app",{"sourceInterval":[2281,2312]},"comment_singleLine",[]],["app",{"sourceInterval":[2334,2356]},"comment_multiLine",[]]]],"tokens":["define",{"sourceInterval":[2374,2389]},null,[],["star",{"sourceInterval":[2383,2389]},["app",{"sourceInterval":[2383,2388]},"token",[]]]],"token":["define",{"sourceInterval":[2393,2469]},null,[],["alt",{"sourceInterval":[2401,2469]},["app",{"sourceInterval":[2401,2409]},"caseName",[]],["app",{"sourceInterval":[2412,2419]},"comment",[]],["app",{"sourceInterval":[2422,2427]},"ident",[]],["app",{"sourceInterval":[2430,2438]},"operator",[]],["app",{"sourceInterval":[2441,2452]},"punctuation",[]],["app",{"sourceInterval":[2455,2463]},"terminal",[]],["app",{"sourceInterval":[2466,2469]},"any",[]]]],"operator":["define",{"sourceInterval":[2473,2538]},null,[],["alt",{"sourceInterval":[2484,2538]},["terminal",{"sourceInterval":[2484,2488]},"<:"],["terminal",{"sourceInterval":[2491,2494]},"="],["terminal",{"sourceInterval":[2497,2501]},":="],["terminal",{"sourceInterval":[2504,2508]},"+="],["terminal",{"sourceInterval":[2511,2514]},"*"],["terminal",{"sourceInterval":[2517,2520]},"+"],["terminal",{"sourceInterval":[2523,2526]},"?"],["terminal",{"sourceInterval":[2529,2532]},"~"],["terminal",{"sourceInterval":[2535,2538]},"&"]]],"punctuation":["define",{"sourceInterval":[2542,2578]},null,[],["alt",{"sourceInterval":[2556,2578]},["terminal",{"sourceInterval":[2556,2559]},"<"],["terminal",{"sourceInterval":[2562,2565]},">"],["terminal",{"sourceInterval":[2568,2571]},","],["terminal",{"sourceInterval":[2574,2578]},"--"]]]}]);
|
|
5752
|
+
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]},"--"]]]}]);
|
|
5722
5753
|
|
|
5723
5754
|
// --------------------------------------------------------------------
|
|
5724
5755
|
// Imports
|
|
5725
5756
|
// --------------------------------------------------------------------
|
|
5726
5757
|
|
|
5727
5758
|
const Builder = Builder_1;
|
|
5728
|
-
const Grammar
|
|
5759
|
+
const Grammar = Grammar_1;
|
|
5729
5760
|
const Namespace = Namespace_1;
|
|
5730
5761
|
const common = common$l;
|
|
5731
5762
|
const errors = errors$9;
|
|
5732
|
-
const pexprs
|
|
5763
|
+
const pexprs = pexprs$6;
|
|
5733
5764
|
const util = util$7;
|
|
5734
5765
|
const version = version$1;
|
|
5735
5766
|
const {makeRecipe} = makeRecipe$5;
|
|
@@ -5742,7 +5773,7 @@ const {makeRecipe} = makeRecipe$5;
|
|
|
5742
5773
|
// bottom of this file because loading the grammar requires Ohm itself.
|
|
5743
5774
|
let ohmGrammar;
|
|
5744
5775
|
|
|
5745
|
-
const superSplicePlaceholder = Object.create(pexprs
|
|
5776
|
+
const superSplicePlaceholder = Object.create(pexprs.PExpr.prototype);
|
|
5746
5777
|
|
|
5747
5778
|
const isBuffer = obj =>
|
|
5748
5779
|
!!obj.constructor &&
|
|
@@ -5797,7 +5828,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5797
5828
|
currentRuleFormals = fs.children.map(c => c.visit())[0] || [];
|
|
5798
5829
|
// If there is no default start rule yet, set it now. This must be done before visiting
|
|
5799
5830
|
// the body, because it might contain an inline rule definition.
|
|
5800
|
-
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar
|
|
5831
|
+
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar.ProtoBuiltInRules) {
|
|
5801
5832
|
decl.withDefaultStartRule(currentRuleName);
|
|
5802
5833
|
}
|
|
5803
5834
|
const body = b.visit();
|
|
@@ -5841,7 +5872,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5841
5872
|
if (t === superSplicePlaceholder) throw errors.multipleSuperSplices(t);
|
|
5842
5873
|
});
|
|
5843
5874
|
|
|
5844
|
-
return new pexprs
|
|
5875
|
+
return new pexprs.Splice(
|
|
5845
5876
|
decl.superGrammar,
|
|
5846
5877
|
currentRuleName,
|
|
5847
5878
|
beforeTerms,
|
|
@@ -5946,12 +5977,15 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5946
5977
|
return c.visit();
|
|
5947
5978
|
},
|
|
5948
5979
|
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5980
|
+
escapeChar(c) {
|
|
5981
|
+
try {
|
|
5982
|
+
return common.unescapeCodePoint(this.sourceString);
|
|
5983
|
+
} catch (err) {
|
|
5984
|
+
if (err instanceof RangeError && err.message.startsWith('Invalid code point ')) {
|
|
5985
|
+
throw errors.invalidCodePoint(c);
|
|
5986
|
+
}
|
|
5987
|
+
throw err; // Rethrow
|
|
5988
|
+
}
|
|
5955
5989
|
},
|
|
5956
5990
|
|
|
5957
5991
|
NonemptyListOf(x, _, xs) {
|
|
@@ -6035,7 +6069,7 @@ main$1.exports = {
|
|
|
6035
6069
|
grammarsFromScriptElements,
|
|
6036
6070
|
makeRecipe,
|
|
6037
6071
|
ohmGrammar: null, // Initialized below, after Grammar.BuiltInRules.
|
|
6038
|
-
pexprs
|
|
6072
|
+
pexprs,
|
|
6039
6073
|
util,
|
|
6040
6074
|
version,
|
|
6041
6075
|
};
|
|
@@ -6046,10 +6080,10 @@ main$1.exports._buildGrammar = buildGrammar;
|
|
|
6046
6080
|
// Late initialization for stuff that is bootstrapped.
|
|
6047
6081
|
|
|
6048
6082
|
|
|
6049
|
-
util.announceBuiltInRules(Grammar
|
|
6083
|
+
util.announceBuiltInRules(Grammar.BuiltInRules);
|
|
6050
6084
|
|
|
6051
6085
|
main$1.exports.ohmGrammar = ohmGrammar = ohmGrammar$1;
|
|
6052
|
-
Grammar
|
|
6086
|
+
Grammar.initApplicationParser(ohmGrammar, buildGrammar);
|
|
6053
6087
|
|
|
6054
6088
|
var ohm = main$1.exports;
|
|
6055
6089
|
|
|
@@ -6223,14 +6257,6 @@ VisitorFamily.prototype.addOperation = function(signature, actions) {
|
|
|
6223
6257
|
|
|
6224
6258
|
var VisitorFamily_1 = VisitorFamily;
|
|
6225
6259
|
|
|
6226
|
-
// --------------------------------------------------------------------
|
|
6227
|
-
// Imports
|
|
6228
|
-
// --------------------------------------------------------------------
|
|
6229
|
-
|
|
6230
|
-
const pexprs = pexprs$7;
|
|
6231
|
-
const MatchResult = MatchResult_1;
|
|
6232
|
-
const Grammar = Grammar_1;
|
|
6233
|
-
|
|
6234
6260
|
// --------------------------------------------------------------------
|
|
6235
6261
|
// Operations
|
|
6236
6262
|
// --------------------------------------------------------------------
|
|
@@ -6246,11 +6272,6 @@ const defaultOperation = {
|
|
|
6246
6272
|
|
|
6247
6273
|
// without customization
|
|
6248
6274
|
if (!Object.prototype.hasOwnProperty.call(mapping, ctorName)) {
|
|
6249
|
-
// intermediate node
|
|
6250
|
-
if (this._node instanceof pexprs.Alt || this._node instanceof pexprs.Apply) {
|
|
6251
|
-
return children[0].toAST(mapping);
|
|
6252
|
-
}
|
|
6253
|
-
|
|
6254
6275
|
// lexical rule
|
|
6255
6276
|
if (this.isLexical()) {
|
|
6256
6277
|
return this.sourceString;
|
|
@@ -6334,8 +6355,8 @@ const defaultOperation = {
|
|
|
6334
6355
|
// The optional `mapping` parameter can be used to customize how the nodes of the CST
|
|
6335
6356
|
// are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).
|
|
6336
6357
|
function toAST(res, mapping) {
|
|
6337
|
-
if (
|
|
6338
|
-
throw new Error('toAST() expects a
|
|
6358
|
+
if (typeof res.failed !== 'function' || res.failed()) {
|
|
6359
|
+
throw new Error('toAST() expects a succesful MatchResult as first parameter');
|
|
6339
6360
|
}
|
|
6340
6361
|
|
|
6341
6362
|
mapping = Object.assign({}, mapping);
|
|
@@ -6353,7 +6374,7 @@ function toAST(res, mapping) {
|
|
|
6353
6374
|
|
|
6354
6375
|
// Returns a semantics containg the toAST(mapping) operation for the given grammar g.
|
|
6355
6376
|
function semanticsForToAST(g) {
|
|
6356
|
-
if (
|
|
6377
|
+
if (typeof g.createSemantics !== 'function') {
|
|
6357
6378
|
throw new Error('semanticsToAST() expects a Grammar as parameter');
|
|
6358
6379
|
}
|
|
6359
6380
|
|