ohm-js 16.3.0 → 16.3.3
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 +5 -5
- package/dist/ohm.esm.js +371 -409
- package/dist/ohm.js +36 -52
- package/dist/ohm.min.js +1 -1
- package/extras/semantics-toAST.js +3 -16
- package/index.d.ts +0 -7
- package/package.json +17 -16
- package/src/CaseInsensitiveTerminal.js +1 -1
- package/src/MatchState.js +6 -2
- package/src/Semantics.js +1 -18
- package/src/errors.js +4 -1
- package/src/nodes.js +21 -32
- package/src/pexprs-eval.js +8 -13
package/dist/ohm.esm.js
CHANGED
|
@@ -293,20 +293,19 @@ exports.unexpectedObjToString = function(obj) {
|
|
|
293
293
|
|
|
294
294
|
const common$k = common$l;
|
|
295
295
|
|
|
296
|
-
// Ensures that the deprecation warning for `primitiveValue` only appears once.
|
|
297
|
-
let didWarnForPrimitiveValue = false;
|
|
298
|
-
|
|
299
296
|
// --------------------------------------------------------------------
|
|
300
297
|
// Private stuff
|
|
301
298
|
// --------------------------------------------------------------------
|
|
302
299
|
|
|
303
300
|
class Node {
|
|
304
|
-
constructor(
|
|
305
|
-
this.grammar = grammar;
|
|
306
|
-
this.ctorName = ctorName;
|
|
301
|
+
constructor(matchLength) {
|
|
307
302
|
this.matchLength = matchLength;
|
|
308
303
|
}
|
|
309
304
|
|
|
305
|
+
get ctorName() {
|
|
306
|
+
throw new Error('subclass responsibility');
|
|
307
|
+
}
|
|
308
|
+
|
|
310
309
|
numChildren() {
|
|
311
310
|
return this.children ? this.children.length : 0;
|
|
312
311
|
}
|
|
@@ -400,52 +399,38 @@ class Node {
|
|
|
400
399
|
isOptional() {
|
|
401
400
|
return false;
|
|
402
401
|
}
|
|
403
|
-
|
|
404
|
-
toJSON() {
|
|
405
|
-
return {[this.ctorName]: this.children};
|
|
406
|
-
}
|
|
407
402
|
}
|
|
408
403
|
|
|
409
404
|
// Terminals
|
|
410
405
|
|
|
411
406
|
class TerminalNode$2 extends Node {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
super(grammar, '_terminal', matchLength);
|
|
415
|
-
this._value = value;
|
|
407
|
+
get ctorName() {
|
|
408
|
+
return '_terminal';
|
|
416
409
|
}
|
|
417
410
|
|
|
418
411
|
isTerminal() {
|
|
419
412
|
return true;
|
|
420
413
|
}
|
|
421
414
|
|
|
422
|
-
toJSON() {
|
|
423
|
-
return {[this.ctorName]: this._value};
|
|
424
|
-
}
|
|
425
|
-
|
|
426
415
|
get primitiveValue() {
|
|
427
|
-
|
|
428
|
-
// eslint-disable-next-line no-console
|
|
429
|
-
console.warn(
|
|
430
|
-
'Warning: primitiveValue is deprecated and will be removed in a future version of Ohm. ' +
|
|
431
|
-
'Use sourceString instead.'
|
|
432
|
-
);
|
|
433
|
-
didWarnForPrimitiveValue = true;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return this._value;
|
|
416
|
+
throw new Error('The `primitiveValue` property was removed in Ohm v17.');
|
|
437
417
|
}
|
|
438
418
|
}
|
|
439
419
|
|
|
440
420
|
// Nonterminals
|
|
441
421
|
|
|
442
422
|
class NonterminalNode$1 extends Node {
|
|
443
|
-
constructor(
|
|
444
|
-
super(
|
|
423
|
+
constructor(ruleName, children, childOffsets, matchLength) {
|
|
424
|
+
super(matchLength);
|
|
425
|
+
this.ruleName = ruleName;
|
|
445
426
|
this.children = children;
|
|
446
427
|
this.childOffsets = childOffsets;
|
|
447
428
|
}
|
|
448
429
|
|
|
430
|
+
get ctorName() {
|
|
431
|
+
return this.ruleName;
|
|
432
|
+
}
|
|
433
|
+
|
|
449
434
|
isNonterminal() {
|
|
450
435
|
return true;
|
|
451
436
|
}
|
|
@@ -462,13 +447,17 @@ class NonterminalNode$1 extends Node {
|
|
|
462
447
|
// Iterations
|
|
463
448
|
|
|
464
449
|
class IterationNode$2 extends Node {
|
|
465
|
-
constructor(
|
|
466
|
-
super(
|
|
450
|
+
constructor(children, childOffsets, matchLength, isOptional) {
|
|
451
|
+
super(matchLength);
|
|
467
452
|
this.children = children;
|
|
468
453
|
this.childOffsets = childOffsets;
|
|
469
454
|
this.optional = isOptional;
|
|
470
455
|
}
|
|
471
456
|
|
|
457
|
+
get ctorName() {
|
|
458
|
+
return '_iter';
|
|
459
|
+
}
|
|
460
|
+
|
|
472
461
|
isIteration() {
|
|
473
462
|
return true;
|
|
474
463
|
}
|
|
@@ -745,7 +734,7 @@ pexprsMain.UnicodeChar = UnicodeChar;
|
|
|
745
734
|
// --------------------------------------------------------------------
|
|
746
735
|
|
|
747
736
|
const common$i = common$l;
|
|
748
|
-
const pexprs$
|
|
737
|
+
const pexprs$l = pexprsMain;
|
|
749
738
|
|
|
750
739
|
// --------------------------------------------------------------------
|
|
751
740
|
// Operations
|
|
@@ -754,7 +743,7 @@ const pexprs$m = pexprsMain;
|
|
|
754
743
|
/*
|
|
755
744
|
Return true if we should skip spaces preceding this expression in a syntactic context.
|
|
756
745
|
*/
|
|
757
|
-
pexprs$
|
|
746
|
+
pexprs$l.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
758
747
|
'allowsSkippingPrecedingSpace'
|
|
759
748
|
);
|
|
760
749
|
|
|
@@ -762,12 +751,12 @@ pexprs$m.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
|
762
751
|
Generally, these are all first-order expressions and (with the exception of Apply)
|
|
763
752
|
directly read from the input stream.
|
|
764
753
|
*/
|
|
765
|
-
pexprs$
|
|
766
|
-
pexprs$
|
|
767
|
-
pexprs$
|
|
768
|
-
pexprs$
|
|
769
|
-
pexprs$
|
|
770
|
-
pexprs$
|
|
754
|
+
pexprs$l.any.allowsSkippingPrecedingSpace =
|
|
755
|
+
pexprs$l.end.allowsSkippingPrecedingSpace =
|
|
756
|
+
pexprs$l.Apply.prototype.allowsSkippingPrecedingSpace =
|
|
757
|
+
pexprs$l.Terminal.prototype.allowsSkippingPrecedingSpace =
|
|
758
|
+
pexprs$l.Range.prototype.allowsSkippingPrecedingSpace =
|
|
759
|
+
pexprs$l.UnicodeChar.prototype.allowsSkippingPrecedingSpace =
|
|
771
760
|
function() {
|
|
772
761
|
return true;
|
|
773
762
|
};
|
|
@@ -775,13 +764,13 @@ pexprs$m.any.allowsSkippingPrecedingSpace =
|
|
|
775
764
|
/*
|
|
776
765
|
Higher-order expressions that don't directly consume input.
|
|
777
766
|
*/
|
|
778
|
-
pexprs$
|
|
779
|
-
pexprs$
|
|
780
|
-
pexprs$
|
|
781
|
-
pexprs$
|
|
782
|
-
pexprs$
|
|
783
|
-
pexprs$
|
|
784
|
-
pexprs$
|
|
767
|
+
pexprs$l.Alt.prototype.allowsSkippingPrecedingSpace =
|
|
768
|
+
pexprs$l.Iter.prototype.allowsSkippingPrecedingSpace =
|
|
769
|
+
pexprs$l.Lex.prototype.allowsSkippingPrecedingSpace =
|
|
770
|
+
pexprs$l.Lookahead.prototype.allowsSkippingPrecedingSpace =
|
|
771
|
+
pexprs$l.Not.prototype.allowsSkippingPrecedingSpace =
|
|
772
|
+
pexprs$l.Param.prototype.allowsSkippingPrecedingSpace =
|
|
773
|
+
pexprs$l.Seq.prototype.allowsSkippingPrecedingSpace =
|
|
785
774
|
function() {
|
|
786
775
|
return false;
|
|
787
776
|
};
|
|
@@ -840,7 +829,7 @@ var Namespace_1 = Namespace$2;
|
|
|
840
829
|
|
|
841
830
|
const {assert: assert$3} = common$l;
|
|
842
831
|
const Namespace$1 = Namespace_1;
|
|
843
|
-
const pexprs$
|
|
832
|
+
const pexprs$k = pexprsMain;
|
|
844
833
|
|
|
845
834
|
// --------------------------------------------------------------------
|
|
846
835
|
// Private stuff
|
|
@@ -1052,7 +1041,10 @@ function invalidCodePoint(applyWrapper) {
|
|
|
1052
1041
|
// Get an interval that covers all of the hex digits.
|
|
1053
1042
|
const digitIntervals = applyWrapper.children.slice(1, -1).map(d => d.source);
|
|
1054
1043
|
const fullInterval = digitIntervals[0].coverageWith(...digitIntervals.slice(1));
|
|
1055
|
-
return createError(
|
|
1044
|
+
return createError(
|
|
1045
|
+
`U+${fullInterval.contents} is not a valid Unicode code point`,
|
|
1046
|
+
fullInterval
|
|
1047
|
+
);
|
|
1056
1048
|
}
|
|
1057
1049
|
|
|
1058
1050
|
// ----------------- Kleene operators -----------------
|
|
@@ -1069,7 +1061,7 @@ function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
|
1069
1061
|
"' (possible infinite loop)";
|
|
1070
1062
|
if (applicationStack.length > 0) {
|
|
1071
1063
|
const stackTrace = applicationStack
|
|
1072
|
-
.map(app => new pexprs$
|
|
1064
|
+
.map(app => new pexprs$k.Apply(app.ruleName, app.args))
|
|
1073
1065
|
.join('\n');
|
|
1074
1066
|
message += '\nApplication stack (most recent application last):\n' + stackTrace;
|
|
1075
1067
|
}
|
|
@@ -1372,7 +1364,7 @@ exports.uniqueId = (() => {
|
|
|
1372
1364
|
|
|
1373
1365
|
const {abstract, isSyntactic} = common$l;
|
|
1374
1366
|
const errors$8 = errors$9;
|
|
1375
|
-
const pexprs$
|
|
1367
|
+
const pexprs$j = pexprsMain;
|
|
1376
1368
|
const util$6 = util$7;
|
|
1377
1369
|
|
|
1378
1370
|
let BuiltInRules;
|
|
@@ -1387,51 +1379,51 @@ util$6.awaitBuiltInRules(g => {
|
|
|
1387
1379
|
|
|
1388
1380
|
let lexifyCount;
|
|
1389
1381
|
|
|
1390
|
-
pexprs$
|
|
1382
|
+
pexprs$j.PExpr.prototype.assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1391
1383
|
lexifyCount = 0;
|
|
1392
1384
|
this._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1393
1385
|
};
|
|
1394
1386
|
|
|
1395
|
-
pexprs$
|
|
1387
|
+
pexprs$j.PExpr.prototype._assertAllApplicationsAreValid = abstract(
|
|
1396
1388
|
'_assertAllApplicationsAreValid'
|
|
1397
1389
|
);
|
|
1398
1390
|
|
|
1399
|
-
pexprs$
|
|
1400
|
-
pexprs$
|
|
1401
|
-
pexprs$
|
|
1402
|
-
pexprs$
|
|
1403
|
-
pexprs$
|
|
1404
|
-
pexprs$
|
|
1391
|
+
pexprs$j.any._assertAllApplicationsAreValid =
|
|
1392
|
+
pexprs$j.end._assertAllApplicationsAreValid =
|
|
1393
|
+
pexprs$j.Terminal.prototype._assertAllApplicationsAreValid =
|
|
1394
|
+
pexprs$j.Range.prototype._assertAllApplicationsAreValid =
|
|
1395
|
+
pexprs$j.Param.prototype._assertAllApplicationsAreValid =
|
|
1396
|
+
pexprs$j.UnicodeChar.prototype._assertAllApplicationsAreValid =
|
|
1405
1397
|
function(ruleName, grammar) {
|
|
1406
1398
|
// no-op
|
|
1407
1399
|
};
|
|
1408
1400
|
|
|
1409
|
-
pexprs$
|
|
1401
|
+
pexprs$j.Lex.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1410
1402
|
lexifyCount++;
|
|
1411
1403
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1412
1404
|
lexifyCount--;
|
|
1413
1405
|
};
|
|
1414
1406
|
|
|
1415
|
-
pexprs$
|
|
1407
|
+
pexprs$j.Alt.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1416
1408
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1417
1409
|
this.terms[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1418
1410
|
}
|
|
1419
1411
|
};
|
|
1420
1412
|
|
|
1421
|
-
pexprs$
|
|
1413
|
+
pexprs$j.Seq.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1422
1414
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1423
1415
|
this.factors[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1424
1416
|
}
|
|
1425
1417
|
};
|
|
1426
1418
|
|
|
1427
|
-
pexprs$
|
|
1428
|
-
pexprs$
|
|
1429
|
-
pexprs$
|
|
1419
|
+
pexprs$j.Iter.prototype._assertAllApplicationsAreValid =
|
|
1420
|
+
pexprs$j.Not.prototype._assertAllApplicationsAreValid =
|
|
1421
|
+
pexprs$j.Lookahead.prototype._assertAllApplicationsAreValid =
|
|
1430
1422
|
function(ruleName, grammar) {
|
|
1431
1423
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1432
1424
|
};
|
|
1433
1425
|
|
|
1434
|
-
pexprs$
|
|
1426
|
+
pexprs$j.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
1435
1427
|
ruleName,
|
|
1436
1428
|
grammar,
|
|
1437
1429
|
skipSyntacticCheck = false
|
|
@@ -1463,14 +1455,14 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1463
1455
|
|
|
1464
1456
|
// If it's an application of 'caseInsensitive', ensure that the argument is a Terminal.
|
|
1465
1457
|
if (isBuiltInCaseInsensitive) {
|
|
1466
|
-
if (!(this.args[0] instanceof pexprs$
|
|
1458
|
+
if (!(this.args[0] instanceof pexprs$j.Terminal)) {
|
|
1467
1459
|
throw errors$8.incorrectArgumentType('a Terminal (e.g. "abc")', this.args[0]);
|
|
1468
1460
|
}
|
|
1469
1461
|
}
|
|
1470
1462
|
|
|
1471
1463
|
if (isBuiltInApplySyntactic) {
|
|
1472
1464
|
const arg = this.args[0];
|
|
1473
|
-
if (!(arg instanceof pexprs$
|
|
1465
|
+
if (!(arg instanceof pexprs$j.Apply)) {
|
|
1474
1466
|
throw errors$8.incorrectArgumentType('a syntactic rule application', arg);
|
|
1475
1467
|
}
|
|
1476
1468
|
if (!isSyntactic(arg.ruleName)) {
|
|
@@ -1498,28 +1490,28 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1498
1490
|
|
|
1499
1491
|
const common$h = common$l;
|
|
1500
1492
|
const errors$7 = errors$9;
|
|
1501
|
-
const pexprs$
|
|
1493
|
+
const pexprs$i = pexprsMain;
|
|
1502
1494
|
|
|
1503
1495
|
// --------------------------------------------------------------------
|
|
1504
1496
|
// Operations
|
|
1505
1497
|
// --------------------------------------------------------------------
|
|
1506
1498
|
|
|
1507
|
-
pexprs$
|
|
1499
|
+
pexprs$i.PExpr.prototype.assertChoicesHaveUniformArity = common$h.abstract(
|
|
1508
1500
|
'assertChoicesHaveUniformArity'
|
|
1509
1501
|
);
|
|
1510
1502
|
|
|
1511
|
-
pexprs$
|
|
1512
|
-
pexprs$
|
|
1513
|
-
pexprs$
|
|
1514
|
-
pexprs$
|
|
1515
|
-
pexprs$
|
|
1516
|
-
pexprs$
|
|
1517
|
-
pexprs$
|
|
1503
|
+
pexprs$i.any.assertChoicesHaveUniformArity =
|
|
1504
|
+
pexprs$i.end.assertChoicesHaveUniformArity =
|
|
1505
|
+
pexprs$i.Terminal.prototype.assertChoicesHaveUniformArity =
|
|
1506
|
+
pexprs$i.Range.prototype.assertChoicesHaveUniformArity =
|
|
1507
|
+
pexprs$i.Param.prototype.assertChoicesHaveUniformArity =
|
|
1508
|
+
pexprs$i.Lex.prototype.assertChoicesHaveUniformArity =
|
|
1509
|
+
pexprs$i.UnicodeChar.prototype.assertChoicesHaveUniformArity =
|
|
1518
1510
|
function(ruleName) {
|
|
1519
1511
|
// no-op
|
|
1520
1512
|
};
|
|
1521
1513
|
|
|
1522
|
-
pexprs$
|
|
1514
|
+
pexprs$i.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1523
1515
|
if (this.terms.length === 0) {
|
|
1524
1516
|
return;
|
|
1525
1517
|
}
|
|
@@ -1534,7 +1526,7 @@ pexprs$j.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1534
1526
|
}
|
|
1535
1527
|
};
|
|
1536
1528
|
|
|
1537
|
-
pexprs$
|
|
1529
|
+
pexprs$i.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1538
1530
|
// Extend is a special case of Alt that's guaranteed to have exactly two
|
|
1539
1531
|
// cases: [extensions, origBody].
|
|
1540
1532
|
const actualArity = this.terms[0].getArity();
|
|
@@ -1544,25 +1536,25 @@ pexprs$j.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1544
1536
|
}
|
|
1545
1537
|
};
|
|
1546
1538
|
|
|
1547
|
-
pexprs$
|
|
1539
|
+
pexprs$i.Seq.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1548
1540
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1549
1541
|
this.factors[idx].assertChoicesHaveUniformArity(ruleName);
|
|
1550
1542
|
}
|
|
1551
1543
|
};
|
|
1552
1544
|
|
|
1553
|
-
pexprs$
|
|
1545
|
+
pexprs$i.Iter.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1554
1546
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1555
1547
|
};
|
|
1556
1548
|
|
|
1557
|
-
pexprs$
|
|
1549
|
+
pexprs$i.Not.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1558
1550
|
// no-op (not required b/c the nested expr doesn't show up in the CST)
|
|
1559
1551
|
};
|
|
1560
1552
|
|
|
1561
|
-
pexprs$
|
|
1553
|
+
pexprs$i.Lookahead.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1562
1554
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1563
1555
|
};
|
|
1564
1556
|
|
|
1565
|
-
pexprs$
|
|
1557
|
+
pexprs$i.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1566
1558
|
// The arities of the parameter expressions is required to be 1 by
|
|
1567
1559
|
// `assertAllApplicationsAreValid()`.
|
|
1568
1560
|
};
|
|
@@ -1573,39 +1565,39 @@ pexprs$j.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1573
1565
|
|
|
1574
1566
|
const common$g = common$l;
|
|
1575
1567
|
const errors$6 = errors$9;
|
|
1576
|
-
const pexprs$
|
|
1568
|
+
const pexprs$h = pexprsMain;
|
|
1577
1569
|
|
|
1578
1570
|
// --------------------------------------------------------------------
|
|
1579
1571
|
// Operations
|
|
1580
1572
|
// --------------------------------------------------------------------
|
|
1581
1573
|
|
|
1582
|
-
pexprs$
|
|
1574
|
+
pexprs$h.PExpr.prototype.assertIteratedExprsAreNotNullable = common$g.abstract(
|
|
1583
1575
|
'assertIteratedExprsAreNotNullable'
|
|
1584
1576
|
);
|
|
1585
1577
|
|
|
1586
|
-
pexprs$
|
|
1587
|
-
pexprs$
|
|
1588
|
-
pexprs$
|
|
1589
|
-
pexprs$
|
|
1590
|
-
pexprs$
|
|
1591
|
-
pexprs$
|
|
1578
|
+
pexprs$h.any.assertIteratedExprsAreNotNullable =
|
|
1579
|
+
pexprs$h.end.assertIteratedExprsAreNotNullable =
|
|
1580
|
+
pexprs$h.Terminal.prototype.assertIteratedExprsAreNotNullable =
|
|
1581
|
+
pexprs$h.Range.prototype.assertIteratedExprsAreNotNullable =
|
|
1582
|
+
pexprs$h.Param.prototype.assertIteratedExprsAreNotNullable =
|
|
1583
|
+
pexprs$h.UnicodeChar.prototype.assertIteratedExprsAreNotNullable =
|
|
1592
1584
|
function(grammar) {
|
|
1593
1585
|
// no-op
|
|
1594
1586
|
};
|
|
1595
1587
|
|
|
1596
|
-
pexprs$
|
|
1588
|
+
pexprs$h.Alt.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1597
1589
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1598
1590
|
this.terms[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1599
1591
|
}
|
|
1600
1592
|
};
|
|
1601
1593
|
|
|
1602
|
-
pexprs$
|
|
1594
|
+
pexprs$h.Seq.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1603
1595
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1604
1596
|
this.factors[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1605
1597
|
}
|
|
1606
1598
|
};
|
|
1607
1599
|
|
|
1608
|
-
pexprs$
|
|
1600
|
+
pexprs$h.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1609
1601
|
// Note: this is the implementation of this method for `Star` and `Plus` expressions.
|
|
1610
1602
|
// It is overridden for `Opt` below.
|
|
1611
1603
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
@@ -1614,15 +1606,15 @@ pexprs$i.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
|
1614
1606
|
}
|
|
1615
1607
|
};
|
|
1616
1608
|
|
|
1617
|
-
pexprs$
|
|
1618
|
-
pexprs$
|
|
1619
|
-
pexprs$
|
|
1620
|
-
pexprs$
|
|
1609
|
+
pexprs$h.Opt.prototype.assertIteratedExprsAreNotNullable =
|
|
1610
|
+
pexprs$h.Not.prototype.assertIteratedExprsAreNotNullable =
|
|
1611
|
+
pexprs$h.Lookahead.prototype.assertIteratedExprsAreNotNullable =
|
|
1612
|
+
pexprs$h.Lex.prototype.assertIteratedExprsAreNotNullable =
|
|
1621
1613
|
function(grammar) {
|
|
1622
1614
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
1623
1615
|
};
|
|
1624
1616
|
|
|
1625
|
-
pexprs$
|
|
1617
|
+
pexprs$h.Apply.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1626
1618
|
this.args.forEach(arg => {
|
|
1627
1619
|
arg.assertIteratedExprsAreNotNullable(grammar);
|
|
1628
1620
|
});
|
|
@@ -1987,7 +1979,7 @@ const Trace$1 = Trace_1;
|
|
|
1987
1979
|
const common$e = common$l;
|
|
1988
1980
|
const errors$4 = errors$9;
|
|
1989
1981
|
const nodes = nodes$1;
|
|
1990
|
-
const pexprs$
|
|
1982
|
+
const pexprs$g = pexprsMain;
|
|
1991
1983
|
|
|
1992
1984
|
const {TerminalNode: TerminalNode$1} = nodes;
|
|
1993
1985
|
const {NonterminalNode} = nodes;
|
|
@@ -2013,14 +2005,14 @@ const {IterationNode: IterationNode$1} = nodes;
|
|
|
2013
2005
|
Note that `State.prototype.eval(expr)`, unlike this method, guarantees that neither the state
|
|
2014
2006
|
object's bindings nor its input stream's position will change if the expression fails to match.
|
|
2015
2007
|
*/
|
|
2016
|
-
pexprs$
|
|
2008
|
+
pexprs$g.PExpr.prototype.eval = common$e.abstract('eval'); // function(state) { ... }
|
|
2017
2009
|
|
|
2018
|
-
pexprs$
|
|
2010
|
+
pexprs$g.any.eval = function(state) {
|
|
2019
2011
|
const {inputStream} = state;
|
|
2020
2012
|
const origPos = inputStream.pos;
|
|
2021
2013
|
const ch = inputStream.next();
|
|
2022
2014
|
if (ch) {
|
|
2023
|
-
state.pushBinding(new TerminalNode$1(
|
|
2015
|
+
state.pushBinding(new TerminalNode$1(ch.length), origPos);
|
|
2024
2016
|
return true;
|
|
2025
2017
|
} else {
|
|
2026
2018
|
state.processFailure(origPos, this);
|
|
@@ -2028,11 +2020,11 @@ pexprs$h.any.eval = function(state) {
|
|
|
2028
2020
|
}
|
|
2029
2021
|
};
|
|
2030
2022
|
|
|
2031
|
-
pexprs$
|
|
2023
|
+
pexprs$g.end.eval = function(state) {
|
|
2032
2024
|
const {inputStream} = state;
|
|
2033
2025
|
const origPos = inputStream.pos;
|
|
2034
2026
|
if (inputStream.atEnd()) {
|
|
2035
|
-
state.pushBinding(new TerminalNode$1(
|
|
2027
|
+
state.pushBinding(new TerminalNode$1(0), origPos);
|
|
2036
2028
|
return true;
|
|
2037
2029
|
} else {
|
|
2038
2030
|
state.processFailure(origPos, this);
|
|
@@ -2040,19 +2032,19 @@ pexprs$h.end.eval = function(state) {
|
|
|
2040
2032
|
}
|
|
2041
2033
|
};
|
|
2042
2034
|
|
|
2043
|
-
pexprs$
|
|
2035
|
+
pexprs$g.Terminal.prototype.eval = function(state) {
|
|
2044
2036
|
const {inputStream} = state;
|
|
2045
2037
|
const origPos = inputStream.pos;
|
|
2046
2038
|
if (!inputStream.matchString(this.obj)) {
|
|
2047
2039
|
state.processFailure(origPos, this);
|
|
2048
2040
|
return false;
|
|
2049
2041
|
} else {
|
|
2050
|
-
state.pushBinding(new TerminalNode$1(
|
|
2042
|
+
state.pushBinding(new TerminalNode$1(this.obj.length), origPos);
|
|
2051
2043
|
return true;
|
|
2052
2044
|
}
|
|
2053
2045
|
};
|
|
2054
2046
|
|
|
2055
|
-
pexprs$
|
|
2047
|
+
pexprs$g.Range.prototype.eval = function(state) {
|
|
2056
2048
|
const {inputStream} = state;
|
|
2057
2049
|
const origPos = inputStream.pos;
|
|
2058
2050
|
|
|
@@ -2063,7 +2055,7 @@ pexprs$h.Range.prototype.eval = function(state) {
|
|
|
2063
2055
|
// Always compare by code point value to get the correct result in all scenarios.
|
|
2064
2056
|
// Note that for strings of length 1, codePointAt(0) and charPointAt(0) are equivalent.
|
|
2065
2057
|
if (cp !== undefined && this.from.codePointAt(0) <= cp && cp <= this.to.codePointAt(0)) {
|
|
2066
|
-
state.pushBinding(new TerminalNode$1(
|
|
2058
|
+
state.pushBinding(new TerminalNode$1(String.fromCodePoint(cp).length), origPos);
|
|
2067
2059
|
return true;
|
|
2068
2060
|
} else {
|
|
2069
2061
|
state.processFailure(origPos, this);
|
|
@@ -2071,18 +2063,18 @@ pexprs$h.Range.prototype.eval = function(state) {
|
|
|
2071
2063
|
}
|
|
2072
2064
|
};
|
|
2073
2065
|
|
|
2074
|
-
pexprs$
|
|
2066
|
+
pexprs$g.Param.prototype.eval = function(state) {
|
|
2075
2067
|
return state.eval(state.currentApplication().args[this.index]);
|
|
2076
2068
|
};
|
|
2077
2069
|
|
|
2078
|
-
pexprs$
|
|
2070
|
+
pexprs$g.Lex.prototype.eval = function(state) {
|
|
2079
2071
|
state.enterLexifiedContext();
|
|
2080
2072
|
const ans = state.eval(this.expr);
|
|
2081
2073
|
state.exitLexifiedContext();
|
|
2082
2074
|
return ans;
|
|
2083
2075
|
};
|
|
2084
2076
|
|
|
2085
|
-
pexprs$
|
|
2077
|
+
pexprs$g.Alt.prototype.eval = function(state) {
|
|
2086
2078
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
2087
2079
|
if (state.eval(this.terms[idx])) {
|
|
2088
2080
|
return true;
|
|
@@ -2091,7 +2083,7 @@ pexprs$h.Alt.prototype.eval = function(state) {
|
|
|
2091
2083
|
return false;
|
|
2092
2084
|
};
|
|
2093
2085
|
|
|
2094
|
-
pexprs$
|
|
2086
|
+
pexprs$g.Seq.prototype.eval = function(state) {
|
|
2095
2087
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2096
2088
|
const factor = this.factors[idx];
|
|
2097
2089
|
if (!state.eval(factor)) {
|
|
@@ -2101,7 +2093,7 @@ pexprs$h.Seq.prototype.eval = function(state) {
|
|
|
2101
2093
|
return true;
|
|
2102
2094
|
};
|
|
2103
2095
|
|
|
2104
|
-
pexprs$
|
|
2096
|
+
pexprs$g.Iter.prototype.eval = function(state) {
|
|
2105
2097
|
const {inputStream} = state;
|
|
2106
2098
|
const origPos = inputStream.pos;
|
|
2107
2099
|
const arity = this.getArity();
|
|
@@ -2145,17 +2137,17 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2145
2137
|
offset = colOffsets[0][0];
|
|
2146
2138
|
matchLength = endOffset - offset;
|
|
2147
2139
|
}
|
|
2148
|
-
const isOptional = this instanceof pexprs$
|
|
2140
|
+
const isOptional = this instanceof pexprs$g.Opt;
|
|
2149
2141
|
for (idx = 0; idx < cols.length; idx++) {
|
|
2150
2142
|
state._bindings.push(
|
|
2151
|
-
new IterationNode$1(
|
|
2143
|
+
new IterationNode$1(cols[idx], colOffsets[idx], matchLength, isOptional)
|
|
2152
2144
|
);
|
|
2153
2145
|
state._bindingOffsets.push(offset);
|
|
2154
2146
|
}
|
|
2155
2147
|
return true;
|
|
2156
2148
|
};
|
|
2157
2149
|
|
|
2158
|
-
pexprs$
|
|
2150
|
+
pexprs$g.Not.prototype.eval = function(state) {
|
|
2159
2151
|
/*
|
|
2160
2152
|
TODO:
|
|
2161
2153
|
- Right now we're just throwing away all of the failures that happen inside a `not`, and
|
|
@@ -2181,7 +2173,7 @@ pexprs$h.Not.prototype.eval = function(state) {
|
|
|
2181
2173
|
return true;
|
|
2182
2174
|
};
|
|
2183
2175
|
|
|
2184
|
-
pexprs$
|
|
2176
|
+
pexprs$g.Lookahead.prototype.eval = function(state) {
|
|
2185
2177
|
const {inputStream} = state;
|
|
2186
2178
|
const origPos = inputStream.pos;
|
|
2187
2179
|
if (state.eval(this.expr)) {
|
|
@@ -2192,7 +2184,7 @@ pexprs$h.Lookahead.prototype.eval = function(state) {
|
|
|
2192
2184
|
}
|
|
2193
2185
|
};
|
|
2194
2186
|
|
|
2195
|
-
pexprs$
|
|
2187
|
+
pexprs$g.Apply.prototype.eval = function(state) {
|
|
2196
2188
|
const caller = state.currentApplication();
|
|
2197
2189
|
const actuals = caller ? caller.args : [];
|
|
2198
2190
|
const app = this.substituteParams(actuals);
|
|
@@ -2215,7 +2207,7 @@ pexprs$h.Apply.prototype.eval = function(state) {
|
|
|
2215
2207
|
return app.reallyEval(state);
|
|
2216
2208
|
};
|
|
2217
2209
|
|
|
2218
|
-
pexprs$
|
|
2210
|
+
pexprs$g.Apply.prototype.handleCycle = function(state) {
|
|
2219
2211
|
const posInfo = state.getCurrentPosInfo();
|
|
2220
2212
|
const {currentLeftRecursion} = posInfo;
|
|
2221
2213
|
const memoKey = this.toMemoKey();
|
|
@@ -2238,7 +2230,7 @@ pexprs$h.Apply.prototype.handleCycle = function(state) {
|
|
|
2238
2230
|
return state.useMemoizedResult(state.inputStream.pos, memoRec);
|
|
2239
2231
|
};
|
|
2240
2232
|
|
|
2241
|
-
pexprs$
|
|
2233
|
+
pexprs$g.Apply.prototype.reallyEval = function(state) {
|
|
2242
2234
|
const {inputStream} = state;
|
|
2243
2235
|
const origPos = inputStream.pos;
|
|
2244
2236
|
const origPosInfo = state.getCurrentPosInfo();
|
|
@@ -2315,7 +2307,7 @@ pexprs$h.Apply.prototype.reallyEval = function(state) {
|
|
|
2315
2307
|
return succeeded;
|
|
2316
2308
|
};
|
|
2317
2309
|
|
|
2318
|
-
pexprs$
|
|
2310
|
+
pexprs$g.Apply.prototype.evalOnce = function(expr, state) {
|
|
2319
2311
|
const {inputStream} = state;
|
|
2320
2312
|
const origPos = inputStream.pos;
|
|
2321
2313
|
|
|
@@ -2323,19 +2315,14 @@ pexprs$h.Apply.prototype.evalOnce = function(expr, state) {
|
|
|
2323
2315
|
const arity = expr.getArity();
|
|
2324
2316
|
const bindings = state._bindings.splice(state._bindings.length - arity, arity);
|
|
2325
2317
|
const offsets = state._bindingOffsets.splice(state._bindingOffsets.length - arity, arity);
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
this.ruleName,
|
|
2329
|
-
bindings,
|
|
2330
|
-
offsets,
|
|
2331
|
-
inputStream.pos - origPos
|
|
2332
|
-
);
|
|
2318
|
+
const matchLength = inputStream.pos - origPos;
|
|
2319
|
+
return new NonterminalNode(this.ruleName, bindings, offsets, matchLength);
|
|
2333
2320
|
} else {
|
|
2334
2321
|
return false;
|
|
2335
2322
|
}
|
|
2336
2323
|
};
|
|
2337
2324
|
|
|
2338
|
-
pexprs$
|
|
2325
|
+
pexprs$g.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoRec, newValue) {
|
|
2339
2326
|
if (!newValue) {
|
|
2340
2327
|
return false;
|
|
2341
2328
|
}
|
|
@@ -2379,12 +2366,12 @@ pexprs$h.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoR
|
|
|
2379
2366
|
return lrMemoRec.value;
|
|
2380
2367
|
};
|
|
2381
2368
|
|
|
2382
|
-
pexprs$
|
|
2369
|
+
pexprs$g.UnicodeChar.prototype.eval = function(state) {
|
|
2383
2370
|
const {inputStream} = state;
|
|
2384
2371
|
const origPos = inputStream.pos;
|
|
2385
2372
|
const ch = inputStream.next();
|
|
2386
2373
|
if (ch && this.pattern.test(ch)) {
|
|
2387
|
-
state.pushBinding(new TerminalNode$1(
|
|
2374
|
+
state.pushBinding(new TerminalNode$1(ch.length), origPos);
|
|
2388
2375
|
return true;
|
|
2389
2376
|
} else {
|
|
2390
2377
|
state.processFailure(origPos, this);
|
|
@@ -2397,32 +2384,32 @@ pexprs$h.UnicodeChar.prototype.eval = function(state) {
|
|
|
2397
2384
|
// --------------------------------------------------------------------
|
|
2398
2385
|
|
|
2399
2386
|
const common$d = common$l;
|
|
2400
|
-
const pexprs$
|
|
2387
|
+
const pexprs$f = pexprsMain;
|
|
2401
2388
|
|
|
2402
2389
|
// --------------------------------------------------------------------
|
|
2403
2390
|
// Operations
|
|
2404
2391
|
// --------------------------------------------------------------------
|
|
2405
2392
|
|
|
2406
|
-
pexprs$
|
|
2393
|
+
pexprs$f.PExpr.prototype.getArity = common$d.abstract('getArity');
|
|
2407
2394
|
|
|
2408
|
-
pexprs$
|
|
2409
|
-
pexprs$
|
|
2410
|
-
pexprs$
|
|
2411
|
-
pexprs$
|
|
2412
|
-
pexprs$
|
|
2413
|
-
pexprs$
|
|
2414
|
-
pexprs$
|
|
2395
|
+
pexprs$f.any.getArity =
|
|
2396
|
+
pexprs$f.end.getArity =
|
|
2397
|
+
pexprs$f.Terminal.prototype.getArity =
|
|
2398
|
+
pexprs$f.Range.prototype.getArity =
|
|
2399
|
+
pexprs$f.Param.prototype.getArity =
|
|
2400
|
+
pexprs$f.Apply.prototype.getArity =
|
|
2401
|
+
pexprs$f.UnicodeChar.prototype.getArity =
|
|
2415
2402
|
function() {
|
|
2416
2403
|
return 1;
|
|
2417
2404
|
};
|
|
2418
2405
|
|
|
2419
|
-
pexprs$
|
|
2406
|
+
pexprs$f.Alt.prototype.getArity = function() {
|
|
2420
2407
|
// This is ok b/c all terms must have the same arity -- this property is
|
|
2421
2408
|
// checked by the Grammar constructor.
|
|
2422
2409
|
return this.terms.length === 0 ? 0 : this.terms[0].getArity();
|
|
2423
2410
|
};
|
|
2424
2411
|
|
|
2425
|
-
pexprs$
|
|
2412
|
+
pexprs$f.Seq.prototype.getArity = function() {
|
|
2426
2413
|
let arity = 0;
|
|
2427
2414
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2428
2415
|
arity += this.factors[idx].getArity();
|
|
@@ -2430,15 +2417,15 @@ pexprs$g.Seq.prototype.getArity = function() {
|
|
|
2430
2417
|
return arity;
|
|
2431
2418
|
};
|
|
2432
2419
|
|
|
2433
|
-
pexprs$
|
|
2420
|
+
pexprs$f.Iter.prototype.getArity = function() {
|
|
2434
2421
|
return this.expr.getArity();
|
|
2435
2422
|
};
|
|
2436
2423
|
|
|
2437
|
-
pexprs$
|
|
2424
|
+
pexprs$f.Not.prototype.getArity = function() {
|
|
2438
2425
|
return 0;
|
|
2439
2426
|
};
|
|
2440
2427
|
|
|
2441
|
-
pexprs$
|
|
2428
|
+
pexprs$f.Lookahead.prototype.getArity = pexprs$f.Lex.prototype.getArity = function() {
|
|
2442
2429
|
return this.expr.getArity();
|
|
2443
2430
|
};
|
|
2444
2431
|
|
|
@@ -2447,7 +2434,7 @@ pexprs$g.Lookahead.prototype.getArity = pexprs$g.Lex.prototype.getArity = functi
|
|
|
2447
2434
|
// --------------------------------------------------------------------
|
|
2448
2435
|
|
|
2449
2436
|
const common$c = common$l;
|
|
2450
|
-
const pexprs$
|
|
2437
|
+
const pexprs$e = pexprsMain;
|
|
2451
2438
|
|
|
2452
2439
|
// --------------------------------------------------------------------
|
|
2453
2440
|
// Private stuff
|
|
@@ -2466,40 +2453,40 @@ function getMetaInfo(expr, grammarInterval) {
|
|
|
2466
2453
|
// Operations
|
|
2467
2454
|
// --------------------------------------------------------------------
|
|
2468
2455
|
|
|
2469
|
-
pexprs$
|
|
2456
|
+
pexprs$e.PExpr.prototype.outputRecipe = common$c.abstract('outputRecipe');
|
|
2470
2457
|
|
|
2471
|
-
pexprs$
|
|
2458
|
+
pexprs$e.any.outputRecipe = function(formals, grammarInterval) {
|
|
2472
2459
|
return ['any', getMetaInfo(this, grammarInterval)];
|
|
2473
2460
|
};
|
|
2474
2461
|
|
|
2475
|
-
pexprs$
|
|
2462
|
+
pexprs$e.end.outputRecipe = function(formals, grammarInterval) {
|
|
2476
2463
|
return ['end', getMetaInfo(this, grammarInterval)];
|
|
2477
2464
|
};
|
|
2478
2465
|
|
|
2479
|
-
pexprs$
|
|
2466
|
+
pexprs$e.Terminal.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2480
2467
|
return ['terminal', getMetaInfo(this, grammarInterval), this.obj];
|
|
2481
2468
|
};
|
|
2482
2469
|
|
|
2483
|
-
pexprs$
|
|
2470
|
+
pexprs$e.Range.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2484
2471
|
return ['range', getMetaInfo(this, grammarInterval), this.from, this.to];
|
|
2485
2472
|
};
|
|
2486
2473
|
|
|
2487
|
-
pexprs$
|
|
2474
|
+
pexprs$e.Param.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2488
2475
|
return ['param', getMetaInfo(this, grammarInterval), this.index];
|
|
2489
2476
|
};
|
|
2490
2477
|
|
|
2491
|
-
pexprs$
|
|
2478
|
+
pexprs$e.Alt.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2492
2479
|
return ['alt', getMetaInfo(this, grammarInterval)].concat(
|
|
2493
2480
|
this.terms.map(term => term.outputRecipe(formals, grammarInterval))
|
|
2494
2481
|
);
|
|
2495
2482
|
};
|
|
2496
2483
|
|
|
2497
|
-
pexprs$
|
|
2484
|
+
pexprs$e.Extend.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2498
2485
|
const extension = this.terms[0]; // [extension, original]
|
|
2499
2486
|
return extension.outputRecipe(formals, grammarInterval);
|
|
2500
2487
|
};
|
|
2501
2488
|
|
|
2502
|
-
pexprs$
|
|
2489
|
+
pexprs$e.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2503
2490
|
const beforeTerms = this.terms.slice(0, this.expansionPos);
|
|
2504
2491
|
const afterTerms = this.terms.slice(this.expansionPos + 1);
|
|
2505
2492
|
return [
|
|
@@ -2510,18 +2497,18 @@ pexprs$f.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2510
2497
|
];
|
|
2511
2498
|
};
|
|
2512
2499
|
|
|
2513
|
-
pexprs$
|
|
2500
|
+
pexprs$e.Seq.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2514
2501
|
return ['seq', getMetaInfo(this, grammarInterval)].concat(
|
|
2515
2502
|
this.factors.map(factor => factor.outputRecipe(formals, grammarInterval))
|
|
2516
2503
|
);
|
|
2517
2504
|
};
|
|
2518
2505
|
|
|
2519
|
-
pexprs$
|
|
2520
|
-
pexprs$
|
|
2521
|
-
pexprs$
|
|
2522
|
-
pexprs$
|
|
2523
|
-
pexprs$
|
|
2524
|
-
pexprs$
|
|
2506
|
+
pexprs$e.Star.prototype.outputRecipe =
|
|
2507
|
+
pexprs$e.Plus.prototype.outputRecipe =
|
|
2508
|
+
pexprs$e.Opt.prototype.outputRecipe =
|
|
2509
|
+
pexprs$e.Not.prototype.outputRecipe =
|
|
2510
|
+
pexprs$e.Lookahead.prototype.outputRecipe =
|
|
2511
|
+
pexprs$e.Lex.prototype.outputRecipe =
|
|
2525
2512
|
function(formals, grammarInterval) {
|
|
2526
2513
|
return [
|
|
2527
2514
|
this.constructor.name.toLowerCase(),
|
|
@@ -2530,7 +2517,7 @@ pexprs$f.Star.prototype.outputRecipe =
|
|
|
2530
2517
|
];
|
|
2531
2518
|
};
|
|
2532
2519
|
|
|
2533
|
-
pexprs$
|
|
2520
|
+
pexprs$e.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2534
2521
|
return [
|
|
2535
2522
|
'app',
|
|
2536
2523
|
getMetaInfo(this, grammarInterval),
|
|
@@ -2539,7 +2526,7 @@ pexprs$f.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2539
2526
|
];
|
|
2540
2527
|
};
|
|
2541
2528
|
|
|
2542
|
-
pexprs$
|
|
2529
|
+
pexprs$e.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2543
2530
|
return ['unicodeChar', getMetaInfo(this, grammarInterval), this.category];
|
|
2544
2531
|
};
|
|
2545
2532
|
|
|
@@ -2548,7 +2535,7 @@ pexprs$f.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval)
|
|
|
2548
2535
|
// --------------------------------------------------------------------
|
|
2549
2536
|
|
|
2550
2537
|
const common$b = common$l;
|
|
2551
|
-
const pexprs$
|
|
2538
|
+
const pexprs$d = pexprsMain;
|
|
2552
2539
|
|
|
2553
2540
|
// --------------------------------------------------------------------
|
|
2554
2541
|
// Operations
|
|
@@ -2559,49 +2546,49 @@ const pexprs$e = pexprsMain;
|
|
|
2559
2546
|
parameter with a `Param` node. Returns a PExpr -- either a new one, or the original one if
|
|
2560
2547
|
it was modified in place.
|
|
2561
2548
|
*/
|
|
2562
|
-
pexprs$
|
|
2563
|
-
|
|
2564
|
-
pexprs$
|
|
2565
|
-
pexprs$
|
|
2566
|
-
pexprs$
|
|
2567
|
-
pexprs$
|
|
2568
|
-
pexprs$
|
|
2569
|
-
pexprs$
|
|
2549
|
+
pexprs$d.PExpr.prototype.introduceParams = common$b.abstract('introduceParams');
|
|
2550
|
+
|
|
2551
|
+
pexprs$d.any.introduceParams =
|
|
2552
|
+
pexprs$d.end.introduceParams =
|
|
2553
|
+
pexprs$d.Terminal.prototype.introduceParams =
|
|
2554
|
+
pexprs$d.Range.prototype.introduceParams =
|
|
2555
|
+
pexprs$d.Param.prototype.introduceParams =
|
|
2556
|
+
pexprs$d.UnicodeChar.prototype.introduceParams =
|
|
2570
2557
|
function(formals) {
|
|
2571
2558
|
return this;
|
|
2572
2559
|
};
|
|
2573
2560
|
|
|
2574
|
-
pexprs$
|
|
2561
|
+
pexprs$d.Alt.prototype.introduceParams = function(formals) {
|
|
2575
2562
|
this.terms.forEach((term, idx, terms) => {
|
|
2576
2563
|
terms[idx] = term.introduceParams(formals);
|
|
2577
2564
|
});
|
|
2578
2565
|
return this;
|
|
2579
2566
|
};
|
|
2580
2567
|
|
|
2581
|
-
pexprs$
|
|
2568
|
+
pexprs$d.Seq.prototype.introduceParams = function(formals) {
|
|
2582
2569
|
this.factors.forEach((factor, idx, factors) => {
|
|
2583
2570
|
factors[idx] = factor.introduceParams(formals);
|
|
2584
2571
|
});
|
|
2585
2572
|
return this;
|
|
2586
2573
|
};
|
|
2587
2574
|
|
|
2588
|
-
pexprs$
|
|
2589
|
-
pexprs$
|
|
2590
|
-
pexprs$
|
|
2591
|
-
pexprs$
|
|
2575
|
+
pexprs$d.Iter.prototype.introduceParams =
|
|
2576
|
+
pexprs$d.Not.prototype.introduceParams =
|
|
2577
|
+
pexprs$d.Lookahead.prototype.introduceParams =
|
|
2578
|
+
pexprs$d.Lex.prototype.introduceParams =
|
|
2592
2579
|
function(formals) {
|
|
2593
2580
|
this.expr = this.expr.introduceParams(formals);
|
|
2594
2581
|
return this;
|
|
2595
2582
|
};
|
|
2596
2583
|
|
|
2597
|
-
pexprs$
|
|
2584
|
+
pexprs$d.Apply.prototype.introduceParams = function(formals) {
|
|
2598
2585
|
const index = formals.indexOf(this.ruleName);
|
|
2599
2586
|
if (index >= 0) {
|
|
2600
2587
|
if (this.args.length > 0) {
|
|
2601
2588
|
// TODO: Should this be supported? See issue #64.
|
|
2602
2589
|
throw new Error('Parameterized rules cannot be passed as arguments to another rule.');
|
|
2603
2590
|
}
|
|
2604
|
-
return new pexprs$
|
|
2591
|
+
return new pexprs$d.Param(index).withSource(this.source);
|
|
2605
2592
|
} else {
|
|
2606
2593
|
this.args.forEach((arg, idx, args) => {
|
|
2607
2594
|
args[idx] = arg.introduceParams(formals);
|
|
@@ -2615,33 +2602,33 @@ pexprs$e.Apply.prototype.introduceParams = function(formals) {
|
|
|
2615
2602
|
// --------------------------------------------------------------------
|
|
2616
2603
|
|
|
2617
2604
|
const common$a = common$l;
|
|
2618
|
-
const pexprs$
|
|
2605
|
+
const pexprs$c = pexprsMain;
|
|
2619
2606
|
|
|
2620
2607
|
// --------------------------------------------------------------------
|
|
2621
2608
|
// Operations
|
|
2622
2609
|
// --------------------------------------------------------------------
|
|
2623
2610
|
|
|
2624
2611
|
// Returns `true` if this parsing expression may accept without consuming any input.
|
|
2625
|
-
pexprs$
|
|
2612
|
+
pexprs$c.PExpr.prototype.isNullable = function(grammar) {
|
|
2626
2613
|
return this._isNullable(grammar, Object.create(null));
|
|
2627
2614
|
};
|
|
2628
2615
|
|
|
2629
|
-
pexprs$
|
|
2616
|
+
pexprs$c.PExpr.prototype._isNullable = common$a.abstract('_isNullable');
|
|
2630
2617
|
|
|
2631
|
-
pexprs$
|
|
2632
|
-
pexprs$
|
|
2633
|
-
pexprs$
|
|
2634
|
-
pexprs$
|
|
2635
|
-
pexprs$
|
|
2618
|
+
pexprs$c.any._isNullable =
|
|
2619
|
+
pexprs$c.Range.prototype._isNullable =
|
|
2620
|
+
pexprs$c.Param.prototype._isNullable =
|
|
2621
|
+
pexprs$c.Plus.prototype._isNullable =
|
|
2622
|
+
pexprs$c.UnicodeChar.prototype._isNullable =
|
|
2636
2623
|
function(grammar, memo) {
|
|
2637
2624
|
return false;
|
|
2638
2625
|
};
|
|
2639
2626
|
|
|
2640
|
-
pexprs$
|
|
2627
|
+
pexprs$c.end._isNullable = function(grammar, memo) {
|
|
2641
2628
|
return true;
|
|
2642
2629
|
};
|
|
2643
2630
|
|
|
2644
|
-
pexprs$
|
|
2631
|
+
pexprs$c.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
2645
2632
|
if (typeof this.obj === 'string') {
|
|
2646
2633
|
// This is an over-simplification: it's only correct if the input is a string. If it's an array
|
|
2647
2634
|
// or an object, then the empty string parsing expression is not nullable.
|
|
@@ -2651,27 +2638,27 @@ pexprs$d.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
|
2651
2638
|
}
|
|
2652
2639
|
};
|
|
2653
2640
|
|
|
2654
|
-
pexprs$
|
|
2641
|
+
pexprs$c.Alt.prototype._isNullable = function(grammar, memo) {
|
|
2655
2642
|
return this.terms.length === 0 || this.terms.some(term => term._isNullable(grammar, memo));
|
|
2656
2643
|
};
|
|
2657
2644
|
|
|
2658
|
-
pexprs$
|
|
2645
|
+
pexprs$c.Seq.prototype._isNullable = function(grammar, memo) {
|
|
2659
2646
|
return this.factors.every(factor => factor._isNullable(grammar, memo));
|
|
2660
2647
|
};
|
|
2661
2648
|
|
|
2662
|
-
pexprs$
|
|
2663
|
-
pexprs$
|
|
2664
|
-
pexprs$
|
|
2665
|
-
pexprs$
|
|
2649
|
+
pexprs$c.Star.prototype._isNullable =
|
|
2650
|
+
pexprs$c.Opt.prototype._isNullable =
|
|
2651
|
+
pexprs$c.Not.prototype._isNullable =
|
|
2652
|
+
pexprs$c.Lookahead.prototype._isNullable =
|
|
2666
2653
|
function(grammar, memo) {
|
|
2667
2654
|
return true;
|
|
2668
2655
|
};
|
|
2669
2656
|
|
|
2670
|
-
pexprs$
|
|
2657
|
+
pexprs$c.Lex.prototype._isNullable = function(grammar, memo) {
|
|
2671
2658
|
return this.expr._isNullable(grammar, memo);
|
|
2672
2659
|
};
|
|
2673
2660
|
|
|
2674
|
-
pexprs$
|
|
2661
|
+
pexprs$c.Apply.prototype._isNullable = function(grammar, memo) {
|
|
2675
2662
|
const key = this.toMemoKey();
|
|
2676
2663
|
if (!Object.prototype.hasOwnProperty.call(memo, key)) {
|
|
2677
2664
|
const {body} = grammar.rules[this.ruleName];
|
|
@@ -2687,7 +2674,7 @@ pexprs$d.Apply.prototype._isNullable = function(grammar, memo) {
|
|
|
2687
2674
|
// --------------------------------------------------------------------
|
|
2688
2675
|
|
|
2689
2676
|
const common$9 = common$l;
|
|
2690
|
-
const pexprs$
|
|
2677
|
+
const pexprs$b = pexprsMain;
|
|
2691
2678
|
|
|
2692
2679
|
// --------------------------------------------------------------------
|
|
2693
2680
|
// Operations
|
|
@@ -2700,44 +2687,44 @@ const pexprs$c = pexprsMain;
|
|
|
2700
2687
|
The receiver must not be modified; a new PExpr must be returned if any replacement is necessary.
|
|
2701
2688
|
*/
|
|
2702
2689
|
// function(actuals) { ... }
|
|
2703
|
-
pexprs$
|
|
2690
|
+
pexprs$b.PExpr.prototype.substituteParams = common$9.abstract('substituteParams');
|
|
2704
2691
|
|
|
2705
|
-
pexprs$
|
|
2706
|
-
pexprs$
|
|
2707
|
-
pexprs$
|
|
2708
|
-
pexprs$
|
|
2709
|
-
pexprs$
|
|
2692
|
+
pexprs$b.any.substituteParams =
|
|
2693
|
+
pexprs$b.end.substituteParams =
|
|
2694
|
+
pexprs$b.Terminal.prototype.substituteParams =
|
|
2695
|
+
pexprs$b.Range.prototype.substituteParams =
|
|
2696
|
+
pexprs$b.UnicodeChar.prototype.substituteParams =
|
|
2710
2697
|
function(actuals) {
|
|
2711
2698
|
return this;
|
|
2712
2699
|
};
|
|
2713
2700
|
|
|
2714
|
-
pexprs$
|
|
2701
|
+
pexprs$b.Param.prototype.substituteParams = function(actuals) {
|
|
2715
2702
|
return actuals[this.index];
|
|
2716
2703
|
};
|
|
2717
2704
|
|
|
2718
|
-
pexprs$
|
|
2719
|
-
return new pexprs$
|
|
2705
|
+
pexprs$b.Alt.prototype.substituteParams = function(actuals) {
|
|
2706
|
+
return new pexprs$b.Alt(this.terms.map(term => term.substituteParams(actuals)));
|
|
2720
2707
|
};
|
|
2721
2708
|
|
|
2722
|
-
pexprs$
|
|
2723
|
-
return new pexprs$
|
|
2709
|
+
pexprs$b.Seq.prototype.substituteParams = function(actuals) {
|
|
2710
|
+
return new pexprs$b.Seq(this.factors.map(factor => factor.substituteParams(actuals)));
|
|
2724
2711
|
};
|
|
2725
2712
|
|
|
2726
|
-
pexprs$
|
|
2727
|
-
pexprs$
|
|
2728
|
-
pexprs$
|
|
2729
|
-
pexprs$
|
|
2713
|
+
pexprs$b.Iter.prototype.substituteParams =
|
|
2714
|
+
pexprs$b.Not.prototype.substituteParams =
|
|
2715
|
+
pexprs$b.Lookahead.prototype.substituteParams =
|
|
2716
|
+
pexprs$b.Lex.prototype.substituteParams =
|
|
2730
2717
|
function(actuals) {
|
|
2731
2718
|
return new this.constructor(this.expr.substituteParams(actuals));
|
|
2732
2719
|
};
|
|
2733
2720
|
|
|
2734
|
-
pexprs$
|
|
2721
|
+
pexprs$b.Apply.prototype.substituteParams = function(actuals) {
|
|
2735
2722
|
if (this.args.length === 0) {
|
|
2736
2723
|
// Avoid making a copy of this application, as an optimization
|
|
2737
2724
|
return this;
|
|
2738
2725
|
} else {
|
|
2739
2726
|
const args = this.args.map(arg => arg.substituteParams(actuals));
|
|
2740
|
-
return new pexprs$
|
|
2727
|
+
return new pexprs$b.Apply(this.ruleName, args);
|
|
2741
2728
|
}
|
|
2742
2729
|
};
|
|
2743
2730
|
|
|
@@ -2746,7 +2733,7 @@ pexprs$c.Apply.prototype.substituteParams = function(actuals) {
|
|
|
2746
2733
|
// --------------------------------------------------------------------
|
|
2747
2734
|
|
|
2748
2735
|
const common$8 = common$l;
|
|
2749
|
-
const pexprs$
|
|
2736
|
+
const pexprs$a = pexprsMain;
|
|
2750
2737
|
|
|
2751
2738
|
const {copyWithoutDuplicates} = common$8;
|
|
2752
2739
|
|
|
@@ -2812,17 +2799,17 @@ function resolveDuplicatedNames(argumentNameList) {
|
|
|
2812
2799
|
* e.getArity() === e.toArgumentNameList(1).length
|
|
2813
2800
|
*/
|
|
2814
2801
|
// function(firstArgIndex, noDupCheck) { ... }
|
|
2815
|
-
pexprs$
|
|
2802
|
+
pexprs$a.PExpr.prototype.toArgumentNameList = common$8.abstract('toArgumentNameList');
|
|
2816
2803
|
|
|
2817
|
-
pexprs$
|
|
2804
|
+
pexprs$a.any.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2818
2805
|
return ['any'];
|
|
2819
2806
|
};
|
|
2820
2807
|
|
|
2821
|
-
pexprs$
|
|
2808
|
+
pexprs$a.end.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2822
2809
|
return ['end'];
|
|
2823
2810
|
};
|
|
2824
2811
|
|
|
2825
|
-
pexprs$
|
|
2812
|
+
pexprs$a.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2826
2813
|
if (typeof this.obj === 'string' && /^[_a-zA-Z0-9]+$/.test(this.obj)) {
|
|
2827
2814
|
// If this terminal is a valid suffix for a JS identifier, just prepend it with '_'
|
|
2828
2815
|
return ['_' + this.obj];
|
|
@@ -2832,7 +2819,7 @@ pexprs$b.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCh
|
|
|
2832
2819
|
}
|
|
2833
2820
|
};
|
|
2834
2821
|
|
|
2835
|
-
pexprs$
|
|
2822
|
+
pexprs$a.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2836
2823
|
let argName = this.from + '_to_' + this.to;
|
|
2837
2824
|
// If the `argName` is not valid then try to prepend a `_`.
|
|
2838
2825
|
if (!isRestrictedJSIdentifier(argName)) {
|
|
@@ -2845,7 +2832,7 @@ pexprs$b.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2845
2832
|
return [argName];
|
|
2846
2833
|
};
|
|
2847
2834
|
|
|
2848
|
-
pexprs$
|
|
2835
|
+
pexprs$a.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2849
2836
|
// `termArgNameLists` is an array of arrays where each row is the
|
|
2850
2837
|
// argument name list that corresponds to a term in this alternation.
|
|
2851
2838
|
const termArgNameLists = this.terms.map(term =>
|
|
@@ -2869,7 +2856,7 @@ pexprs$b.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2869
2856
|
return argumentNameList;
|
|
2870
2857
|
};
|
|
2871
2858
|
|
|
2872
|
-
pexprs$
|
|
2859
|
+
pexprs$a.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2873
2860
|
// Generate the argument name list, without worrying about duplicates.
|
|
2874
2861
|
let argumentNameList = [];
|
|
2875
2862
|
this.factors.forEach(factor => {
|
|
@@ -2885,7 +2872,7 @@ pexprs$b.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2885
2872
|
return argumentNameList;
|
|
2886
2873
|
};
|
|
2887
2874
|
|
|
2888
|
-
pexprs$
|
|
2875
|
+
pexprs$a.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2889
2876
|
const argumentNameList = this.expr
|
|
2890
2877
|
.toArgumentNameList(firstArgIndex, noDupCheck)
|
|
2891
2878
|
.map(exprArgumentString =>
|
|
@@ -2899,30 +2886,30 @@ pexprs$b.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2899
2886
|
return argumentNameList;
|
|
2900
2887
|
};
|
|
2901
2888
|
|
|
2902
|
-
pexprs$
|
|
2889
|
+
pexprs$a.Opt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2903
2890
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck).map(argName => {
|
|
2904
2891
|
return 'opt' + argName[0].toUpperCase() + argName.slice(1);
|
|
2905
2892
|
});
|
|
2906
2893
|
};
|
|
2907
2894
|
|
|
2908
|
-
pexprs$
|
|
2895
|
+
pexprs$a.Not.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2909
2896
|
return [];
|
|
2910
2897
|
};
|
|
2911
2898
|
|
|
2912
|
-
pexprs$
|
|
2899
|
+
pexprs$a.Lookahead.prototype.toArgumentNameList = pexprs$a.Lex.prototype.toArgumentNameList =
|
|
2913
2900
|
function(firstArgIndex, noDupCheck) {
|
|
2914
2901
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck);
|
|
2915
2902
|
};
|
|
2916
2903
|
|
|
2917
|
-
pexprs$
|
|
2904
|
+
pexprs$a.Apply.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2918
2905
|
return [this.ruleName];
|
|
2919
2906
|
};
|
|
2920
2907
|
|
|
2921
|
-
pexprs$
|
|
2908
|
+
pexprs$a.UnicodeChar.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2922
2909
|
return ['$' + firstArgIndex];
|
|
2923
2910
|
};
|
|
2924
2911
|
|
|
2925
|
-
pexprs$
|
|
2912
|
+
pexprs$a.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2926
2913
|
return ['param' + this.index];
|
|
2927
2914
|
};
|
|
2928
2915
|
|
|
@@ -2931,36 +2918,36 @@ pexprs$b.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2931
2918
|
// --------------------------------------------------------------------
|
|
2932
2919
|
|
|
2933
2920
|
const common$7 = common$l;
|
|
2934
|
-
const pexprs$
|
|
2921
|
+
const pexprs$9 = pexprsMain;
|
|
2935
2922
|
|
|
2936
2923
|
// --------------------------------------------------------------------
|
|
2937
2924
|
// Operations
|
|
2938
2925
|
// --------------------------------------------------------------------
|
|
2939
2926
|
|
|
2940
2927
|
// Returns a string representing the PExpr, for use as a UI label, etc.
|
|
2941
|
-
pexprs$
|
|
2928
|
+
pexprs$9.PExpr.prototype.toDisplayString = common$7.abstract('toDisplayString');
|
|
2942
2929
|
|
|
2943
|
-
pexprs$
|
|
2930
|
+
pexprs$9.Alt.prototype.toDisplayString = pexprs$9.Seq.prototype.toDisplayString = function() {
|
|
2944
2931
|
if (this.source) {
|
|
2945
2932
|
return this.source.trimmed().contents;
|
|
2946
2933
|
}
|
|
2947
2934
|
return '[' + this.constructor.name + ']';
|
|
2948
2935
|
};
|
|
2949
2936
|
|
|
2950
|
-
pexprs$
|
|
2951
|
-
pexprs$
|
|
2952
|
-
pexprs$
|
|
2953
|
-
pexprs$
|
|
2954
|
-
pexprs$
|
|
2955
|
-
pexprs$
|
|
2956
|
-
pexprs$
|
|
2957
|
-
pexprs$
|
|
2958
|
-
pexprs$
|
|
2937
|
+
pexprs$9.any.toDisplayString =
|
|
2938
|
+
pexprs$9.end.toDisplayString =
|
|
2939
|
+
pexprs$9.Iter.prototype.toDisplayString =
|
|
2940
|
+
pexprs$9.Not.prototype.toDisplayString =
|
|
2941
|
+
pexprs$9.Lookahead.prototype.toDisplayString =
|
|
2942
|
+
pexprs$9.Lex.prototype.toDisplayString =
|
|
2943
|
+
pexprs$9.Terminal.prototype.toDisplayString =
|
|
2944
|
+
pexprs$9.Range.prototype.toDisplayString =
|
|
2945
|
+
pexprs$9.Param.prototype.toDisplayString =
|
|
2959
2946
|
function() {
|
|
2960
2947
|
return this.toString();
|
|
2961
2948
|
};
|
|
2962
2949
|
|
|
2963
|
-
pexprs$
|
|
2950
|
+
pexprs$9.Apply.prototype.toDisplayString = function() {
|
|
2964
2951
|
if (this.args.length > 0) {
|
|
2965
2952
|
const ps = this.args.map(arg => arg.toDisplayString());
|
|
2966
2953
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -2969,7 +2956,7 @@ pexprs$a.Apply.prototype.toDisplayString = function() {
|
|
|
2969
2956
|
}
|
|
2970
2957
|
};
|
|
2971
2958
|
|
|
2972
|
-
pexprs$
|
|
2959
|
+
pexprs$9.UnicodeChar.prototype.toDisplayString = function() {
|
|
2973
2960
|
return 'Unicode [' + this.category + '] character';
|
|
2974
2961
|
};
|
|
2975
2962
|
|
|
@@ -2979,42 +2966,42 @@ pexprs$a.UnicodeChar.prototype.toDisplayString = function() {
|
|
|
2979
2966
|
|
|
2980
2967
|
const Failure$1 = Failure_1;
|
|
2981
2968
|
const common$6 = common$l;
|
|
2982
|
-
const pexprs$
|
|
2969
|
+
const pexprs$8 = pexprsMain;
|
|
2983
2970
|
|
|
2984
2971
|
// --------------------------------------------------------------------
|
|
2985
2972
|
// Operations
|
|
2986
2973
|
// --------------------------------------------------------------------
|
|
2987
2974
|
|
|
2988
|
-
pexprs$
|
|
2975
|
+
pexprs$8.PExpr.prototype.toFailure = common$6.abstract('toFailure');
|
|
2989
2976
|
|
|
2990
|
-
pexprs$
|
|
2977
|
+
pexprs$8.any.toFailure = function(grammar) {
|
|
2991
2978
|
return new Failure$1(this, 'any object', 'description');
|
|
2992
2979
|
};
|
|
2993
2980
|
|
|
2994
|
-
pexprs$
|
|
2981
|
+
pexprs$8.end.toFailure = function(grammar) {
|
|
2995
2982
|
return new Failure$1(this, 'end of input', 'description');
|
|
2996
2983
|
};
|
|
2997
2984
|
|
|
2998
|
-
pexprs$
|
|
2985
|
+
pexprs$8.Terminal.prototype.toFailure = function(grammar) {
|
|
2999
2986
|
return new Failure$1(this, this.obj, 'string');
|
|
3000
2987
|
};
|
|
3001
2988
|
|
|
3002
|
-
pexprs$
|
|
2989
|
+
pexprs$8.Range.prototype.toFailure = function(grammar) {
|
|
3003
2990
|
// TODO: come up with something better
|
|
3004
2991
|
return new Failure$1(this, JSON.stringify(this.from) + '..' + JSON.stringify(this.to), 'code');
|
|
3005
2992
|
};
|
|
3006
2993
|
|
|
3007
|
-
pexprs$
|
|
2994
|
+
pexprs$8.Not.prototype.toFailure = function(grammar) {
|
|
3008
2995
|
const description =
|
|
3009
|
-
this.expr === pexprs$
|
|
2996
|
+
this.expr === pexprs$8.any ? 'nothing' : 'not ' + this.expr.toFailure(grammar);
|
|
3010
2997
|
return new Failure$1(this, description, 'description');
|
|
3011
2998
|
};
|
|
3012
2999
|
|
|
3013
|
-
pexprs$
|
|
3000
|
+
pexprs$8.Lookahead.prototype.toFailure = function(grammar) {
|
|
3014
3001
|
return this.expr.toFailure(grammar);
|
|
3015
3002
|
};
|
|
3016
3003
|
|
|
3017
|
-
pexprs$
|
|
3004
|
+
pexprs$8.Apply.prototype.toFailure = function(grammar) {
|
|
3018
3005
|
let {description} = grammar.rules[this.ruleName];
|
|
3019
3006
|
if (!description) {
|
|
3020
3007
|
const article = /^[aeiouAEIOU]/.test(this.ruleName) ? 'an' : 'a';
|
|
@@ -3023,23 +3010,23 @@ pexprs$9.Apply.prototype.toFailure = function(grammar) {
|
|
|
3023
3010
|
return new Failure$1(this, description, 'description');
|
|
3024
3011
|
};
|
|
3025
3012
|
|
|
3026
|
-
pexprs$
|
|
3013
|
+
pexprs$8.UnicodeChar.prototype.toFailure = function(grammar) {
|
|
3027
3014
|
return new Failure$1(this, 'a Unicode [' + this.category + '] character', 'description');
|
|
3028
3015
|
};
|
|
3029
3016
|
|
|
3030
|
-
pexprs$
|
|
3017
|
+
pexprs$8.Alt.prototype.toFailure = function(grammar) {
|
|
3031
3018
|
const fs = this.terms.map(t => t.toFailure(grammar));
|
|
3032
3019
|
const description = '(' + fs.join(' or ') + ')';
|
|
3033
3020
|
return new Failure$1(this, description, 'description');
|
|
3034
3021
|
};
|
|
3035
3022
|
|
|
3036
|
-
pexprs$
|
|
3023
|
+
pexprs$8.Seq.prototype.toFailure = function(grammar) {
|
|
3037
3024
|
const fs = this.factors.map(f => f.toFailure(grammar));
|
|
3038
3025
|
const description = '(' + fs.join(' ') + ')';
|
|
3039
3026
|
return new Failure$1(this, description, 'description');
|
|
3040
3027
|
};
|
|
3041
3028
|
|
|
3042
|
-
pexprs$
|
|
3029
|
+
pexprs$8.Iter.prototype.toFailure = function(grammar) {
|
|
3043
3030
|
const description = '(' + this.expr.toFailure(grammar) + this.operator + ')';
|
|
3044
3031
|
return new Failure$1(this, description, 'description');
|
|
3045
3032
|
};
|
|
@@ -3049,7 +3036,7 @@ pexprs$9.Iter.prototype.toFailure = function(grammar) {
|
|
|
3049
3036
|
// --------------------------------------------------------------------
|
|
3050
3037
|
|
|
3051
3038
|
const common$5 = common$l;
|
|
3052
|
-
const pexprs$
|
|
3039
|
+
const pexprs$7 = pexprsMain;
|
|
3053
3040
|
|
|
3054
3041
|
// --------------------------------------------------------------------
|
|
3055
3042
|
// Operations
|
|
@@ -3062,57 +3049,57 @@ const pexprs$8 = pexprsMain;
|
|
|
3062
3049
|
~"b" "a" and "a" are interchangeable in any grammar,
|
|
3063
3050
|
both in terms of the languages they accept and their arities.
|
|
3064
3051
|
*/
|
|
3065
|
-
pexprs$
|
|
3052
|
+
pexprs$7.PExpr.prototype.toString = common$5.abstract('toString');
|
|
3066
3053
|
|
|
3067
|
-
pexprs$
|
|
3054
|
+
pexprs$7.any.toString = function() {
|
|
3068
3055
|
return 'any';
|
|
3069
3056
|
};
|
|
3070
3057
|
|
|
3071
|
-
pexprs$
|
|
3058
|
+
pexprs$7.end.toString = function() {
|
|
3072
3059
|
return 'end';
|
|
3073
3060
|
};
|
|
3074
3061
|
|
|
3075
|
-
pexprs$
|
|
3062
|
+
pexprs$7.Terminal.prototype.toString = function() {
|
|
3076
3063
|
return JSON.stringify(this.obj);
|
|
3077
3064
|
};
|
|
3078
3065
|
|
|
3079
|
-
pexprs$
|
|
3066
|
+
pexprs$7.Range.prototype.toString = function() {
|
|
3080
3067
|
return JSON.stringify(this.from) + '..' + JSON.stringify(this.to);
|
|
3081
3068
|
};
|
|
3082
3069
|
|
|
3083
|
-
pexprs$
|
|
3070
|
+
pexprs$7.Param.prototype.toString = function() {
|
|
3084
3071
|
return '$' + this.index;
|
|
3085
3072
|
};
|
|
3086
3073
|
|
|
3087
|
-
pexprs$
|
|
3074
|
+
pexprs$7.Lex.prototype.toString = function() {
|
|
3088
3075
|
return '#(' + this.expr.toString() + ')';
|
|
3089
3076
|
};
|
|
3090
3077
|
|
|
3091
|
-
pexprs$
|
|
3078
|
+
pexprs$7.Alt.prototype.toString = function() {
|
|
3092
3079
|
return this.terms.length === 1 ?
|
|
3093
3080
|
this.terms[0].toString() :
|
|
3094
3081
|
'(' + this.terms.map(term => term.toString()).join(' | ') + ')';
|
|
3095
3082
|
};
|
|
3096
3083
|
|
|
3097
|
-
pexprs$
|
|
3084
|
+
pexprs$7.Seq.prototype.toString = function() {
|
|
3098
3085
|
return this.factors.length === 1 ?
|
|
3099
3086
|
this.factors[0].toString() :
|
|
3100
3087
|
'(' + this.factors.map(factor => factor.toString()).join(' ') + ')';
|
|
3101
3088
|
};
|
|
3102
3089
|
|
|
3103
|
-
pexprs$
|
|
3090
|
+
pexprs$7.Iter.prototype.toString = function() {
|
|
3104
3091
|
return this.expr + this.operator;
|
|
3105
3092
|
};
|
|
3106
3093
|
|
|
3107
|
-
pexprs$
|
|
3094
|
+
pexprs$7.Not.prototype.toString = function() {
|
|
3108
3095
|
return '~' + this.expr;
|
|
3109
3096
|
};
|
|
3110
3097
|
|
|
3111
|
-
pexprs$
|
|
3098
|
+
pexprs$7.Lookahead.prototype.toString = function() {
|
|
3112
3099
|
return '&' + this.expr;
|
|
3113
3100
|
};
|
|
3114
3101
|
|
|
3115
|
-
pexprs$
|
|
3102
|
+
pexprs$7.Apply.prototype.toString = function() {
|
|
3116
3103
|
if (this.args.length > 0) {
|
|
3117
3104
|
const ps = this.args.map(arg => arg.toString());
|
|
3118
3105
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -3121,7 +3108,7 @@ pexprs$8.Apply.prototype.toString = function() {
|
|
|
3121
3108
|
}
|
|
3122
3109
|
};
|
|
3123
3110
|
|
|
3124
|
-
pexprs$
|
|
3111
|
+
pexprs$7.UnicodeChar.prototype.toString = function() {
|
|
3125
3112
|
return '\\p{' + this.category + '}';
|
|
3126
3113
|
};
|
|
3127
3114
|
|
|
@@ -3129,7 +3116,7 @@ pexprs$8.UnicodeChar.prototype.toString = function() {
|
|
|
3129
3116
|
// Re-export classes
|
|
3130
3117
|
// --------------------------------------------------------------------
|
|
3131
3118
|
|
|
3132
|
-
var pexprs$
|
|
3119
|
+
var pexprs$6 = pexprsMain;
|
|
3133
3120
|
|
|
3134
3121
|
// --------------------------------------------------------------------
|
|
3135
3122
|
// Imports
|
|
@@ -3138,7 +3125,7 @@ var pexprs$7 = pexprsMain;
|
|
|
3138
3125
|
const Failure = Failure_1;
|
|
3139
3126
|
const {TerminalNode} = nodes$1;
|
|
3140
3127
|
const {assert: assert$1} = common$l;
|
|
3141
|
-
const {PExpr, Terminal} = pexprs$
|
|
3128
|
+
const {PExpr, Terminal} = pexprs$6;
|
|
3142
3129
|
|
|
3143
3130
|
class CaseInsensitiveTerminal$1 extends PExpr {
|
|
3144
3131
|
constructor(param) {
|
|
@@ -3166,7 +3153,7 @@ class CaseInsensitiveTerminal$1 extends PExpr {
|
|
|
3166
3153
|
state.processFailure(origPos, this);
|
|
3167
3154
|
return false;
|
|
3168
3155
|
} else {
|
|
3169
|
-
state.pushBinding(new TerminalNode(
|
|
3156
|
+
state.pushBinding(new TerminalNode(matchStr.length), origPos);
|
|
3170
3157
|
return true;
|
|
3171
3158
|
}
|
|
3172
3159
|
}
|
|
@@ -3298,7 +3285,7 @@ const Interval = Interval_1;
|
|
|
3298
3285
|
// Private stuff
|
|
3299
3286
|
// --------------------------------------------------------------------
|
|
3300
3287
|
|
|
3301
|
-
function MatchResult$
|
|
3288
|
+
function MatchResult$2(
|
|
3302
3289
|
matcher,
|
|
3303
3290
|
input,
|
|
3304
3291
|
startExpr,
|
|
@@ -3332,19 +3319,19 @@ function MatchResult$3(
|
|
|
3332
3319
|
}
|
|
3333
3320
|
}
|
|
3334
3321
|
|
|
3335
|
-
MatchResult$
|
|
3322
|
+
MatchResult$2.prototype.succeeded = function() {
|
|
3336
3323
|
return !!this._cst;
|
|
3337
3324
|
};
|
|
3338
3325
|
|
|
3339
|
-
MatchResult$
|
|
3326
|
+
MatchResult$2.prototype.failed = function() {
|
|
3340
3327
|
return !this.succeeded();
|
|
3341
3328
|
};
|
|
3342
3329
|
|
|
3343
|
-
MatchResult$
|
|
3330
|
+
MatchResult$2.prototype.getRightmostFailurePosition = function() {
|
|
3344
3331
|
return this._rightmostFailurePosition;
|
|
3345
3332
|
};
|
|
3346
3333
|
|
|
3347
|
-
MatchResult$
|
|
3334
|
+
MatchResult$2.prototype.getRightmostFailures = function() {
|
|
3348
3335
|
if (!this._rightmostFailures) {
|
|
3349
3336
|
this.matcher.setInput(this.input);
|
|
3350
3337
|
const matchResultWithFailures = this.matcher._match(
|
|
@@ -3357,7 +3344,7 @@ MatchResult$3.prototype.getRightmostFailures = function() {
|
|
|
3357
3344
|
return this._rightmostFailures;
|
|
3358
3345
|
};
|
|
3359
3346
|
|
|
3360
|
-
MatchResult$
|
|
3347
|
+
MatchResult$2.prototype.toString = function() {
|
|
3361
3348
|
return this.succeeded() ?
|
|
3362
3349
|
'[match succeeded]' :
|
|
3363
3350
|
'[match failed at position ' + this.getRightmostFailurePosition() + ']';
|
|
@@ -3365,7 +3352,7 @@ MatchResult$3.prototype.toString = function() {
|
|
|
3365
3352
|
|
|
3366
3353
|
// Return a string summarizing the expected contents of the input stream when
|
|
3367
3354
|
// the match failure occurred.
|
|
3368
|
-
MatchResult$
|
|
3355
|
+
MatchResult$2.prototype.getExpectedText = function() {
|
|
3369
3356
|
if (this.succeeded()) {
|
|
3370
3357
|
throw new Error('cannot get expected text of a successful MatchResult');
|
|
3371
3358
|
}
|
|
@@ -3389,7 +3376,7 @@ MatchResult$3.prototype.getExpectedText = function() {
|
|
|
3389
3376
|
return sb.contents();
|
|
3390
3377
|
};
|
|
3391
3378
|
|
|
3392
|
-
MatchResult$
|
|
3379
|
+
MatchResult$2.prototype.getInterval = function() {
|
|
3393
3380
|
const pos = this.getRightmostFailurePosition();
|
|
3394
3381
|
return new Interval(this.input, pos, pos);
|
|
3395
3382
|
};
|
|
@@ -3398,7 +3385,7 @@ MatchResult$3.prototype.getInterval = function() {
|
|
|
3398
3385
|
// Exports
|
|
3399
3386
|
// --------------------------------------------------------------------
|
|
3400
3387
|
|
|
3401
|
-
var MatchResult_1 = MatchResult$
|
|
3388
|
+
var MatchResult_1 = MatchResult$2;
|
|
3402
3389
|
|
|
3403
3390
|
// --------------------------------------------------------------------
|
|
3404
3391
|
// Private stuff
|
|
@@ -3518,10 +3505,10 @@ var PosInfo_1 = PosInfo$1;
|
|
|
3518
3505
|
// --------------------------------------------------------------------
|
|
3519
3506
|
|
|
3520
3507
|
const InputStream$2 = InputStream_1;
|
|
3521
|
-
const MatchResult$
|
|
3508
|
+
const MatchResult$1 = MatchResult_1;
|
|
3522
3509
|
const PosInfo = PosInfo_1;
|
|
3523
3510
|
const Trace = Trace_1;
|
|
3524
|
-
const pexprs$
|
|
3511
|
+
const pexprs$5 = pexprs$6;
|
|
3525
3512
|
const util$3 = util$7;
|
|
3526
3513
|
|
|
3527
3514
|
// --------------------------------------------------------------------
|
|
@@ -3534,7 +3521,7 @@ util$3.awaitBuiltInRules(builtInRules => {
|
|
|
3534
3521
|
builtInApplySyntacticBody = builtInRules.rules.applySyntactic.body;
|
|
3535
3522
|
});
|
|
3536
3523
|
|
|
3537
|
-
const applySpaces = new pexprs$
|
|
3524
|
+
const applySpaces = new pexprs$5.Apply('spaces');
|
|
3538
3525
|
|
|
3539
3526
|
function MatchState$1(matcher, startExpr, optPositionToRecordFailures) {
|
|
3540
3527
|
this.matcher = matcher;
|
|
@@ -3727,7 +3714,7 @@ MatchState$1.prototype = {
|
|
|
3727
3714
|
// Returns the memoized trace entry for `expr` at `pos`, if one exists, `null` otherwise.
|
|
3728
3715
|
getMemoizedTraceEntry(pos, expr) {
|
|
3729
3716
|
const posInfo = this.memoTable[pos];
|
|
3730
|
-
if (posInfo && expr.
|
|
3717
|
+
if (posInfo && expr instanceof pexprs$5.Apply) {
|
|
3731
3718
|
const memoRec = posInfo.memo[expr.toMemoKey()];
|
|
3732
3719
|
if (memoRec && memoRec.traceEntry) {
|
|
3733
3720
|
const entry = memoRec.traceEntry.cloneWithExpr(expr);
|
|
@@ -3740,7 +3727,7 @@ MatchState$1.prototype = {
|
|
|
3740
3727
|
|
|
3741
3728
|
// Returns a new trace entry, with the currently active trace array as its children.
|
|
3742
3729
|
getTraceEntry(pos, expr, succeeded, bindings) {
|
|
3743
|
-
if (expr instanceof pexprs$
|
|
3730
|
+
if (expr instanceof pexprs$5.Apply) {
|
|
3744
3731
|
const app = this.currentApplication();
|
|
3745
3732
|
const actuals = app ? app.args : [];
|
|
3746
3733
|
expr = expr.substituteParams(actuals);
|
|
@@ -3869,11 +3856,15 @@ MatchState$1.prototype = {
|
|
|
3869
3856
|
key => this.recordedFailures[key]
|
|
3870
3857
|
);
|
|
3871
3858
|
}
|
|
3872
|
-
|
|
3859
|
+
const cst = this._bindings[0];
|
|
3860
|
+
if (cst) {
|
|
3861
|
+
cst.grammar = this.grammar;
|
|
3862
|
+
}
|
|
3863
|
+
return new MatchResult$1(
|
|
3873
3864
|
this.matcher,
|
|
3874
3865
|
this.input,
|
|
3875
3866
|
this.startExpr,
|
|
3876
|
-
|
|
3867
|
+
cst,
|
|
3877
3868
|
this._bindingOffsets[0],
|
|
3878
3869
|
this.rightmostFailurePosition,
|
|
3879
3870
|
rightmostFailures
|
|
@@ -3916,7 +3907,7 @@ var MatchState_1 = MatchState$1;
|
|
|
3916
3907
|
|
|
3917
3908
|
const MatchState = MatchState_1;
|
|
3918
3909
|
|
|
3919
|
-
const pexprs$
|
|
3910
|
+
const pexprs$4 = pexprs$6;
|
|
3920
3911
|
|
|
3921
3912
|
// --------------------------------------------------------------------
|
|
3922
3913
|
// Private stuff
|
|
@@ -4000,7 +3991,7 @@ Matcher$1.prototype._getStartExpr = function(optStartApplicationStr) {
|
|
|
4000
3991
|
}
|
|
4001
3992
|
|
|
4002
3993
|
const startApp = this.grammar.parseApplication(applicationStr);
|
|
4003
|
-
return new pexprs$
|
|
3994
|
+
return new pexprs$4.Seq([startApp, pexprs$4.end]);
|
|
4004
3995
|
};
|
|
4005
3996
|
|
|
4006
3997
|
// --------------------------------------------------------------------
|
|
@@ -4015,7 +4006,7 @@ var Matcher_1 = Matcher$1;
|
|
|
4015
4006
|
|
|
4016
4007
|
const InputStream$1 = InputStream_1;
|
|
4017
4008
|
const {IterationNode} = nodes$1;
|
|
4018
|
-
const MatchResult
|
|
4009
|
+
const MatchResult = MatchResult_1;
|
|
4019
4010
|
const common$3 = common$l;
|
|
4020
4011
|
const errors$3 = errors$9;
|
|
4021
4012
|
const util$2 = util$7;
|
|
@@ -4056,11 +4047,6 @@ class Wrapper {
|
|
|
4056
4047
|
return '[semantics wrapper for ' + this._node.grammar.name + ']';
|
|
4057
4048
|
}
|
|
4058
4049
|
|
|
4059
|
-
// This is used by ohm editor to display a node wrapper appropriately.
|
|
4060
|
-
toJSON() {
|
|
4061
|
-
return this.toString();
|
|
4062
|
-
}
|
|
4063
|
-
|
|
4064
4050
|
_forgetMemoizedResultFor(attributeName) {
|
|
4065
4051
|
// Remove the memoized attribute from the cstNode and all its children.
|
|
4066
4052
|
delete this._node[this._semantics.attributeKeys[attributeName]];
|
|
@@ -4140,7 +4126,7 @@ class Wrapper {
|
|
|
4140
4126
|
const childWrappers = optChildWrappers || [];
|
|
4141
4127
|
|
|
4142
4128
|
const childNodes = childWrappers.map(c => c._node);
|
|
4143
|
-
const iter = new IterationNode(
|
|
4129
|
+
const iter = new IterationNode(childNodes, [], -1, false);
|
|
4144
4130
|
|
|
4145
4131
|
const wrapper = this._semantics.wrap(iter, null, null);
|
|
4146
4132
|
wrapper._childWrappers = childWrappers;
|
|
@@ -4167,18 +4153,6 @@ class Wrapper {
|
|
|
4167
4153
|
return this._node.numChildren();
|
|
4168
4154
|
}
|
|
4169
4155
|
|
|
4170
|
-
// Returns the primitive value of this CST node, if it's a terminal node. Otherwise,
|
|
4171
|
-
// throws an exception.
|
|
4172
|
-
// DEPRECATED: Use `sourceString` instead.
|
|
4173
|
-
get primitiveValue() {
|
|
4174
|
-
if (this.isTerminal()) {
|
|
4175
|
-
return this._node.primitiveValue;
|
|
4176
|
-
}
|
|
4177
|
-
throw new TypeError(
|
|
4178
|
-
"tried to access the 'primitiveValue' attribute of a non-terminal CST node"
|
|
4179
|
-
);
|
|
4180
|
-
}
|
|
4181
|
-
|
|
4182
4156
|
// Returns the contents of the input stream consumed by this CST node.
|
|
4183
4157
|
get sourceString() {
|
|
4184
4158
|
return this.source.contents;
|
|
@@ -4544,7 +4518,7 @@ Semantics$2.createSemantics = function(grammar, optSuperSemantics) {
|
|
|
4544
4518
|
// To enable clients to invoke a semantics like a function, return a function that acts as a proxy
|
|
4545
4519
|
// for `s`, which is the real `Semantics` instance.
|
|
4546
4520
|
const proxy = function ASemantics(matchResult) {
|
|
4547
|
-
if (!(matchResult instanceof MatchResult
|
|
4521
|
+
if (!(matchResult instanceof MatchResult)) {
|
|
4548
4522
|
throw new TypeError(
|
|
4549
4523
|
'Semantics expected a MatchResult, but got ' +
|
|
4550
4524
|
common$3.unexpectedObjToString(matchResult)
|
|
@@ -4728,7 +4702,7 @@ const Matcher = Matcher_1;
|
|
|
4728
4702
|
const Semantics$1 = Semantics_1;
|
|
4729
4703
|
const common$2 = common$l;
|
|
4730
4704
|
const errors$2 = errors$9;
|
|
4731
|
-
const pexprs$
|
|
4705
|
+
const pexprs$3 = pexprs$6;
|
|
4732
4706
|
|
|
4733
4707
|
// --------------------------------------------------------------------
|
|
4734
4708
|
// Private stuff
|
|
@@ -4749,7 +4723,7 @@ function getSortedRuleValues(grammar) {
|
|
|
4749
4723
|
// See https://v8.dev/features/subsume-json for more details.
|
|
4750
4724
|
const jsonToJS = str => str.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
4751
4725
|
|
|
4752
|
-
function Grammar$
|
|
4726
|
+
function Grammar$4(name, superGrammar, rules, optDefaultStartRule) {
|
|
4753
4727
|
this.name = name;
|
|
4754
4728
|
this.superGrammar = superGrammar;
|
|
4755
4729
|
this.rules = rules;
|
|
@@ -4771,12 +4745,12 @@ let ohmGrammar$2;
|
|
|
4771
4745
|
let buildGrammar$1;
|
|
4772
4746
|
|
|
4773
4747
|
// This method is called from main.js once Ohm has loaded.
|
|
4774
|
-
Grammar$
|
|
4748
|
+
Grammar$4.initApplicationParser = function(grammar, builderFn) {
|
|
4775
4749
|
ohmGrammar$2 = grammar;
|
|
4776
4750
|
buildGrammar$1 = builderFn;
|
|
4777
4751
|
};
|
|
4778
4752
|
|
|
4779
|
-
Grammar$
|
|
4753
|
+
Grammar$4.prototype = {
|
|
4780
4754
|
matcher() {
|
|
4781
4755
|
return new Matcher(this);
|
|
4782
4756
|
},
|
|
@@ -4784,7 +4758,7 @@ Grammar$5.prototype = {
|
|
|
4784
4758
|
// Return true if the grammar is a built-in grammar, otherwise false.
|
|
4785
4759
|
// NOTE: This might give an unexpected result if called before BuiltInRules is defined!
|
|
4786
4760
|
isBuiltIn() {
|
|
4787
|
-
return this === Grammar$
|
|
4761
|
+
return this === Grammar$4.ProtoBuiltInRules || this === Grammar$4.BuiltInRules;
|
|
4788
4762
|
},
|
|
4789
4763
|
|
|
4790
4764
|
equals(g) {
|
|
@@ -4923,7 +4897,7 @@ Grammar$5.prototype = {
|
|
|
4923
4897
|
if (isDefinition) {
|
|
4924
4898
|
operation = 'define';
|
|
4925
4899
|
} else {
|
|
4926
|
-
operation = body instanceof pexprs$
|
|
4900
|
+
operation = body instanceof pexprs$3.Extend ? 'extend' : 'override';
|
|
4927
4901
|
}
|
|
4928
4902
|
|
|
4929
4903
|
const metaInfo = {};
|
|
@@ -5010,7 +4984,7 @@ Grammar$5.prototype = {
|
|
|
5010
4984
|
let app;
|
|
5011
4985
|
if (str.indexOf('<') === -1) {
|
|
5012
4986
|
// simple application
|
|
5013
|
-
app = new pexprs$
|
|
4987
|
+
app = new pexprs$3.Apply(str);
|
|
5014
4988
|
} else {
|
|
5015
4989
|
// parameterized application
|
|
5016
4990
|
const cst = ohmGrammar$2.match(str, 'Base_application');
|
|
@@ -5040,43 +5014,43 @@ Grammar$5.prototype = {
|
|
|
5040
5014
|
// `BuiltInRules`. That grammar contains several convenience rules, e.g., `letter` and
|
|
5041
5015
|
// `digit`, and is implicitly the super-grammar of any grammar whose super-grammar
|
|
5042
5016
|
// isn't specified.
|
|
5043
|
-
Grammar$
|
|
5017
|
+
Grammar$4.ProtoBuiltInRules = new Grammar$4(
|
|
5044
5018
|
'ProtoBuiltInRules', // name
|
|
5045
5019
|
undefined, // supergrammar
|
|
5046
5020
|
{
|
|
5047
5021
|
any: {
|
|
5048
|
-
body: pexprs$
|
|
5022
|
+
body: pexprs$3.any,
|
|
5049
5023
|
formals: [],
|
|
5050
5024
|
description: 'any character',
|
|
5051
5025
|
primitive: true,
|
|
5052
5026
|
},
|
|
5053
5027
|
end: {
|
|
5054
|
-
body: pexprs$
|
|
5028
|
+
body: pexprs$3.end,
|
|
5055
5029
|
formals: [],
|
|
5056
5030
|
description: 'end of input',
|
|
5057
5031
|
primitive: true,
|
|
5058
5032
|
},
|
|
5059
5033
|
|
|
5060
5034
|
caseInsensitive: {
|
|
5061
|
-
body: new CaseInsensitiveTerminal(new pexprs$
|
|
5035
|
+
body: new CaseInsensitiveTerminal(new pexprs$3.Param(0)),
|
|
5062
5036
|
formals: ['str'],
|
|
5063
5037
|
primitive: true,
|
|
5064
5038
|
},
|
|
5065
5039
|
lower: {
|
|
5066
|
-
body: new pexprs$
|
|
5040
|
+
body: new pexprs$3.UnicodeChar('Ll'),
|
|
5067
5041
|
formals: [],
|
|
5068
5042
|
description: 'a lowercase letter',
|
|
5069
5043
|
primitive: true,
|
|
5070
5044
|
},
|
|
5071
5045
|
upper: {
|
|
5072
|
-
body: new pexprs$
|
|
5046
|
+
body: new pexprs$3.UnicodeChar('Lu'),
|
|
5073
5047
|
formals: [],
|
|
5074
5048
|
description: 'an uppercase letter',
|
|
5075
5049
|
primitive: true,
|
|
5076
5050
|
},
|
|
5077
5051
|
// Union of Lt (titlecase), Lm (modifier), and Lo (other), i.e. any letter not in Ll or Lu.
|
|
5078
5052
|
unicodeLtmo: {
|
|
5079
|
-
body: new pexprs$
|
|
5053
|
+
body: new pexprs$3.UnicodeChar('Ltmo'),
|
|
5080
5054
|
formals: [],
|
|
5081
5055
|
description: 'a Unicode character in Lt, Lm, or Lo',
|
|
5082
5056
|
primitive: true,
|
|
@@ -5085,11 +5059,11 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5085
5059
|
// These rules are not truly primitive (they could be written in userland) but are defined
|
|
5086
5060
|
// here for bootstrapping purposes.
|
|
5087
5061
|
spaces: {
|
|
5088
|
-
body: new pexprs$
|
|
5062
|
+
body: new pexprs$3.Star(new pexprs$3.Apply('space')),
|
|
5089
5063
|
formals: [],
|
|
5090
5064
|
},
|
|
5091
5065
|
space: {
|
|
5092
|
-
body: new pexprs$
|
|
5066
|
+
body: new pexprs$3.Range('\x00', ' '),
|
|
5093
5067
|
formals: [],
|
|
5094
5068
|
description: 'a space',
|
|
5095
5069
|
},
|
|
@@ -5100,17 +5074,17 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5100
5074
|
// Exports
|
|
5101
5075
|
// --------------------------------------------------------------------
|
|
5102
5076
|
|
|
5103
|
-
var Grammar_1 = Grammar$
|
|
5077
|
+
var Grammar_1 = Grammar$4;
|
|
5104
5078
|
|
|
5105
5079
|
// --------------------------------------------------------------------
|
|
5106
5080
|
// Imports
|
|
5107
5081
|
// --------------------------------------------------------------------
|
|
5108
5082
|
|
|
5109
|
-
const Grammar$
|
|
5083
|
+
const Grammar$3 = Grammar_1;
|
|
5110
5084
|
const InputStream = InputStream_1;
|
|
5111
5085
|
const common$1 = common$l;
|
|
5112
5086
|
const errors$1 = errors$9;
|
|
5113
|
-
const pexprs$
|
|
5087
|
+
const pexprs$2 = pexprs$6;
|
|
5114
5088
|
|
|
5115
5089
|
// --------------------------------------------------------------------
|
|
5116
5090
|
// Private Stuff
|
|
@@ -5134,7 +5108,7 @@ GrammarDecl$1.prototype.ensureSuperGrammar = function() {
|
|
|
5134
5108
|
// TODO: The conditional expression below is an ugly hack. It's kind of ok because
|
|
5135
5109
|
// I doubt anyone will ever try to declare a grammar called `BuiltInRules`. Still,
|
|
5136
5110
|
// we should try to find a better way to do this.
|
|
5137
|
-
this.name === 'BuiltInRules' ? Grammar$
|
|
5111
|
+
this.name === 'BuiltInRules' ? Grammar$3.ProtoBuiltInRules : Grammar$3.BuiltInRules
|
|
5138
5112
|
);
|
|
5139
5113
|
}
|
|
5140
5114
|
return this.superGrammar;
|
|
@@ -5205,7 +5179,7 @@ GrammarDecl$1.prototype.withSource = function(source) {
|
|
|
5205
5179
|
|
|
5206
5180
|
// Creates a Grammar instance, and if it passes the sanity checks, returns it.
|
|
5207
5181
|
GrammarDecl$1.prototype.build = function() {
|
|
5208
|
-
const grammar = new Grammar$
|
|
5182
|
+
const grammar = new Grammar$3(
|
|
5209
5183
|
this.name,
|
|
5210
5184
|
this.ensureSuperGrammar(),
|
|
5211
5185
|
this.rules,
|
|
@@ -5281,7 +5255,7 @@ GrammarDecl$1.prototype.extend = function(name, formals, fragment, descIgnored,
|
|
|
5281
5255
|
if (!ruleInfo) {
|
|
5282
5256
|
throw errors$1.cannotExtendUndeclaredRule(name, this.superGrammar.name, source);
|
|
5283
5257
|
}
|
|
5284
|
-
const body = new pexprs$
|
|
5258
|
+
const body = new pexprs$2.Extend(this.superGrammar, name, fragment);
|
|
5285
5259
|
body.source = fragment.source;
|
|
5286
5260
|
this.installOverriddenOrExtendedRule(name, formals, body, source);
|
|
5287
5261
|
return this;
|
|
@@ -5297,9 +5271,9 @@ var GrammarDecl_1 = GrammarDecl$1;
|
|
|
5297
5271
|
// Imports
|
|
5298
5272
|
// --------------------------------------------------------------------
|
|
5299
5273
|
|
|
5300
|
-
const Grammar$
|
|
5274
|
+
const Grammar$2 = Grammar_1;
|
|
5301
5275
|
const GrammarDecl = GrammarDecl_1;
|
|
5302
|
-
const pexprs$
|
|
5276
|
+
const pexprs$1 = pexprs$6;
|
|
5303
5277
|
|
|
5304
5278
|
// --------------------------------------------------------------------
|
|
5305
5279
|
// Private stuff
|
|
@@ -5320,7 +5294,7 @@ Builder$2.prototype = {
|
|
|
5320
5294
|
if (superGrammar) {
|
|
5321
5295
|
// `superGrammar` may be a recipe (i.e. an Array), or an actual grammar instance.
|
|
5322
5296
|
gDecl.withSuperGrammar(
|
|
5323
|
-
superGrammar instanceof Grammar$
|
|
5297
|
+
superGrammar instanceof Grammar$2 ? superGrammar : this.fromRecipe(superGrammar)
|
|
5324
5298
|
);
|
|
5325
5299
|
}
|
|
5326
5300
|
if (defaultStartRule) {
|
|
@@ -5355,73 +5329,73 @@ Builder$2.prototype = {
|
|
|
5355
5329
|
},
|
|
5356
5330
|
|
|
5357
5331
|
terminal(x) {
|
|
5358
|
-
return new pexprs$
|
|
5332
|
+
return new pexprs$1.Terminal(x);
|
|
5359
5333
|
},
|
|
5360
5334
|
|
|
5361
5335
|
range(from, to) {
|
|
5362
|
-
return new pexprs$
|
|
5336
|
+
return new pexprs$1.Range(from, to);
|
|
5363
5337
|
},
|
|
5364
5338
|
|
|
5365
5339
|
param(index) {
|
|
5366
|
-
return new pexprs$
|
|
5340
|
+
return new pexprs$1.Param(index);
|
|
5367
5341
|
},
|
|
5368
5342
|
|
|
5369
5343
|
alt(...termArgs) {
|
|
5370
5344
|
let terms = [];
|
|
5371
5345
|
for (let arg of termArgs) {
|
|
5372
|
-
if (!(arg instanceof pexprs$
|
|
5346
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5373
5347
|
arg = this.fromRecipe(arg);
|
|
5374
5348
|
}
|
|
5375
|
-
if (arg instanceof pexprs$
|
|
5349
|
+
if (arg instanceof pexprs$1.Alt) {
|
|
5376
5350
|
terms = terms.concat(arg.terms);
|
|
5377
5351
|
} else {
|
|
5378
5352
|
terms.push(arg);
|
|
5379
5353
|
}
|
|
5380
5354
|
}
|
|
5381
|
-
return terms.length === 1 ? terms[0] : new pexprs$
|
|
5355
|
+
return terms.length === 1 ? terms[0] : new pexprs$1.Alt(terms);
|
|
5382
5356
|
},
|
|
5383
5357
|
|
|
5384
5358
|
seq(...factorArgs) {
|
|
5385
5359
|
let factors = [];
|
|
5386
5360
|
for (let arg of factorArgs) {
|
|
5387
|
-
if (!(arg instanceof pexprs$
|
|
5361
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5388
5362
|
arg = this.fromRecipe(arg);
|
|
5389
5363
|
}
|
|
5390
|
-
if (arg instanceof pexprs$
|
|
5364
|
+
if (arg instanceof pexprs$1.Seq) {
|
|
5391
5365
|
factors = factors.concat(arg.factors);
|
|
5392
5366
|
} else {
|
|
5393
5367
|
factors.push(arg);
|
|
5394
5368
|
}
|
|
5395
5369
|
}
|
|
5396
|
-
return factors.length === 1 ? factors[0] : new pexprs$
|
|
5370
|
+
return factors.length === 1 ? factors[0] : new pexprs$1.Seq(factors);
|
|
5397
5371
|
},
|
|
5398
5372
|
|
|
5399
5373
|
star(expr) {
|
|
5400
|
-
if (!(expr instanceof pexprs$
|
|
5374
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5401
5375
|
expr = this.fromRecipe(expr);
|
|
5402
5376
|
}
|
|
5403
|
-
return new pexprs$
|
|
5377
|
+
return new pexprs$1.Star(expr);
|
|
5404
5378
|
},
|
|
5405
5379
|
|
|
5406
5380
|
plus(expr) {
|
|
5407
|
-
if (!(expr instanceof pexprs$
|
|
5381
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5408
5382
|
expr = this.fromRecipe(expr);
|
|
5409
5383
|
}
|
|
5410
|
-
return new pexprs$
|
|
5384
|
+
return new pexprs$1.Plus(expr);
|
|
5411
5385
|
},
|
|
5412
5386
|
|
|
5413
5387
|
opt(expr) {
|
|
5414
|
-
if (!(expr instanceof pexprs$
|
|
5388
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5415
5389
|
expr = this.fromRecipe(expr);
|
|
5416
5390
|
}
|
|
5417
|
-
return new pexprs$
|
|
5391
|
+
return new pexprs$1.Opt(expr);
|
|
5418
5392
|
},
|
|
5419
5393
|
|
|
5420
5394
|
not(expr) {
|
|
5421
|
-
if (!(expr instanceof pexprs$
|
|
5395
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5422
5396
|
expr = this.fromRecipe(expr);
|
|
5423
5397
|
}
|
|
5424
|
-
return new pexprs$
|
|
5398
|
+
return new pexprs$1.Not(expr);
|
|
5425
5399
|
},
|
|
5426
5400
|
|
|
5427
5401
|
la(expr) {
|
|
@@ -5430,33 +5404,33 @@ Builder$2.prototype = {
|
|
|
5430
5404
|
},
|
|
5431
5405
|
|
|
5432
5406
|
lookahead(expr) {
|
|
5433
|
-
if (!(expr instanceof pexprs$
|
|
5407
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5434
5408
|
expr = this.fromRecipe(expr);
|
|
5435
5409
|
}
|
|
5436
|
-
return new pexprs$
|
|
5410
|
+
return new pexprs$1.Lookahead(expr);
|
|
5437
5411
|
},
|
|
5438
5412
|
|
|
5439
5413
|
lex(expr) {
|
|
5440
|
-
if (!(expr instanceof pexprs$
|
|
5414
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5441
5415
|
expr = this.fromRecipe(expr);
|
|
5442
5416
|
}
|
|
5443
|
-
return new pexprs$
|
|
5417
|
+
return new pexprs$1.Lex(expr);
|
|
5444
5418
|
},
|
|
5445
5419
|
|
|
5446
5420
|
app(ruleName, optParams) {
|
|
5447
5421
|
if (optParams && optParams.length > 0) {
|
|
5448
5422
|
optParams = optParams.map(function(param) {
|
|
5449
|
-
return param instanceof pexprs$
|
|
5423
|
+
return param instanceof pexprs$1.PExpr ? param : this.fromRecipe(param);
|
|
5450
5424
|
}, this);
|
|
5451
5425
|
}
|
|
5452
|
-
return new pexprs$
|
|
5426
|
+
return new pexprs$1.Apply(ruleName, optParams);
|
|
5453
5427
|
},
|
|
5454
5428
|
|
|
5455
5429
|
// Note that unlike other methods in this class, this method cannot be used as a
|
|
5456
5430
|
// convenience constructor. It only works with recipes, because it relies on
|
|
5457
5431
|
// `this.currentDecl` and `this.currentRuleName` being set.
|
|
5458
5432
|
splice(beforeTerms, afterTerms) {
|
|
5459
|
-
return new pexprs$
|
|
5433
|
+
return new pexprs$1.Splice(
|
|
5460
5434
|
this.currentDecl.superGrammar,
|
|
5461
5435
|
this.currentRuleName,
|
|
5462
5436
|
beforeTerms.map(term => this.fromRecipe(term)),
|
|
@@ -5486,7 +5460,7 @@ Builder$2.prototype = {
|
|
|
5486
5460
|
var Builder_1 = Builder$2;
|
|
5487
5461
|
|
|
5488
5462
|
var name = "ohm-js";
|
|
5489
|
-
var version$2 = "16.3.
|
|
5463
|
+
var version$2 = "16.3.3";
|
|
5490
5464
|
var description = "An object-oriented language for parsing and pattern matching";
|
|
5491
5465
|
var repository = "https://github.com/harc/ohm";
|
|
5492
5466
|
var keywords = [
|
|
@@ -5501,7 +5475,7 @@ var keywords = [
|
|
|
5501
5475
|
"rapid",
|
|
5502
5476
|
"prototyping"
|
|
5503
5477
|
];
|
|
5504
|
-
var homepage = "https://
|
|
5478
|
+
var homepage = "https://ohmjs.org";
|
|
5505
5479
|
var bugs = "https://github.com/harc/ohm/issues";
|
|
5506
5480
|
var main = "index.js";
|
|
5507
5481
|
var module = "dist/ohm.esm.js";
|
|
@@ -5542,38 +5516,39 @@ var contributors = [
|
|
|
5542
5516
|
"Tony Garnock-Jones <tonygarnockjones@gmail.com>",
|
|
5543
5517
|
"Saketh Kasibatla <sake.kasi@gmail.com>",
|
|
5544
5518
|
"Lionel Landwerlin <llandwerlin@gmail.com>",
|
|
5545
|
-
"Jason Merrill <jwmerrill@gmail.com>",
|
|
5546
5519
|
"Ray Toal <rtoal@lmu.edu>",
|
|
5520
|
+
"Jason Merrill <jwmerrill@gmail.com>",
|
|
5547
5521
|
"Yoshiki Ohshima <Yoshiki.Ohshima@acm.org>",
|
|
5548
5522
|
"megabuz <3299889+megabuz@users.noreply.github.com>",
|
|
5549
|
-
"stagas <gstagas@gmail.com>",
|
|
5550
|
-
"Jonathan Edwards <JonathanMEdwards@gmail.com>",
|
|
5551
5523
|
"Milan Lajtoš <milan.lajtos@me.com>",
|
|
5552
5524
|
"Neil Jewers <njjewers@uwaterloo.ca>",
|
|
5553
|
-
"
|
|
5554
|
-
"
|
|
5555
|
-
"
|
|
5556
|
-
"Leslie Ying <acetophore@users.noreply.github.com>",
|
|
5525
|
+
"Jonathan Edwards <JonathanMEdwards@gmail.com>",
|
|
5526
|
+
"stagas <gstagas@gmail.com>",
|
|
5527
|
+
"Daniel Tomlinson <DanielTomlinson@me.com>",
|
|
5557
5528
|
"Pierre Donias <pierre.donias@gmail.com>",
|
|
5558
|
-
"
|
|
5559
|
-
"
|
|
5529
|
+
"Casey Olson <casey.m.olson@gmail.com>",
|
|
5530
|
+
"Arthur Carabott <arthurc@gmail.com>",
|
|
5560
5531
|
"Stan Rozenraukh <stan@stanistan.com>",
|
|
5561
5532
|
"Stephan Seidt <stephan.seidt@gmail.com>",
|
|
5562
|
-
"
|
|
5533
|
+
"Leslie Ying <acetophore@users.noreply.github.com>",
|
|
5563
5534
|
"Szymon Kaliski <kaliskiszymon@gmail.com>",
|
|
5564
5535
|
"Thomas Nyberg <tomnyberg@gmail.com>",
|
|
5565
|
-
"
|
|
5536
|
+
"AngryPowman <angrypowman@qq.com>",
|
|
5566
5537
|
"Vse Mozhet Byt <vsemozhetbyt@gmail.com>",
|
|
5567
5538
|
"Wil Chung <10446+iamwilhelm@users.noreply.github.com>",
|
|
5568
|
-
"
|
|
5539
|
+
"Zachary Sakowitz <zsakowitz@gmail.com>",
|
|
5569
5540
|
"abego <ub@abego-software.de>",
|
|
5570
5541
|
"acslk <d_vd415@hotmail.com>",
|
|
5571
5542
|
"codeZeilen <codeZeilen@users.noreply.github.com>",
|
|
5572
5543
|
"kassadin <kassadin@foxmail.com>",
|
|
5573
|
-
"Arthur Carabott <arthurc@gmail.com>",
|
|
5574
5544
|
"owch <bowenrainyday@gmail.com>",
|
|
5545
|
+
"sfinnie <scott.finnie@gmail.com>",
|
|
5546
|
+
"Steve Phillips <steve@tryingtobeawesome.com>",
|
|
5547
|
+
"Justin Chase <justin.m.chase@gmail.com>",
|
|
5575
5548
|
"Luca Guzzon <luca.guzzon@gmail.com>",
|
|
5576
|
-
"
|
|
5549
|
+
"Ian Harris <ian@fofgof.xyz>",
|
|
5550
|
+
"Mike Niebling <(none)>",
|
|
5551
|
+
"Patrick Dubroy <patrick@sourcegraph.com>"
|
|
5577
5552
|
];
|
|
5578
5553
|
var dependencies = {
|
|
5579
5554
|
};
|
|
@@ -5674,13 +5649,13 @@ var builtInRules = makeRecipe$3(["grammar",{"source":"BuiltInRules {\n\n alnum
|
|
|
5674
5649
|
// Imports
|
|
5675
5650
|
// --------------------------------------------------------------------
|
|
5676
5651
|
|
|
5677
|
-
const Grammar$
|
|
5652
|
+
const Grammar$1 = Grammar_1;
|
|
5678
5653
|
|
|
5679
5654
|
// --------------------------------------------------------------------
|
|
5680
5655
|
// Private stuff
|
|
5681
5656
|
// --------------------------------------------------------------------
|
|
5682
5657
|
|
|
5683
|
-
Grammar$
|
|
5658
|
+
Grammar$1.BuiltInRules = builtInRules;
|
|
5684
5659
|
|
|
5685
5660
|
var {makeRecipe: makeRecipe$2} = makeRecipe$5;
|
|
5686
5661
|
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",[]]]]}]);
|
|
@@ -5753,11 +5728,11 @@ var ohmGrammar$1 = makeRecipe$1(["grammar",{"source":"Ohm {\n\n Grammars\n =
|
|
|
5753
5728
|
// --------------------------------------------------------------------
|
|
5754
5729
|
|
|
5755
5730
|
const Builder = Builder_1;
|
|
5756
|
-
const Grammar
|
|
5731
|
+
const Grammar = Grammar_1;
|
|
5757
5732
|
const Namespace = Namespace_1;
|
|
5758
5733
|
const common = common$l;
|
|
5759
5734
|
const errors = errors$9;
|
|
5760
|
-
const pexprs
|
|
5735
|
+
const pexprs = pexprs$6;
|
|
5761
5736
|
const util = util$7;
|
|
5762
5737
|
const version = version$1;
|
|
5763
5738
|
const {makeRecipe} = makeRecipe$5;
|
|
@@ -5770,7 +5745,7 @@ const {makeRecipe} = makeRecipe$5;
|
|
|
5770
5745
|
// bottom of this file because loading the grammar requires Ohm itself.
|
|
5771
5746
|
let ohmGrammar;
|
|
5772
5747
|
|
|
5773
|
-
const superSplicePlaceholder = Object.create(pexprs
|
|
5748
|
+
const superSplicePlaceholder = Object.create(pexprs.PExpr.prototype);
|
|
5774
5749
|
|
|
5775
5750
|
const isBuffer = obj =>
|
|
5776
5751
|
!!obj.constructor &&
|
|
@@ -5825,7 +5800,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5825
5800
|
currentRuleFormals = fs.children.map(c => c.visit())[0] || [];
|
|
5826
5801
|
// If there is no default start rule yet, set it now. This must be done before visiting
|
|
5827
5802
|
// the body, because it might contain an inline rule definition.
|
|
5828
|
-
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar
|
|
5803
|
+
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar.ProtoBuiltInRules) {
|
|
5829
5804
|
decl.withDefaultStartRule(currentRuleName);
|
|
5830
5805
|
}
|
|
5831
5806
|
const body = b.visit();
|
|
@@ -5869,7 +5844,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5869
5844
|
if (t === superSplicePlaceholder) throw errors.multipleSuperSplices(t);
|
|
5870
5845
|
});
|
|
5871
5846
|
|
|
5872
|
-
return new pexprs
|
|
5847
|
+
return new pexprs.Splice(
|
|
5873
5848
|
decl.superGrammar,
|
|
5874
5849
|
currentRuleName,
|
|
5875
5850
|
beforeTerms,
|
|
@@ -6066,7 +6041,7 @@ main$1.exports = {
|
|
|
6066
6041
|
grammarsFromScriptElements,
|
|
6067
6042
|
makeRecipe,
|
|
6068
6043
|
ohmGrammar: null, // Initialized below, after Grammar.BuiltInRules.
|
|
6069
|
-
pexprs
|
|
6044
|
+
pexprs,
|
|
6070
6045
|
util,
|
|
6071
6046
|
version,
|
|
6072
6047
|
};
|
|
@@ -6077,10 +6052,10 @@ main$1.exports._buildGrammar = buildGrammar;
|
|
|
6077
6052
|
// Late initialization for stuff that is bootstrapped.
|
|
6078
6053
|
|
|
6079
6054
|
|
|
6080
|
-
util.announceBuiltInRules(Grammar
|
|
6055
|
+
util.announceBuiltInRules(Grammar.BuiltInRules);
|
|
6081
6056
|
|
|
6082
6057
|
main$1.exports.ohmGrammar = ohmGrammar = ohmGrammar$1;
|
|
6083
|
-
Grammar
|
|
6058
|
+
Grammar.initApplicationParser(ohmGrammar, buildGrammar);
|
|
6084
6059
|
|
|
6085
6060
|
var ohm = main$1.exports;
|
|
6086
6061
|
|
|
@@ -6254,14 +6229,6 @@ VisitorFamily.prototype.addOperation = function(signature, actions) {
|
|
|
6254
6229
|
|
|
6255
6230
|
var VisitorFamily_1 = VisitorFamily;
|
|
6256
6231
|
|
|
6257
|
-
// --------------------------------------------------------------------
|
|
6258
|
-
// Imports
|
|
6259
|
-
// --------------------------------------------------------------------
|
|
6260
|
-
|
|
6261
|
-
const pexprs = pexprs$7;
|
|
6262
|
-
const MatchResult = MatchResult_1;
|
|
6263
|
-
const Grammar = Grammar_1;
|
|
6264
|
-
|
|
6265
6232
|
// --------------------------------------------------------------------
|
|
6266
6233
|
// Operations
|
|
6267
6234
|
// --------------------------------------------------------------------
|
|
@@ -6277,11 +6244,6 @@ const defaultOperation = {
|
|
|
6277
6244
|
|
|
6278
6245
|
// without customization
|
|
6279
6246
|
if (!Object.prototype.hasOwnProperty.call(mapping, ctorName)) {
|
|
6280
|
-
// intermediate node
|
|
6281
|
-
if (this._node instanceof pexprs.Alt || this._node instanceof pexprs.Apply) {
|
|
6282
|
-
return children[0].toAST(mapping);
|
|
6283
|
-
}
|
|
6284
|
-
|
|
6285
6247
|
// lexical rule
|
|
6286
6248
|
if (this.isLexical()) {
|
|
6287
6249
|
return this.sourceString;
|
|
@@ -6365,8 +6327,8 @@ const defaultOperation = {
|
|
|
6365
6327
|
// The optional `mapping` parameter can be used to customize how the nodes of the CST
|
|
6366
6328
|
// are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).
|
|
6367
6329
|
function toAST(res, mapping) {
|
|
6368
|
-
if (
|
|
6369
|
-
throw new Error('toAST() expects a
|
|
6330
|
+
if (typeof res.failed !== 'function' || res.failed()) {
|
|
6331
|
+
throw new Error('toAST() expects a succesful MatchResult as first parameter');
|
|
6370
6332
|
}
|
|
6371
6333
|
|
|
6372
6334
|
mapping = Object.assign({}, mapping);
|
|
@@ -6384,7 +6346,7 @@ function toAST(res, mapping) {
|
|
|
6384
6346
|
|
|
6385
6347
|
// Returns a semantics containg the toAST(mapping) operation for the given grammar g.
|
|
6386
6348
|
function semanticsForToAST(g) {
|
|
6387
|
-
if (
|
|
6349
|
+
if (typeof g.createSemantics !== 'function') {
|
|
6388
6350
|
throw new Error('semanticsToAST() expects a Grammar as parameter');
|
|
6389
6351
|
}
|
|
6390
6352
|
|