ohm-js 16.3.0 → 16.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/ohm.esm.js +319 -329
- package/dist/ohm.js +1 -1
- package/dist/ohm.min.js +1 -1
- package/extras/semantics-toAST.js +3 -16
- package/package.json +2 -2
- package/src/errors.js +4 -1
package/dist/ohm.esm.js
CHANGED
|
@@ -745,7 +745,7 @@ pexprsMain.UnicodeChar = UnicodeChar;
|
|
|
745
745
|
// --------------------------------------------------------------------
|
|
746
746
|
|
|
747
747
|
const common$i = common$l;
|
|
748
|
-
const pexprs$
|
|
748
|
+
const pexprs$l = pexprsMain;
|
|
749
749
|
|
|
750
750
|
// --------------------------------------------------------------------
|
|
751
751
|
// Operations
|
|
@@ -754,7 +754,7 @@ const pexprs$m = pexprsMain;
|
|
|
754
754
|
/*
|
|
755
755
|
Return true if we should skip spaces preceding this expression in a syntactic context.
|
|
756
756
|
*/
|
|
757
|
-
pexprs$
|
|
757
|
+
pexprs$l.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
758
758
|
'allowsSkippingPrecedingSpace'
|
|
759
759
|
);
|
|
760
760
|
|
|
@@ -762,12 +762,12 @@ pexprs$m.PExpr.prototype.allowsSkippingPrecedingSpace = common$i.abstract(
|
|
|
762
762
|
Generally, these are all first-order expressions and (with the exception of Apply)
|
|
763
763
|
directly read from the input stream.
|
|
764
764
|
*/
|
|
765
|
-
pexprs$
|
|
766
|
-
pexprs$
|
|
767
|
-
pexprs$
|
|
768
|
-
pexprs$
|
|
769
|
-
pexprs$
|
|
770
|
-
pexprs$
|
|
765
|
+
pexprs$l.any.allowsSkippingPrecedingSpace =
|
|
766
|
+
pexprs$l.end.allowsSkippingPrecedingSpace =
|
|
767
|
+
pexprs$l.Apply.prototype.allowsSkippingPrecedingSpace =
|
|
768
|
+
pexprs$l.Terminal.prototype.allowsSkippingPrecedingSpace =
|
|
769
|
+
pexprs$l.Range.prototype.allowsSkippingPrecedingSpace =
|
|
770
|
+
pexprs$l.UnicodeChar.prototype.allowsSkippingPrecedingSpace =
|
|
771
771
|
function() {
|
|
772
772
|
return true;
|
|
773
773
|
};
|
|
@@ -775,13 +775,13 @@ pexprs$m.any.allowsSkippingPrecedingSpace =
|
|
|
775
775
|
/*
|
|
776
776
|
Higher-order expressions that don't directly consume input.
|
|
777
777
|
*/
|
|
778
|
-
pexprs$
|
|
779
|
-
pexprs$
|
|
780
|
-
pexprs$
|
|
781
|
-
pexprs$
|
|
782
|
-
pexprs$
|
|
783
|
-
pexprs$
|
|
784
|
-
pexprs$
|
|
778
|
+
pexprs$l.Alt.prototype.allowsSkippingPrecedingSpace =
|
|
779
|
+
pexprs$l.Iter.prototype.allowsSkippingPrecedingSpace =
|
|
780
|
+
pexprs$l.Lex.prototype.allowsSkippingPrecedingSpace =
|
|
781
|
+
pexprs$l.Lookahead.prototype.allowsSkippingPrecedingSpace =
|
|
782
|
+
pexprs$l.Not.prototype.allowsSkippingPrecedingSpace =
|
|
783
|
+
pexprs$l.Param.prototype.allowsSkippingPrecedingSpace =
|
|
784
|
+
pexprs$l.Seq.prototype.allowsSkippingPrecedingSpace =
|
|
785
785
|
function() {
|
|
786
786
|
return false;
|
|
787
787
|
};
|
|
@@ -840,7 +840,7 @@ var Namespace_1 = Namespace$2;
|
|
|
840
840
|
|
|
841
841
|
const {assert: assert$3} = common$l;
|
|
842
842
|
const Namespace$1 = Namespace_1;
|
|
843
|
-
const pexprs$
|
|
843
|
+
const pexprs$k = pexprsMain;
|
|
844
844
|
|
|
845
845
|
// --------------------------------------------------------------------
|
|
846
846
|
// Private stuff
|
|
@@ -1052,7 +1052,10 @@ function invalidCodePoint(applyWrapper) {
|
|
|
1052
1052
|
// Get an interval that covers all of the hex digits.
|
|
1053
1053
|
const digitIntervals = applyWrapper.children.slice(1, -1).map(d => d.source);
|
|
1054
1054
|
const fullInterval = digitIntervals[0].coverageWith(...digitIntervals.slice(1));
|
|
1055
|
-
return createError(
|
|
1055
|
+
return createError(
|
|
1056
|
+
`U+${fullInterval.contents} is not a valid Unicode code point`,
|
|
1057
|
+
fullInterval
|
|
1058
|
+
);
|
|
1056
1059
|
}
|
|
1057
1060
|
|
|
1058
1061
|
// ----------------- Kleene operators -----------------
|
|
@@ -1069,7 +1072,7 @@ function kleeneExprHasNullableOperand(kleeneExpr, applicationStack) {
|
|
|
1069
1072
|
"' (possible infinite loop)";
|
|
1070
1073
|
if (applicationStack.length > 0) {
|
|
1071
1074
|
const stackTrace = applicationStack
|
|
1072
|
-
.map(app => new pexprs$
|
|
1075
|
+
.map(app => new pexprs$k.Apply(app.ruleName, app.args))
|
|
1073
1076
|
.join('\n');
|
|
1074
1077
|
message += '\nApplication stack (most recent application last):\n' + stackTrace;
|
|
1075
1078
|
}
|
|
@@ -1372,7 +1375,7 @@ exports.uniqueId = (() => {
|
|
|
1372
1375
|
|
|
1373
1376
|
const {abstract, isSyntactic} = common$l;
|
|
1374
1377
|
const errors$8 = errors$9;
|
|
1375
|
-
const pexprs$
|
|
1378
|
+
const pexprs$j = pexprsMain;
|
|
1376
1379
|
const util$6 = util$7;
|
|
1377
1380
|
|
|
1378
1381
|
let BuiltInRules;
|
|
@@ -1387,51 +1390,51 @@ util$6.awaitBuiltInRules(g => {
|
|
|
1387
1390
|
|
|
1388
1391
|
let lexifyCount;
|
|
1389
1392
|
|
|
1390
|
-
pexprs$
|
|
1393
|
+
pexprs$j.PExpr.prototype.assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1391
1394
|
lexifyCount = 0;
|
|
1392
1395
|
this._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1393
1396
|
};
|
|
1394
1397
|
|
|
1395
|
-
pexprs$
|
|
1398
|
+
pexprs$j.PExpr.prototype._assertAllApplicationsAreValid = abstract(
|
|
1396
1399
|
'_assertAllApplicationsAreValid'
|
|
1397
1400
|
);
|
|
1398
1401
|
|
|
1399
|
-
pexprs$
|
|
1400
|
-
pexprs$
|
|
1401
|
-
pexprs$
|
|
1402
|
-
pexprs$
|
|
1403
|
-
pexprs$
|
|
1404
|
-
pexprs$
|
|
1402
|
+
pexprs$j.any._assertAllApplicationsAreValid =
|
|
1403
|
+
pexprs$j.end._assertAllApplicationsAreValid =
|
|
1404
|
+
pexprs$j.Terminal.prototype._assertAllApplicationsAreValid =
|
|
1405
|
+
pexprs$j.Range.prototype._assertAllApplicationsAreValid =
|
|
1406
|
+
pexprs$j.Param.prototype._assertAllApplicationsAreValid =
|
|
1407
|
+
pexprs$j.UnicodeChar.prototype._assertAllApplicationsAreValid =
|
|
1405
1408
|
function(ruleName, grammar) {
|
|
1406
1409
|
// no-op
|
|
1407
1410
|
};
|
|
1408
1411
|
|
|
1409
|
-
pexprs$
|
|
1412
|
+
pexprs$j.Lex.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1410
1413
|
lexifyCount++;
|
|
1411
1414
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1412
1415
|
lexifyCount--;
|
|
1413
1416
|
};
|
|
1414
1417
|
|
|
1415
|
-
pexprs$
|
|
1418
|
+
pexprs$j.Alt.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1416
1419
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1417
1420
|
this.terms[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1418
1421
|
}
|
|
1419
1422
|
};
|
|
1420
1423
|
|
|
1421
|
-
pexprs$
|
|
1424
|
+
pexprs$j.Seq.prototype._assertAllApplicationsAreValid = function(ruleName, grammar) {
|
|
1422
1425
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1423
1426
|
this.factors[idx]._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1424
1427
|
}
|
|
1425
1428
|
};
|
|
1426
1429
|
|
|
1427
|
-
pexprs$
|
|
1428
|
-
pexprs$
|
|
1429
|
-
pexprs$
|
|
1430
|
+
pexprs$j.Iter.prototype._assertAllApplicationsAreValid =
|
|
1431
|
+
pexprs$j.Not.prototype._assertAllApplicationsAreValid =
|
|
1432
|
+
pexprs$j.Lookahead.prototype._assertAllApplicationsAreValid =
|
|
1430
1433
|
function(ruleName, grammar) {
|
|
1431
1434
|
this.expr._assertAllApplicationsAreValid(ruleName, grammar);
|
|
1432
1435
|
};
|
|
1433
1436
|
|
|
1434
|
-
pexprs$
|
|
1437
|
+
pexprs$j.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
1435
1438
|
ruleName,
|
|
1436
1439
|
grammar,
|
|
1437
1440
|
skipSyntacticCheck = false
|
|
@@ -1463,14 +1466,14 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1463
1466
|
|
|
1464
1467
|
// If it's an application of 'caseInsensitive', ensure that the argument is a Terminal.
|
|
1465
1468
|
if (isBuiltInCaseInsensitive) {
|
|
1466
|
-
if (!(this.args[0] instanceof pexprs$
|
|
1469
|
+
if (!(this.args[0] instanceof pexprs$j.Terminal)) {
|
|
1467
1470
|
throw errors$8.incorrectArgumentType('a Terminal (e.g. "abc")', this.args[0]);
|
|
1468
1471
|
}
|
|
1469
1472
|
}
|
|
1470
1473
|
|
|
1471
1474
|
if (isBuiltInApplySyntactic) {
|
|
1472
1475
|
const arg = this.args[0];
|
|
1473
|
-
if (!(arg instanceof pexprs$
|
|
1476
|
+
if (!(arg instanceof pexprs$j.Apply)) {
|
|
1474
1477
|
throw errors$8.incorrectArgumentType('a syntactic rule application', arg);
|
|
1475
1478
|
}
|
|
1476
1479
|
if (!isSyntactic(arg.ruleName)) {
|
|
@@ -1498,28 +1501,28 @@ pexprs$k.Apply.prototype._assertAllApplicationsAreValid = function(
|
|
|
1498
1501
|
|
|
1499
1502
|
const common$h = common$l;
|
|
1500
1503
|
const errors$7 = errors$9;
|
|
1501
|
-
const pexprs$
|
|
1504
|
+
const pexprs$i = pexprsMain;
|
|
1502
1505
|
|
|
1503
1506
|
// --------------------------------------------------------------------
|
|
1504
1507
|
// Operations
|
|
1505
1508
|
// --------------------------------------------------------------------
|
|
1506
1509
|
|
|
1507
|
-
pexprs$
|
|
1510
|
+
pexprs$i.PExpr.prototype.assertChoicesHaveUniformArity = common$h.abstract(
|
|
1508
1511
|
'assertChoicesHaveUniformArity'
|
|
1509
1512
|
);
|
|
1510
1513
|
|
|
1511
|
-
pexprs$
|
|
1512
|
-
pexprs$
|
|
1513
|
-
pexprs$
|
|
1514
|
-
pexprs$
|
|
1515
|
-
pexprs$
|
|
1516
|
-
pexprs$
|
|
1517
|
-
pexprs$
|
|
1514
|
+
pexprs$i.any.assertChoicesHaveUniformArity =
|
|
1515
|
+
pexprs$i.end.assertChoicesHaveUniformArity =
|
|
1516
|
+
pexprs$i.Terminal.prototype.assertChoicesHaveUniformArity =
|
|
1517
|
+
pexprs$i.Range.prototype.assertChoicesHaveUniformArity =
|
|
1518
|
+
pexprs$i.Param.prototype.assertChoicesHaveUniformArity =
|
|
1519
|
+
pexprs$i.Lex.prototype.assertChoicesHaveUniformArity =
|
|
1520
|
+
pexprs$i.UnicodeChar.prototype.assertChoicesHaveUniformArity =
|
|
1518
1521
|
function(ruleName) {
|
|
1519
1522
|
// no-op
|
|
1520
1523
|
};
|
|
1521
1524
|
|
|
1522
|
-
pexprs$
|
|
1525
|
+
pexprs$i.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1523
1526
|
if (this.terms.length === 0) {
|
|
1524
1527
|
return;
|
|
1525
1528
|
}
|
|
@@ -1534,7 +1537,7 @@ pexprs$j.Alt.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1534
1537
|
}
|
|
1535
1538
|
};
|
|
1536
1539
|
|
|
1537
|
-
pexprs$
|
|
1540
|
+
pexprs$i.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1538
1541
|
// Extend is a special case of Alt that's guaranteed to have exactly two
|
|
1539
1542
|
// cases: [extensions, origBody].
|
|
1540
1543
|
const actualArity = this.terms[0].getArity();
|
|
@@ -1544,25 +1547,25 @@ pexprs$j.Extend.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1544
1547
|
}
|
|
1545
1548
|
};
|
|
1546
1549
|
|
|
1547
|
-
pexprs$
|
|
1550
|
+
pexprs$i.Seq.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1548
1551
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1549
1552
|
this.factors[idx].assertChoicesHaveUniformArity(ruleName);
|
|
1550
1553
|
}
|
|
1551
1554
|
};
|
|
1552
1555
|
|
|
1553
|
-
pexprs$
|
|
1556
|
+
pexprs$i.Iter.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1554
1557
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1555
1558
|
};
|
|
1556
1559
|
|
|
1557
|
-
pexprs$
|
|
1560
|
+
pexprs$i.Not.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1558
1561
|
// no-op (not required b/c the nested expr doesn't show up in the CST)
|
|
1559
1562
|
};
|
|
1560
1563
|
|
|
1561
|
-
pexprs$
|
|
1564
|
+
pexprs$i.Lookahead.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1562
1565
|
this.expr.assertChoicesHaveUniformArity(ruleName);
|
|
1563
1566
|
};
|
|
1564
1567
|
|
|
1565
|
-
pexprs$
|
|
1568
|
+
pexprs$i.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
1566
1569
|
// The arities of the parameter expressions is required to be 1 by
|
|
1567
1570
|
// `assertAllApplicationsAreValid()`.
|
|
1568
1571
|
};
|
|
@@ -1573,39 +1576,39 @@ pexprs$j.Apply.prototype.assertChoicesHaveUniformArity = function(ruleName) {
|
|
|
1573
1576
|
|
|
1574
1577
|
const common$g = common$l;
|
|
1575
1578
|
const errors$6 = errors$9;
|
|
1576
|
-
const pexprs$
|
|
1579
|
+
const pexprs$h = pexprsMain;
|
|
1577
1580
|
|
|
1578
1581
|
// --------------------------------------------------------------------
|
|
1579
1582
|
// Operations
|
|
1580
1583
|
// --------------------------------------------------------------------
|
|
1581
1584
|
|
|
1582
|
-
pexprs$
|
|
1585
|
+
pexprs$h.PExpr.prototype.assertIteratedExprsAreNotNullable = common$g.abstract(
|
|
1583
1586
|
'assertIteratedExprsAreNotNullable'
|
|
1584
1587
|
);
|
|
1585
1588
|
|
|
1586
|
-
pexprs$
|
|
1587
|
-
pexprs$
|
|
1588
|
-
pexprs$
|
|
1589
|
-
pexprs$
|
|
1590
|
-
pexprs$
|
|
1591
|
-
pexprs$
|
|
1589
|
+
pexprs$h.any.assertIteratedExprsAreNotNullable =
|
|
1590
|
+
pexprs$h.end.assertIteratedExprsAreNotNullable =
|
|
1591
|
+
pexprs$h.Terminal.prototype.assertIteratedExprsAreNotNullable =
|
|
1592
|
+
pexprs$h.Range.prototype.assertIteratedExprsAreNotNullable =
|
|
1593
|
+
pexprs$h.Param.prototype.assertIteratedExprsAreNotNullable =
|
|
1594
|
+
pexprs$h.UnicodeChar.prototype.assertIteratedExprsAreNotNullable =
|
|
1592
1595
|
function(grammar) {
|
|
1593
1596
|
// no-op
|
|
1594
1597
|
};
|
|
1595
1598
|
|
|
1596
|
-
pexprs$
|
|
1599
|
+
pexprs$h.Alt.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1597
1600
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
1598
1601
|
this.terms[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1599
1602
|
}
|
|
1600
1603
|
};
|
|
1601
1604
|
|
|
1602
|
-
pexprs$
|
|
1605
|
+
pexprs$h.Seq.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1603
1606
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
1604
1607
|
this.factors[idx].assertIteratedExprsAreNotNullable(grammar);
|
|
1605
1608
|
}
|
|
1606
1609
|
};
|
|
1607
1610
|
|
|
1608
|
-
pexprs$
|
|
1611
|
+
pexprs$h.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1609
1612
|
// Note: this is the implementation of this method for `Star` and `Plus` expressions.
|
|
1610
1613
|
// It is overridden for `Opt` below.
|
|
1611
1614
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
@@ -1614,15 +1617,15 @@ pexprs$i.Iter.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
|
1614
1617
|
}
|
|
1615
1618
|
};
|
|
1616
1619
|
|
|
1617
|
-
pexprs$
|
|
1618
|
-
pexprs$
|
|
1619
|
-
pexprs$
|
|
1620
|
-
pexprs$
|
|
1620
|
+
pexprs$h.Opt.prototype.assertIteratedExprsAreNotNullable =
|
|
1621
|
+
pexprs$h.Not.prototype.assertIteratedExprsAreNotNullable =
|
|
1622
|
+
pexprs$h.Lookahead.prototype.assertIteratedExprsAreNotNullable =
|
|
1623
|
+
pexprs$h.Lex.prototype.assertIteratedExprsAreNotNullable =
|
|
1621
1624
|
function(grammar) {
|
|
1622
1625
|
this.expr.assertIteratedExprsAreNotNullable(grammar);
|
|
1623
1626
|
};
|
|
1624
1627
|
|
|
1625
|
-
pexprs$
|
|
1628
|
+
pexprs$h.Apply.prototype.assertIteratedExprsAreNotNullable = function(grammar) {
|
|
1626
1629
|
this.args.forEach(arg => {
|
|
1627
1630
|
arg.assertIteratedExprsAreNotNullable(grammar);
|
|
1628
1631
|
});
|
|
@@ -1987,7 +1990,7 @@ const Trace$1 = Trace_1;
|
|
|
1987
1990
|
const common$e = common$l;
|
|
1988
1991
|
const errors$4 = errors$9;
|
|
1989
1992
|
const nodes = nodes$1;
|
|
1990
|
-
const pexprs$
|
|
1993
|
+
const pexprs$g = pexprsMain;
|
|
1991
1994
|
|
|
1992
1995
|
const {TerminalNode: TerminalNode$1} = nodes;
|
|
1993
1996
|
const {NonterminalNode} = nodes;
|
|
@@ -2013,9 +2016,9 @@ const {IterationNode: IterationNode$1} = nodes;
|
|
|
2013
2016
|
Note that `State.prototype.eval(expr)`, unlike this method, guarantees that neither the state
|
|
2014
2017
|
object's bindings nor its input stream's position will change if the expression fails to match.
|
|
2015
2018
|
*/
|
|
2016
|
-
pexprs$
|
|
2019
|
+
pexprs$g.PExpr.prototype.eval = common$e.abstract('eval'); // function(state) { ... }
|
|
2017
2020
|
|
|
2018
|
-
pexprs$
|
|
2021
|
+
pexprs$g.any.eval = function(state) {
|
|
2019
2022
|
const {inputStream} = state;
|
|
2020
2023
|
const origPos = inputStream.pos;
|
|
2021
2024
|
const ch = inputStream.next();
|
|
@@ -2028,7 +2031,7 @@ pexprs$h.any.eval = function(state) {
|
|
|
2028
2031
|
}
|
|
2029
2032
|
};
|
|
2030
2033
|
|
|
2031
|
-
pexprs$
|
|
2034
|
+
pexprs$g.end.eval = function(state) {
|
|
2032
2035
|
const {inputStream} = state;
|
|
2033
2036
|
const origPos = inputStream.pos;
|
|
2034
2037
|
if (inputStream.atEnd()) {
|
|
@@ -2040,7 +2043,7 @@ pexprs$h.end.eval = function(state) {
|
|
|
2040
2043
|
}
|
|
2041
2044
|
};
|
|
2042
2045
|
|
|
2043
|
-
pexprs$
|
|
2046
|
+
pexprs$g.Terminal.prototype.eval = function(state) {
|
|
2044
2047
|
const {inputStream} = state;
|
|
2045
2048
|
const origPos = inputStream.pos;
|
|
2046
2049
|
if (!inputStream.matchString(this.obj)) {
|
|
@@ -2052,7 +2055,7 @@ pexprs$h.Terminal.prototype.eval = function(state) {
|
|
|
2052
2055
|
}
|
|
2053
2056
|
};
|
|
2054
2057
|
|
|
2055
|
-
pexprs$
|
|
2058
|
+
pexprs$g.Range.prototype.eval = function(state) {
|
|
2056
2059
|
const {inputStream} = state;
|
|
2057
2060
|
const origPos = inputStream.pos;
|
|
2058
2061
|
|
|
@@ -2071,18 +2074,18 @@ pexprs$h.Range.prototype.eval = function(state) {
|
|
|
2071
2074
|
}
|
|
2072
2075
|
};
|
|
2073
2076
|
|
|
2074
|
-
pexprs$
|
|
2077
|
+
pexprs$g.Param.prototype.eval = function(state) {
|
|
2075
2078
|
return state.eval(state.currentApplication().args[this.index]);
|
|
2076
2079
|
};
|
|
2077
2080
|
|
|
2078
|
-
pexprs$
|
|
2081
|
+
pexprs$g.Lex.prototype.eval = function(state) {
|
|
2079
2082
|
state.enterLexifiedContext();
|
|
2080
2083
|
const ans = state.eval(this.expr);
|
|
2081
2084
|
state.exitLexifiedContext();
|
|
2082
2085
|
return ans;
|
|
2083
2086
|
};
|
|
2084
2087
|
|
|
2085
|
-
pexprs$
|
|
2088
|
+
pexprs$g.Alt.prototype.eval = function(state) {
|
|
2086
2089
|
for (let idx = 0; idx < this.terms.length; idx++) {
|
|
2087
2090
|
if (state.eval(this.terms[idx])) {
|
|
2088
2091
|
return true;
|
|
@@ -2091,7 +2094,7 @@ pexprs$h.Alt.prototype.eval = function(state) {
|
|
|
2091
2094
|
return false;
|
|
2092
2095
|
};
|
|
2093
2096
|
|
|
2094
|
-
pexprs$
|
|
2097
|
+
pexprs$g.Seq.prototype.eval = function(state) {
|
|
2095
2098
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2096
2099
|
const factor = this.factors[idx];
|
|
2097
2100
|
if (!state.eval(factor)) {
|
|
@@ -2101,7 +2104,7 @@ pexprs$h.Seq.prototype.eval = function(state) {
|
|
|
2101
2104
|
return true;
|
|
2102
2105
|
};
|
|
2103
2106
|
|
|
2104
|
-
pexprs$
|
|
2107
|
+
pexprs$g.Iter.prototype.eval = function(state) {
|
|
2105
2108
|
const {inputStream} = state;
|
|
2106
2109
|
const origPos = inputStream.pos;
|
|
2107
2110
|
const arity = this.getArity();
|
|
@@ -2145,7 +2148,7 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2145
2148
|
offset = colOffsets[0][0];
|
|
2146
2149
|
matchLength = endOffset - offset;
|
|
2147
2150
|
}
|
|
2148
|
-
const isOptional = this instanceof pexprs$
|
|
2151
|
+
const isOptional = this instanceof pexprs$g.Opt;
|
|
2149
2152
|
for (idx = 0; idx < cols.length; idx++) {
|
|
2150
2153
|
state._bindings.push(
|
|
2151
2154
|
new IterationNode$1(state.grammar, cols[idx], colOffsets[idx], matchLength, isOptional)
|
|
@@ -2155,7 +2158,7 @@ pexprs$h.Iter.prototype.eval = function(state) {
|
|
|
2155
2158
|
return true;
|
|
2156
2159
|
};
|
|
2157
2160
|
|
|
2158
|
-
pexprs$
|
|
2161
|
+
pexprs$g.Not.prototype.eval = function(state) {
|
|
2159
2162
|
/*
|
|
2160
2163
|
TODO:
|
|
2161
2164
|
- Right now we're just throwing away all of the failures that happen inside a `not`, and
|
|
@@ -2181,7 +2184,7 @@ pexprs$h.Not.prototype.eval = function(state) {
|
|
|
2181
2184
|
return true;
|
|
2182
2185
|
};
|
|
2183
2186
|
|
|
2184
|
-
pexprs$
|
|
2187
|
+
pexprs$g.Lookahead.prototype.eval = function(state) {
|
|
2185
2188
|
const {inputStream} = state;
|
|
2186
2189
|
const origPos = inputStream.pos;
|
|
2187
2190
|
if (state.eval(this.expr)) {
|
|
@@ -2192,7 +2195,7 @@ pexprs$h.Lookahead.prototype.eval = function(state) {
|
|
|
2192
2195
|
}
|
|
2193
2196
|
};
|
|
2194
2197
|
|
|
2195
|
-
pexprs$
|
|
2198
|
+
pexprs$g.Apply.prototype.eval = function(state) {
|
|
2196
2199
|
const caller = state.currentApplication();
|
|
2197
2200
|
const actuals = caller ? caller.args : [];
|
|
2198
2201
|
const app = this.substituteParams(actuals);
|
|
@@ -2215,7 +2218,7 @@ pexprs$h.Apply.prototype.eval = function(state) {
|
|
|
2215
2218
|
return app.reallyEval(state);
|
|
2216
2219
|
};
|
|
2217
2220
|
|
|
2218
|
-
pexprs$
|
|
2221
|
+
pexprs$g.Apply.prototype.handleCycle = function(state) {
|
|
2219
2222
|
const posInfo = state.getCurrentPosInfo();
|
|
2220
2223
|
const {currentLeftRecursion} = posInfo;
|
|
2221
2224
|
const memoKey = this.toMemoKey();
|
|
@@ -2238,7 +2241,7 @@ pexprs$h.Apply.prototype.handleCycle = function(state) {
|
|
|
2238
2241
|
return state.useMemoizedResult(state.inputStream.pos, memoRec);
|
|
2239
2242
|
};
|
|
2240
2243
|
|
|
2241
|
-
pexprs$
|
|
2244
|
+
pexprs$g.Apply.prototype.reallyEval = function(state) {
|
|
2242
2245
|
const {inputStream} = state;
|
|
2243
2246
|
const origPos = inputStream.pos;
|
|
2244
2247
|
const origPosInfo = state.getCurrentPosInfo();
|
|
@@ -2315,7 +2318,7 @@ pexprs$h.Apply.prototype.reallyEval = function(state) {
|
|
|
2315
2318
|
return succeeded;
|
|
2316
2319
|
};
|
|
2317
2320
|
|
|
2318
|
-
pexprs$
|
|
2321
|
+
pexprs$g.Apply.prototype.evalOnce = function(expr, state) {
|
|
2319
2322
|
const {inputStream} = state;
|
|
2320
2323
|
const origPos = inputStream.pos;
|
|
2321
2324
|
|
|
@@ -2335,7 +2338,7 @@ pexprs$h.Apply.prototype.evalOnce = function(expr, state) {
|
|
|
2335
2338
|
}
|
|
2336
2339
|
};
|
|
2337
2340
|
|
|
2338
|
-
pexprs$
|
|
2341
|
+
pexprs$g.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoRec, newValue) {
|
|
2339
2342
|
if (!newValue) {
|
|
2340
2343
|
return false;
|
|
2341
2344
|
}
|
|
@@ -2379,7 +2382,7 @@ pexprs$h.Apply.prototype.growSeedResult = function(body, state, origPos, lrMemoR
|
|
|
2379
2382
|
return lrMemoRec.value;
|
|
2380
2383
|
};
|
|
2381
2384
|
|
|
2382
|
-
pexprs$
|
|
2385
|
+
pexprs$g.UnicodeChar.prototype.eval = function(state) {
|
|
2383
2386
|
const {inputStream} = state;
|
|
2384
2387
|
const origPos = inputStream.pos;
|
|
2385
2388
|
const ch = inputStream.next();
|
|
@@ -2397,32 +2400,32 @@ pexprs$h.UnicodeChar.prototype.eval = function(state) {
|
|
|
2397
2400
|
// --------------------------------------------------------------------
|
|
2398
2401
|
|
|
2399
2402
|
const common$d = common$l;
|
|
2400
|
-
const pexprs$
|
|
2403
|
+
const pexprs$f = pexprsMain;
|
|
2401
2404
|
|
|
2402
2405
|
// --------------------------------------------------------------------
|
|
2403
2406
|
// Operations
|
|
2404
2407
|
// --------------------------------------------------------------------
|
|
2405
2408
|
|
|
2406
|
-
pexprs$
|
|
2409
|
+
pexprs$f.PExpr.prototype.getArity = common$d.abstract('getArity');
|
|
2407
2410
|
|
|
2408
|
-
pexprs$
|
|
2409
|
-
pexprs$
|
|
2410
|
-
pexprs$
|
|
2411
|
-
pexprs$
|
|
2412
|
-
pexprs$
|
|
2413
|
-
pexprs$
|
|
2414
|
-
pexprs$
|
|
2411
|
+
pexprs$f.any.getArity =
|
|
2412
|
+
pexprs$f.end.getArity =
|
|
2413
|
+
pexprs$f.Terminal.prototype.getArity =
|
|
2414
|
+
pexprs$f.Range.prototype.getArity =
|
|
2415
|
+
pexprs$f.Param.prototype.getArity =
|
|
2416
|
+
pexprs$f.Apply.prototype.getArity =
|
|
2417
|
+
pexprs$f.UnicodeChar.prototype.getArity =
|
|
2415
2418
|
function() {
|
|
2416
2419
|
return 1;
|
|
2417
2420
|
};
|
|
2418
2421
|
|
|
2419
|
-
pexprs$
|
|
2422
|
+
pexprs$f.Alt.prototype.getArity = function() {
|
|
2420
2423
|
// This is ok b/c all terms must have the same arity -- this property is
|
|
2421
2424
|
// checked by the Grammar constructor.
|
|
2422
2425
|
return this.terms.length === 0 ? 0 : this.terms[0].getArity();
|
|
2423
2426
|
};
|
|
2424
2427
|
|
|
2425
|
-
pexprs$
|
|
2428
|
+
pexprs$f.Seq.prototype.getArity = function() {
|
|
2426
2429
|
let arity = 0;
|
|
2427
2430
|
for (let idx = 0; idx < this.factors.length; idx++) {
|
|
2428
2431
|
arity += this.factors[idx].getArity();
|
|
@@ -2430,15 +2433,15 @@ pexprs$g.Seq.prototype.getArity = function() {
|
|
|
2430
2433
|
return arity;
|
|
2431
2434
|
};
|
|
2432
2435
|
|
|
2433
|
-
pexprs$
|
|
2436
|
+
pexprs$f.Iter.prototype.getArity = function() {
|
|
2434
2437
|
return this.expr.getArity();
|
|
2435
2438
|
};
|
|
2436
2439
|
|
|
2437
|
-
pexprs$
|
|
2440
|
+
pexprs$f.Not.prototype.getArity = function() {
|
|
2438
2441
|
return 0;
|
|
2439
2442
|
};
|
|
2440
2443
|
|
|
2441
|
-
pexprs$
|
|
2444
|
+
pexprs$f.Lookahead.prototype.getArity = pexprs$f.Lex.prototype.getArity = function() {
|
|
2442
2445
|
return this.expr.getArity();
|
|
2443
2446
|
};
|
|
2444
2447
|
|
|
@@ -2447,7 +2450,7 @@ pexprs$g.Lookahead.prototype.getArity = pexprs$g.Lex.prototype.getArity = functi
|
|
|
2447
2450
|
// --------------------------------------------------------------------
|
|
2448
2451
|
|
|
2449
2452
|
const common$c = common$l;
|
|
2450
|
-
const pexprs$
|
|
2453
|
+
const pexprs$e = pexprsMain;
|
|
2451
2454
|
|
|
2452
2455
|
// --------------------------------------------------------------------
|
|
2453
2456
|
// Private stuff
|
|
@@ -2466,40 +2469,40 @@ function getMetaInfo(expr, grammarInterval) {
|
|
|
2466
2469
|
// Operations
|
|
2467
2470
|
// --------------------------------------------------------------------
|
|
2468
2471
|
|
|
2469
|
-
pexprs$
|
|
2472
|
+
pexprs$e.PExpr.prototype.outputRecipe = common$c.abstract('outputRecipe');
|
|
2470
2473
|
|
|
2471
|
-
pexprs$
|
|
2474
|
+
pexprs$e.any.outputRecipe = function(formals, grammarInterval) {
|
|
2472
2475
|
return ['any', getMetaInfo(this, grammarInterval)];
|
|
2473
2476
|
};
|
|
2474
2477
|
|
|
2475
|
-
pexprs$
|
|
2478
|
+
pexprs$e.end.outputRecipe = function(formals, grammarInterval) {
|
|
2476
2479
|
return ['end', getMetaInfo(this, grammarInterval)];
|
|
2477
2480
|
};
|
|
2478
2481
|
|
|
2479
|
-
pexprs$
|
|
2482
|
+
pexprs$e.Terminal.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2480
2483
|
return ['terminal', getMetaInfo(this, grammarInterval), this.obj];
|
|
2481
2484
|
};
|
|
2482
2485
|
|
|
2483
|
-
pexprs$
|
|
2486
|
+
pexprs$e.Range.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2484
2487
|
return ['range', getMetaInfo(this, grammarInterval), this.from, this.to];
|
|
2485
2488
|
};
|
|
2486
2489
|
|
|
2487
|
-
pexprs$
|
|
2490
|
+
pexprs$e.Param.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2488
2491
|
return ['param', getMetaInfo(this, grammarInterval), this.index];
|
|
2489
2492
|
};
|
|
2490
2493
|
|
|
2491
|
-
pexprs$
|
|
2494
|
+
pexprs$e.Alt.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2492
2495
|
return ['alt', getMetaInfo(this, grammarInterval)].concat(
|
|
2493
2496
|
this.terms.map(term => term.outputRecipe(formals, grammarInterval))
|
|
2494
2497
|
);
|
|
2495
2498
|
};
|
|
2496
2499
|
|
|
2497
|
-
pexprs$
|
|
2500
|
+
pexprs$e.Extend.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2498
2501
|
const extension = this.terms[0]; // [extension, original]
|
|
2499
2502
|
return extension.outputRecipe(formals, grammarInterval);
|
|
2500
2503
|
};
|
|
2501
2504
|
|
|
2502
|
-
pexprs$
|
|
2505
|
+
pexprs$e.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2503
2506
|
const beforeTerms = this.terms.slice(0, this.expansionPos);
|
|
2504
2507
|
const afterTerms = this.terms.slice(this.expansionPos + 1);
|
|
2505
2508
|
return [
|
|
@@ -2510,18 +2513,18 @@ pexprs$f.Splice.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2510
2513
|
];
|
|
2511
2514
|
};
|
|
2512
2515
|
|
|
2513
|
-
pexprs$
|
|
2516
|
+
pexprs$e.Seq.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2514
2517
|
return ['seq', getMetaInfo(this, grammarInterval)].concat(
|
|
2515
2518
|
this.factors.map(factor => factor.outputRecipe(formals, grammarInterval))
|
|
2516
2519
|
);
|
|
2517
2520
|
};
|
|
2518
2521
|
|
|
2519
|
-
pexprs$
|
|
2520
|
-
pexprs$
|
|
2521
|
-
pexprs$
|
|
2522
|
-
pexprs$
|
|
2523
|
-
pexprs$
|
|
2524
|
-
pexprs$
|
|
2522
|
+
pexprs$e.Star.prototype.outputRecipe =
|
|
2523
|
+
pexprs$e.Plus.prototype.outputRecipe =
|
|
2524
|
+
pexprs$e.Opt.prototype.outputRecipe =
|
|
2525
|
+
pexprs$e.Not.prototype.outputRecipe =
|
|
2526
|
+
pexprs$e.Lookahead.prototype.outputRecipe =
|
|
2527
|
+
pexprs$e.Lex.prototype.outputRecipe =
|
|
2525
2528
|
function(formals, grammarInterval) {
|
|
2526
2529
|
return [
|
|
2527
2530
|
this.constructor.name.toLowerCase(),
|
|
@@ -2530,7 +2533,7 @@ pexprs$f.Star.prototype.outputRecipe =
|
|
|
2530
2533
|
];
|
|
2531
2534
|
};
|
|
2532
2535
|
|
|
2533
|
-
pexprs$
|
|
2536
|
+
pexprs$e.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2534
2537
|
return [
|
|
2535
2538
|
'app',
|
|
2536
2539
|
getMetaInfo(this, grammarInterval),
|
|
@@ -2539,7 +2542,7 @@ pexprs$f.Apply.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
|
2539
2542
|
];
|
|
2540
2543
|
};
|
|
2541
2544
|
|
|
2542
|
-
pexprs$
|
|
2545
|
+
pexprs$e.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval) {
|
|
2543
2546
|
return ['unicodeChar', getMetaInfo(this, grammarInterval), this.category];
|
|
2544
2547
|
};
|
|
2545
2548
|
|
|
@@ -2548,7 +2551,7 @@ pexprs$f.UnicodeChar.prototype.outputRecipe = function(formals, grammarInterval)
|
|
|
2548
2551
|
// --------------------------------------------------------------------
|
|
2549
2552
|
|
|
2550
2553
|
const common$b = common$l;
|
|
2551
|
-
const pexprs$
|
|
2554
|
+
const pexprs$d = pexprsMain;
|
|
2552
2555
|
|
|
2553
2556
|
// --------------------------------------------------------------------
|
|
2554
2557
|
// Operations
|
|
@@ -2559,49 +2562,49 @@ const pexprs$e = pexprsMain;
|
|
|
2559
2562
|
parameter with a `Param` node. Returns a PExpr -- either a new one, or the original one if
|
|
2560
2563
|
it was modified in place.
|
|
2561
2564
|
*/
|
|
2562
|
-
pexprs$
|
|
2563
|
-
|
|
2564
|
-
pexprs$
|
|
2565
|
-
pexprs$
|
|
2566
|
-
pexprs$
|
|
2567
|
-
pexprs$
|
|
2568
|
-
pexprs$
|
|
2569
|
-
pexprs$
|
|
2565
|
+
pexprs$d.PExpr.prototype.introduceParams = common$b.abstract('introduceParams');
|
|
2566
|
+
|
|
2567
|
+
pexprs$d.any.introduceParams =
|
|
2568
|
+
pexprs$d.end.introduceParams =
|
|
2569
|
+
pexprs$d.Terminal.prototype.introduceParams =
|
|
2570
|
+
pexprs$d.Range.prototype.introduceParams =
|
|
2571
|
+
pexprs$d.Param.prototype.introduceParams =
|
|
2572
|
+
pexprs$d.UnicodeChar.prototype.introduceParams =
|
|
2570
2573
|
function(formals) {
|
|
2571
2574
|
return this;
|
|
2572
2575
|
};
|
|
2573
2576
|
|
|
2574
|
-
pexprs$
|
|
2577
|
+
pexprs$d.Alt.prototype.introduceParams = function(formals) {
|
|
2575
2578
|
this.terms.forEach((term, idx, terms) => {
|
|
2576
2579
|
terms[idx] = term.introduceParams(formals);
|
|
2577
2580
|
});
|
|
2578
2581
|
return this;
|
|
2579
2582
|
};
|
|
2580
2583
|
|
|
2581
|
-
pexprs$
|
|
2584
|
+
pexprs$d.Seq.prototype.introduceParams = function(formals) {
|
|
2582
2585
|
this.factors.forEach((factor, idx, factors) => {
|
|
2583
2586
|
factors[idx] = factor.introduceParams(formals);
|
|
2584
2587
|
});
|
|
2585
2588
|
return this;
|
|
2586
2589
|
};
|
|
2587
2590
|
|
|
2588
|
-
pexprs$
|
|
2589
|
-
pexprs$
|
|
2590
|
-
pexprs$
|
|
2591
|
-
pexprs$
|
|
2591
|
+
pexprs$d.Iter.prototype.introduceParams =
|
|
2592
|
+
pexprs$d.Not.prototype.introduceParams =
|
|
2593
|
+
pexprs$d.Lookahead.prototype.introduceParams =
|
|
2594
|
+
pexprs$d.Lex.prototype.introduceParams =
|
|
2592
2595
|
function(formals) {
|
|
2593
2596
|
this.expr = this.expr.introduceParams(formals);
|
|
2594
2597
|
return this;
|
|
2595
2598
|
};
|
|
2596
2599
|
|
|
2597
|
-
pexprs$
|
|
2600
|
+
pexprs$d.Apply.prototype.introduceParams = function(formals) {
|
|
2598
2601
|
const index = formals.indexOf(this.ruleName);
|
|
2599
2602
|
if (index >= 0) {
|
|
2600
2603
|
if (this.args.length > 0) {
|
|
2601
2604
|
// TODO: Should this be supported? See issue #64.
|
|
2602
2605
|
throw new Error('Parameterized rules cannot be passed as arguments to another rule.');
|
|
2603
2606
|
}
|
|
2604
|
-
return new pexprs$
|
|
2607
|
+
return new pexprs$d.Param(index).withSource(this.source);
|
|
2605
2608
|
} else {
|
|
2606
2609
|
this.args.forEach((arg, idx, args) => {
|
|
2607
2610
|
args[idx] = arg.introduceParams(formals);
|
|
@@ -2615,33 +2618,33 @@ pexprs$e.Apply.prototype.introduceParams = function(formals) {
|
|
|
2615
2618
|
// --------------------------------------------------------------------
|
|
2616
2619
|
|
|
2617
2620
|
const common$a = common$l;
|
|
2618
|
-
const pexprs$
|
|
2621
|
+
const pexprs$c = pexprsMain;
|
|
2619
2622
|
|
|
2620
2623
|
// --------------------------------------------------------------------
|
|
2621
2624
|
// Operations
|
|
2622
2625
|
// --------------------------------------------------------------------
|
|
2623
2626
|
|
|
2624
2627
|
// Returns `true` if this parsing expression may accept without consuming any input.
|
|
2625
|
-
pexprs$
|
|
2628
|
+
pexprs$c.PExpr.prototype.isNullable = function(grammar) {
|
|
2626
2629
|
return this._isNullable(grammar, Object.create(null));
|
|
2627
2630
|
};
|
|
2628
2631
|
|
|
2629
|
-
pexprs$
|
|
2632
|
+
pexprs$c.PExpr.prototype._isNullable = common$a.abstract('_isNullable');
|
|
2630
2633
|
|
|
2631
|
-
pexprs$
|
|
2632
|
-
pexprs$
|
|
2633
|
-
pexprs$
|
|
2634
|
-
pexprs$
|
|
2635
|
-
pexprs$
|
|
2634
|
+
pexprs$c.any._isNullable =
|
|
2635
|
+
pexprs$c.Range.prototype._isNullable =
|
|
2636
|
+
pexprs$c.Param.prototype._isNullable =
|
|
2637
|
+
pexprs$c.Plus.prototype._isNullable =
|
|
2638
|
+
pexprs$c.UnicodeChar.prototype._isNullable =
|
|
2636
2639
|
function(grammar, memo) {
|
|
2637
2640
|
return false;
|
|
2638
2641
|
};
|
|
2639
2642
|
|
|
2640
|
-
pexprs$
|
|
2643
|
+
pexprs$c.end._isNullable = function(grammar, memo) {
|
|
2641
2644
|
return true;
|
|
2642
2645
|
};
|
|
2643
2646
|
|
|
2644
|
-
pexprs$
|
|
2647
|
+
pexprs$c.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
2645
2648
|
if (typeof this.obj === 'string') {
|
|
2646
2649
|
// This is an over-simplification: it's only correct if the input is a string. If it's an array
|
|
2647
2650
|
// or an object, then the empty string parsing expression is not nullable.
|
|
@@ -2651,27 +2654,27 @@ pexprs$d.Terminal.prototype._isNullable = function(grammar, memo) {
|
|
|
2651
2654
|
}
|
|
2652
2655
|
};
|
|
2653
2656
|
|
|
2654
|
-
pexprs$
|
|
2657
|
+
pexprs$c.Alt.prototype._isNullable = function(grammar, memo) {
|
|
2655
2658
|
return this.terms.length === 0 || this.terms.some(term => term._isNullable(grammar, memo));
|
|
2656
2659
|
};
|
|
2657
2660
|
|
|
2658
|
-
pexprs$
|
|
2661
|
+
pexprs$c.Seq.prototype._isNullable = function(grammar, memo) {
|
|
2659
2662
|
return this.factors.every(factor => factor._isNullable(grammar, memo));
|
|
2660
2663
|
};
|
|
2661
2664
|
|
|
2662
|
-
pexprs$
|
|
2663
|
-
pexprs$
|
|
2664
|
-
pexprs$
|
|
2665
|
-
pexprs$
|
|
2665
|
+
pexprs$c.Star.prototype._isNullable =
|
|
2666
|
+
pexprs$c.Opt.prototype._isNullable =
|
|
2667
|
+
pexprs$c.Not.prototype._isNullable =
|
|
2668
|
+
pexprs$c.Lookahead.prototype._isNullable =
|
|
2666
2669
|
function(grammar, memo) {
|
|
2667
2670
|
return true;
|
|
2668
2671
|
};
|
|
2669
2672
|
|
|
2670
|
-
pexprs$
|
|
2673
|
+
pexprs$c.Lex.prototype._isNullable = function(grammar, memo) {
|
|
2671
2674
|
return this.expr._isNullable(grammar, memo);
|
|
2672
2675
|
};
|
|
2673
2676
|
|
|
2674
|
-
pexprs$
|
|
2677
|
+
pexprs$c.Apply.prototype._isNullable = function(grammar, memo) {
|
|
2675
2678
|
const key = this.toMemoKey();
|
|
2676
2679
|
if (!Object.prototype.hasOwnProperty.call(memo, key)) {
|
|
2677
2680
|
const {body} = grammar.rules[this.ruleName];
|
|
@@ -2687,7 +2690,7 @@ pexprs$d.Apply.prototype._isNullable = function(grammar, memo) {
|
|
|
2687
2690
|
// --------------------------------------------------------------------
|
|
2688
2691
|
|
|
2689
2692
|
const common$9 = common$l;
|
|
2690
|
-
const pexprs$
|
|
2693
|
+
const pexprs$b = pexprsMain;
|
|
2691
2694
|
|
|
2692
2695
|
// --------------------------------------------------------------------
|
|
2693
2696
|
// Operations
|
|
@@ -2700,44 +2703,44 @@ const pexprs$c = pexprsMain;
|
|
|
2700
2703
|
The receiver must not be modified; a new PExpr must be returned if any replacement is necessary.
|
|
2701
2704
|
*/
|
|
2702
2705
|
// function(actuals) { ... }
|
|
2703
|
-
pexprs$
|
|
2706
|
+
pexprs$b.PExpr.prototype.substituteParams = common$9.abstract('substituteParams');
|
|
2704
2707
|
|
|
2705
|
-
pexprs$
|
|
2706
|
-
pexprs$
|
|
2707
|
-
pexprs$
|
|
2708
|
-
pexprs$
|
|
2709
|
-
pexprs$
|
|
2708
|
+
pexprs$b.any.substituteParams =
|
|
2709
|
+
pexprs$b.end.substituteParams =
|
|
2710
|
+
pexprs$b.Terminal.prototype.substituteParams =
|
|
2711
|
+
pexprs$b.Range.prototype.substituteParams =
|
|
2712
|
+
pexprs$b.UnicodeChar.prototype.substituteParams =
|
|
2710
2713
|
function(actuals) {
|
|
2711
2714
|
return this;
|
|
2712
2715
|
};
|
|
2713
2716
|
|
|
2714
|
-
pexprs$
|
|
2717
|
+
pexprs$b.Param.prototype.substituteParams = function(actuals) {
|
|
2715
2718
|
return actuals[this.index];
|
|
2716
2719
|
};
|
|
2717
2720
|
|
|
2718
|
-
pexprs$
|
|
2719
|
-
return new pexprs$
|
|
2721
|
+
pexprs$b.Alt.prototype.substituteParams = function(actuals) {
|
|
2722
|
+
return new pexprs$b.Alt(this.terms.map(term => term.substituteParams(actuals)));
|
|
2720
2723
|
};
|
|
2721
2724
|
|
|
2722
|
-
pexprs$
|
|
2723
|
-
return new pexprs$
|
|
2725
|
+
pexprs$b.Seq.prototype.substituteParams = function(actuals) {
|
|
2726
|
+
return new pexprs$b.Seq(this.factors.map(factor => factor.substituteParams(actuals)));
|
|
2724
2727
|
};
|
|
2725
2728
|
|
|
2726
|
-
pexprs$
|
|
2727
|
-
pexprs$
|
|
2728
|
-
pexprs$
|
|
2729
|
-
pexprs$
|
|
2729
|
+
pexprs$b.Iter.prototype.substituteParams =
|
|
2730
|
+
pexprs$b.Not.prototype.substituteParams =
|
|
2731
|
+
pexprs$b.Lookahead.prototype.substituteParams =
|
|
2732
|
+
pexprs$b.Lex.prototype.substituteParams =
|
|
2730
2733
|
function(actuals) {
|
|
2731
2734
|
return new this.constructor(this.expr.substituteParams(actuals));
|
|
2732
2735
|
};
|
|
2733
2736
|
|
|
2734
|
-
pexprs$
|
|
2737
|
+
pexprs$b.Apply.prototype.substituteParams = function(actuals) {
|
|
2735
2738
|
if (this.args.length === 0) {
|
|
2736
2739
|
// Avoid making a copy of this application, as an optimization
|
|
2737
2740
|
return this;
|
|
2738
2741
|
} else {
|
|
2739
2742
|
const args = this.args.map(arg => arg.substituteParams(actuals));
|
|
2740
|
-
return new pexprs$
|
|
2743
|
+
return new pexprs$b.Apply(this.ruleName, args);
|
|
2741
2744
|
}
|
|
2742
2745
|
};
|
|
2743
2746
|
|
|
@@ -2746,7 +2749,7 @@ pexprs$c.Apply.prototype.substituteParams = function(actuals) {
|
|
|
2746
2749
|
// --------------------------------------------------------------------
|
|
2747
2750
|
|
|
2748
2751
|
const common$8 = common$l;
|
|
2749
|
-
const pexprs$
|
|
2752
|
+
const pexprs$a = pexprsMain;
|
|
2750
2753
|
|
|
2751
2754
|
const {copyWithoutDuplicates} = common$8;
|
|
2752
2755
|
|
|
@@ -2812,17 +2815,17 @@ function resolveDuplicatedNames(argumentNameList) {
|
|
|
2812
2815
|
* e.getArity() === e.toArgumentNameList(1).length
|
|
2813
2816
|
*/
|
|
2814
2817
|
// function(firstArgIndex, noDupCheck) { ... }
|
|
2815
|
-
pexprs$
|
|
2818
|
+
pexprs$a.PExpr.prototype.toArgumentNameList = common$8.abstract('toArgumentNameList');
|
|
2816
2819
|
|
|
2817
|
-
pexprs$
|
|
2820
|
+
pexprs$a.any.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2818
2821
|
return ['any'];
|
|
2819
2822
|
};
|
|
2820
2823
|
|
|
2821
|
-
pexprs$
|
|
2824
|
+
pexprs$a.end.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2822
2825
|
return ['end'];
|
|
2823
2826
|
};
|
|
2824
2827
|
|
|
2825
|
-
pexprs$
|
|
2828
|
+
pexprs$a.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2826
2829
|
if (typeof this.obj === 'string' && /^[_a-zA-Z0-9]+$/.test(this.obj)) {
|
|
2827
2830
|
// If this terminal is a valid suffix for a JS identifier, just prepend it with '_'
|
|
2828
2831
|
return ['_' + this.obj];
|
|
@@ -2832,7 +2835,7 @@ pexprs$b.Terminal.prototype.toArgumentNameList = function(firstArgIndex, noDupCh
|
|
|
2832
2835
|
}
|
|
2833
2836
|
};
|
|
2834
2837
|
|
|
2835
|
-
pexprs$
|
|
2838
|
+
pexprs$a.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2836
2839
|
let argName = this.from + '_to_' + this.to;
|
|
2837
2840
|
// If the `argName` is not valid then try to prepend a `_`.
|
|
2838
2841
|
if (!isRestrictedJSIdentifier(argName)) {
|
|
@@ -2845,7 +2848,7 @@ pexprs$b.Range.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2845
2848
|
return [argName];
|
|
2846
2849
|
};
|
|
2847
2850
|
|
|
2848
|
-
pexprs$
|
|
2851
|
+
pexprs$a.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2849
2852
|
// `termArgNameLists` is an array of arrays where each row is the
|
|
2850
2853
|
// argument name list that corresponds to a term in this alternation.
|
|
2851
2854
|
const termArgNameLists = this.terms.map(term =>
|
|
@@ -2869,7 +2872,7 @@ pexprs$b.Alt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2869
2872
|
return argumentNameList;
|
|
2870
2873
|
};
|
|
2871
2874
|
|
|
2872
|
-
pexprs$
|
|
2875
|
+
pexprs$a.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2873
2876
|
// Generate the argument name list, without worrying about duplicates.
|
|
2874
2877
|
let argumentNameList = [];
|
|
2875
2878
|
this.factors.forEach(factor => {
|
|
@@ -2885,7 +2888,7 @@ pexprs$b.Seq.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2885
2888
|
return argumentNameList;
|
|
2886
2889
|
};
|
|
2887
2890
|
|
|
2888
|
-
pexprs$
|
|
2891
|
+
pexprs$a.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2889
2892
|
const argumentNameList = this.expr
|
|
2890
2893
|
.toArgumentNameList(firstArgIndex, noDupCheck)
|
|
2891
2894
|
.map(exprArgumentString =>
|
|
@@ -2899,30 +2902,30 @@ pexprs$b.Iter.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck)
|
|
|
2899
2902
|
return argumentNameList;
|
|
2900
2903
|
};
|
|
2901
2904
|
|
|
2902
|
-
pexprs$
|
|
2905
|
+
pexprs$a.Opt.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2903
2906
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck).map(argName => {
|
|
2904
2907
|
return 'opt' + argName[0].toUpperCase() + argName.slice(1);
|
|
2905
2908
|
});
|
|
2906
2909
|
};
|
|
2907
2910
|
|
|
2908
|
-
pexprs$
|
|
2911
|
+
pexprs$a.Not.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2909
2912
|
return [];
|
|
2910
2913
|
};
|
|
2911
2914
|
|
|
2912
|
-
pexprs$
|
|
2915
|
+
pexprs$a.Lookahead.prototype.toArgumentNameList = pexprs$a.Lex.prototype.toArgumentNameList =
|
|
2913
2916
|
function(firstArgIndex, noDupCheck) {
|
|
2914
2917
|
return this.expr.toArgumentNameList(firstArgIndex, noDupCheck);
|
|
2915
2918
|
};
|
|
2916
2919
|
|
|
2917
|
-
pexprs$
|
|
2920
|
+
pexprs$a.Apply.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2918
2921
|
return [this.ruleName];
|
|
2919
2922
|
};
|
|
2920
2923
|
|
|
2921
|
-
pexprs$
|
|
2924
|
+
pexprs$a.UnicodeChar.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2922
2925
|
return ['$' + firstArgIndex];
|
|
2923
2926
|
};
|
|
2924
2927
|
|
|
2925
|
-
pexprs$
|
|
2928
|
+
pexprs$a.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck) {
|
|
2926
2929
|
return ['param' + this.index];
|
|
2927
2930
|
};
|
|
2928
2931
|
|
|
@@ -2931,36 +2934,36 @@ pexprs$b.Param.prototype.toArgumentNameList = function(firstArgIndex, noDupCheck
|
|
|
2931
2934
|
// --------------------------------------------------------------------
|
|
2932
2935
|
|
|
2933
2936
|
const common$7 = common$l;
|
|
2934
|
-
const pexprs$
|
|
2937
|
+
const pexprs$9 = pexprsMain;
|
|
2935
2938
|
|
|
2936
2939
|
// --------------------------------------------------------------------
|
|
2937
2940
|
// Operations
|
|
2938
2941
|
// --------------------------------------------------------------------
|
|
2939
2942
|
|
|
2940
2943
|
// Returns a string representing the PExpr, for use as a UI label, etc.
|
|
2941
|
-
pexprs$
|
|
2944
|
+
pexprs$9.PExpr.prototype.toDisplayString = common$7.abstract('toDisplayString');
|
|
2942
2945
|
|
|
2943
|
-
pexprs$
|
|
2946
|
+
pexprs$9.Alt.prototype.toDisplayString = pexprs$9.Seq.prototype.toDisplayString = function() {
|
|
2944
2947
|
if (this.source) {
|
|
2945
2948
|
return this.source.trimmed().contents;
|
|
2946
2949
|
}
|
|
2947
2950
|
return '[' + this.constructor.name + ']';
|
|
2948
2951
|
};
|
|
2949
2952
|
|
|
2950
|
-
pexprs$
|
|
2951
|
-
pexprs$
|
|
2952
|
-
pexprs$
|
|
2953
|
-
pexprs$
|
|
2954
|
-
pexprs$
|
|
2955
|
-
pexprs$
|
|
2956
|
-
pexprs$
|
|
2957
|
-
pexprs$
|
|
2958
|
-
pexprs$
|
|
2953
|
+
pexprs$9.any.toDisplayString =
|
|
2954
|
+
pexprs$9.end.toDisplayString =
|
|
2955
|
+
pexprs$9.Iter.prototype.toDisplayString =
|
|
2956
|
+
pexprs$9.Not.prototype.toDisplayString =
|
|
2957
|
+
pexprs$9.Lookahead.prototype.toDisplayString =
|
|
2958
|
+
pexprs$9.Lex.prototype.toDisplayString =
|
|
2959
|
+
pexprs$9.Terminal.prototype.toDisplayString =
|
|
2960
|
+
pexprs$9.Range.prototype.toDisplayString =
|
|
2961
|
+
pexprs$9.Param.prototype.toDisplayString =
|
|
2959
2962
|
function() {
|
|
2960
2963
|
return this.toString();
|
|
2961
2964
|
};
|
|
2962
2965
|
|
|
2963
|
-
pexprs$
|
|
2966
|
+
pexprs$9.Apply.prototype.toDisplayString = function() {
|
|
2964
2967
|
if (this.args.length > 0) {
|
|
2965
2968
|
const ps = this.args.map(arg => arg.toDisplayString());
|
|
2966
2969
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -2969,7 +2972,7 @@ pexprs$a.Apply.prototype.toDisplayString = function() {
|
|
|
2969
2972
|
}
|
|
2970
2973
|
};
|
|
2971
2974
|
|
|
2972
|
-
pexprs$
|
|
2975
|
+
pexprs$9.UnicodeChar.prototype.toDisplayString = function() {
|
|
2973
2976
|
return 'Unicode [' + this.category + '] character';
|
|
2974
2977
|
};
|
|
2975
2978
|
|
|
@@ -2979,42 +2982,42 @@ pexprs$a.UnicodeChar.prototype.toDisplayString = function() {
|
|
|
2979
2982
|
|
|
2980
2983
|
const Failure$1 = Failure_1;
|
|
2981
2984
|
const common$6 = common$l;
|
|
2982
|
-
const pexprs$
|
|
2985
|
+
const pexprs$8 = pexprsMain;
|
|
2983
2986
|
|
|
2984
2987
|
// --------------------------------------------------------------------
|
|
2985
2988
|
// Operations
|
|
2986
2989
|
// --------------------------------------------------------------------
|
|
2987
2990
|
|
|
2988
|
-
pexprs$
|
|
2991
|
+
pexprs$8.PExpr.prototype.toFailure = common$6.abstract('toFailure');
|
|
2989
2992
|
|
|
2990
|
-
pexprs$
|
|
2993
|
+
pexprs$8.any.toFailure = function(grammar) {
|
|
2991
2994
|
return new Failure$1(this, 'any object', 'description');
|
|
2992
2995
|
};
|
|
2993
2996
|
|
|
2994
|
-
pexprs$
|
|
2997
|
+
pexprs$8.end.toFailure = function(grammar) {
|
|
2995
2998
|
return new Failure$1(this, 'end of input', 'description');
|
|
2996
2999
|
};
|
|
2997
3000
|
|
|
2998
|
-
pexprs$
|
|
3001
|
+
pexprs$8.Terminal.prototype.toFailure = function(grammar) {
|
|
2999
3002
|
return new Failure$1(this, this.obj, 'string');
|
|
3000
3003
|
};
|
|
3001
3004
|
|
|
3002
|
-
pexprs$
|
|
3005
|
+
pexprs$8.Range.prototype.toFailure = function(grammar) {
|
|
3003
3006
|
// TODO: come up with something better
|
|
3004
3007
|
return new Failure$1(this, JSON.stringify(this.from) + '..' + JSON.stringify(this.to), 'code');
|
|
3005
3008
|
};
|
|
3006
3009
|
|
|
3007
|
-
pexprs$
|
|
3010
|
+
pexprs$8.Not.prototype.toFailure = function(grammar) {
|
|
3008
3011
|
const description =
|
|
3009
|
-
this.expr === pexprs$
|
|
3012
|
+
this.expr === pexprs$8.any ? 'nothing' : 'not ' + this.expr.toFailure(grammar);
|
|
3010
3013
|
return new Failure$1(this, description, 'description');
|
|
3011
3014
|
};
|
|
3012
3015
|
|
|
3013
|
-
pexprs$
|
|
3016
|
+
pexprs$8.Lookahead.prototype.toFailure = function(grammar) {
|
|
3014
3017
|
return this.expr.toFailure(grammar);
|
|
3015
3018
|
};
|
|
3016
3019
|
|
|
3017
|
-
pexprs$
|
|
3020
|
+
pexprs$8.Apply.prototype.toFailure = function(grammar) {
|
|
3018
3021
|
let {description} = grammar.rules[this.ruleName];
|
|
3019
3022
|
if (!description) {
|
|
3020
3023
|
const article = /^[aeiouAEIOU]/.test(this.ruleName) ? 'an' : 'a';
|
|
@@ -3023,23 +3026,23 @@ pexprs$9.Apply.prototype.toFailure = function(grammar) {
|
|
|
3023
3026
|
return new Failure$1(this, description, 'description');
|
|
3024
3027
|
};
|
|
3025
3028
|
|
|
3026
|
-
pexprs$
|
|
3029
|
+
pexprs$8.UnicodeChar.prototype.toFailure = function(grammar) {
|
|
3027
3030
|
return new Failure$1(this, 'a Unicode [' + this.category + '] character', 'description');
|
|
3028
3031
|
};
|
|
3029
3032
|
|
|
3030
|
-
pexprs$
|
|
3033
|
+
pexprs$8.Alt.prototype.toFailure = function(grammar) {
|
|
3031
3034
|
const fs = this.terms.map(t => t.toFailure(grammar));
|
|
3032
3035
|
const description = '(' + fs.join(' or ') + ')';
|
|
3033
3036
|
return new Failure$1(this, description, 'description');
|
|
3034
3037
|
};
|
|
3035
3038
|
|
|
3036
|
-
pexprs$
|
|
3039
|
+
pexprs$8.Seq.prototype.toFailure = function(grammar) {
|
|
3037
3040
|
const fs = this.factors.map(f => f.toFailure(grammar));
|
|
3038
3041
|
const description = '(' + fs.join(' ') + ')';
|
|
3039
3042
|
return new Failure$1(this, description, 'description');
|
|
3040
3043
|
};
|
|
3041
3044
|
|
|
3042
|
-
pexprs$
|
|
3045
|
+
pexprs$8.Iter.prototype.toFailure = function(grammar) {
|
|
3043
3046
|
const description = '(' + this.expr.toFailure(grammar) + this.operator + ')';
|
|
3044
3047
|
return new Failure$1(this, description, 'description');
|
|
3045
3048
|
};
|
|
@@ -3049,7 +3052,7 @@ pexprs$9.Iter.prototype.toFailure = function(grammar) {
|
|
|
3049
3052
|
// --------------------------------------------------------------------
|
|
3050
3053
|
|
|
3051
3054
|
const common$5 = common$l;
|
|
3052
|
-
const pexprs$
|
|
3055
|
+
const pexprs$7 = pexprsMain;
|
|
3053
3056
|
|
|
3054
3057
|
// --------------------------------------------------------------------
|
|
3055
3058
|
// Operations
|
|
@@ -3062,57 +3065,57 @@ const pexprs$8 = pexprsMain;
|
|
|
3062
3065
|
~"b" "a" and "a" are interchangeable in any grammar,
|
|
3063
3066
|
both in terms of the languages they accept and their arities.
|
|
3064
3067
|
*/
|
|
3065
|
-
pexprs$
|
|
3068
|
+
pexprs$7.PExpr.prototype.toString = common$5.abstract('toString');
|
|
3066
3069
|
|
|
3067
|
-
pexprs$
|
|
3070
|
+
pexprs$7.any.toString = function() {
|
|
3068
3071
|
return 'any';
|
|
3069
3072
|
};
|
|
3070
3073
|
|
|
3071
|
-
pexprs$
|
|
3074
|
+
pexprs$7.end.toString = function() {
|
|
3072
3075
|
return 'end';
|
|
3073
3076
|
};
|
|
3074
3077
|
|
|
3075
|
-
pexprs$
|
|
3078
|
+
pexprs$7.Terminal.prototype.toString = function() {
|
|
3076
3079
|
return JSON.stringify(this.obj);
|
|
3077
3080
|
};
|
|
3078
3081
|
|
|
3079
|
-
pexprs$
|
|
3082
|
+
pexprs$7.Range.prototype.toString = function() {
|
|
3080
3083
|
return JSON.stringify(this.from) + '..' + JSON.stringify(this.to);
|
|
3081
3084
|
};
|
|
3082
3085
|
|
|
3083
|
-
pexprs$
|
|
3086
|
+
pexprs$7.Param.prototype.toString = function() {
|
|
3084
3087
|
return '$' + this.index;
|
|
3085
3088
|
};
|
|
3086
3089
|
|
|
3087
|
-
pexprs$
|
|
3090
|
+
pexprs$7.Lex.prototype.toString = function() {
|
|
3088
3091
|
return '#(' + this.expr.toString() + ')';
|
|
3089
3092
|
};
|
|
3090
3093
|
|
|
3091
|
-
pexprs$
|
|
3094
|
+
pexprs$7.Alt.prototype.toString = function() {
|
|
3092
3095
|
return this.terms.length === 1 ?
|
|
3093
3096
|
this.terms[0].toString() :
|
|
3094
3097
|
'(' + this.terms.map(term => term.toString()).join(' | ') + ')';
|
|
3095
3098
|
};
|
|
3096
3099
|
|
|
3097
|
-
pexprs$
|
|
3100
|
+
pexprs$7.Seq.prototype.toString = function() {
|
|
3098
3101
|
return this.factors.length === 1 ?
|
|
3099
3102
|
this.factors[0].toString() :
|
|
3100
3103
|
'(' + this.factors.map(factor => factor.toString()).join(' ') + ')';
|
|
3101
3104
|
};
|
|
3102
3105
|
|
|
3103
|
-
pexprs$
|
|
3106
|
+
pexprs$7.Iter.prototype.toString = function() {
|
|
3104
3107
|
return this.expr + this.operator;
|
|
3105
3108
|
};
|
|
3106
3109
|
|
|
3107
|
-
pexprs$
|
|
3110
|
+
pexprs$7.Not.prototype.toString = function() {
|
|
3108
3111
|
return '~' + this.expr;
|
|
3109
3112
|
};
|
|
3110
3113
|
|
|
3111
|
-
pexprs$
|
|
3114
|
+
pexprs$7.Lookahead.prototype.toString = function() {
|
|
3112
3115
|
return '&' + this.expr;
|
|
3113
3116
|
};
|
|
3114
3117
|
|
|
3115
|
-
pexprs$
|
|
3118
|
+
pexprs$7.Apply.prototype.toString = function() {
|
|
3116
3119
|
if (this.args.length > 0) {
|
|
3117
3120
|
const ps = this.args.map(arg => arg.toString());
|
|
3118
3121
|
return this.ruleName + '<' + ps.join(',') + '>';
|
|
@@ -3121,7 +3124,7 @@ pexprs$8.Apply.prototype.toString = function() {
|
|
|
3121
3124
|
}
|
|
3122
3125
|
};
|
|
3123
3126
|
|
|
3124
|
-
pexprs$
|
|
3127
|
+
pexprs$7.UnicodeChar.prototype.toString = function() {
|
|
3125
3128
|
return '\\p{' + this.category + '}';
|
|
3126
3129
|
};
|
|
3127
3130
|
|
|
@@ -3129,7 +3132,7 @@ pexprs$8.UnicodeChar.prototype.toString = function() {
|
|
|
3129
3132
|
// Re-export classes
|
|
3130
3133
|
// --------------------------------------------------------------------
|
|
3131
3134
|
|
|
3132
|
-
var pexprs$
|
|
3135
|
+
var pexprs$6 = pexprsMain;
|
|
3133
3136
|
|
|
3134
3137
|
// --------------------------------------------------------------------
|
|
3135
3138
|
// Imports
|
|
@@ -3138,7 +3141,7 @@ var pexprs$7 = pexprsMain;
|
|
|
3138
3141
|
const Failure = Failure_1;
|
|
3139
3142
|
const {TerminalNode} = nodes$1;
|
|
3140
3143
|
const {assert: assert$1} = common$l;
|
|
3141
|
-
const {PExpr, Terminal} = pexprs$
|
|
3144
|
+
const {PExpr, Terminal} = pexprs$6;
|
|
3142
3145
|
|
|
3143
3146
|
class CaseInsensitiveTerminal$1 extends PExpr {
|
|
3144
3147
|
constructor(param) {
|
|
@@ -3298,7 +3301,7 @@ const Interval = Interval_1;
|
|
|
3298
3301
|
// Private stuff
|
|
3299
3302
|
// --------------------------------------------------------------------
|
|
3300
3303
|
|
|
3301
|
-
function MatchResult$
|
|
3304
|
+
function MatchResult$2(
|
|
3302
3305
|
matcher,
|
|
3303
3306
|
input,
|
|
3304
3307
|
startExpr,
|
|
@@ -3332,19 +3335,19 @@ function MatchResult$3(
|
|
|
3332
3335
|
}
|
|
3333
3336
|
}
|
|
3334
3337
|
|
|
3335
|
-
MatchResult$
|
|
3338
|
+
MatchResult$2.prototype.succeeded = function() {
|
|
3336
3339
|
return !!this._cst;
|
|
3337
3340
|
};
|
|
3338
3341
|
|
|
3339
|
-
MatchResult$
|
|
3342
|
+
MatchResult$2.prototype.failed = function() {
|
|
3340
3343
|
return !this.succeeded();
|
|
3341
3344
|
};
|
|
3342
3345
|
|
|
3343
|
-
MatchResult$
|
|
3346
|
+
MatchResult$2.prototype.getRightmostFailurePosition = function() {
|
|
3344
3347
|
return this._rightmostFailurePosition;
|
|
3345
3348
|
};
|
|
3346
3349
|
|
|
3347
|
-
MatchResult$
|
|
3350
|
+
MatchResult$2.prototype.getRightmostFailures = function() {
|
|
3348
3351
|
if (!this._rightmostFailures) {
|
|
3349
3352
|
this.matcher.setInput(this.input);
|
|
3350
3353
|
const matchResultWithFailures = this.matcher._match(
|
|
@@ -3357,7 +3360,7 @@ MatchResult$3.prototype.getRightmostFailures = function() {
|
|
|
3357
3360
|
return this._rightmostFailures;
|
|
3358
3361
|
};
|
|
3359
3362
|
|
|
3360
|
-
MatchResult$
|
|
3363
|
+
MatchResult$2.prototype.toString = function() {
|
|
3361
3364
|
return this.succeeded() ?
|
|
3362
3365
|
'[match succeeded]' :
|
|
3363
3366
|
'[match failed at position ' + this.getRightmostFailurePosition() + ']';
|
|
@@ -3365,7 +3368,7 @@ MatchResult$3.prototype.toString = function() {
|
|
|
3365
3368
|
|
|
3366
3369
|
// Return a string summarizing the expected contents of the input stream when
|
|
3367
3370
|
// the match failure occurred.
|
|
3368
|
-
MatchResult$
|
|
3371
|
+
MatchResult$2.prototype.getExpectedText = function() {
|
|
3369
3372
|
if (this.succeeded()) {
|
|
3370
3373
|
throw new Error('cannot get expected text of a successful MatchResult');
|
|
3371
3374
|
}
|
|
@@ -3389,7 +3392,7 @@ MatchResult$3.prototype.getExpectedText = function() {
|
|
|
3389
3392
|
return sb.contents();
|
|
3390
3393
|
};
|
|
3391
3394
|
|
|
3392
|
-
MatchResult$
|
|
3395
|
+
MatchResult$2.prototype.getInterval = function() {
|
|
3393
3396
|
const pos = this.getRightmostFailurePosition();
|
|
3394
3397
|
return new Interval(this.input, pos, pos);
|
|
3395
3398
|
};
|
|
@@ -3398,7 +3401,7 @@ MatchResult$3.prototype.getInterval = function() {
|
|
|
3398
3401
|
// Exports
|
|
3399
3402
|
// --------------------------------------------------------------------
|
|
3400
3403
|
|
|
3401
|
-
var MatchResult_1 = MatchResult$
|
|
3404
|
+
var MatchResult_1 = MatchResult$2;
|
|
3402
3405
|
|
|
3403
3406
|
// --------------------------------------------------------------------
|
|
3404
3407
|
// Private stuff
|
|
@@ -3518,10 +3521,10 @@ var PosInfo_1 = PosInfo$1;
|
|
|
3518
3521
|
// --------------------------------------------------------------------
|
|
3519
3522
|
|
|
3520
3523
|
const InputStream$2 = InputStream_1;
|
|
3521
|
-
const MatchResult$
|
|
3524
|
+
const MatchResult$1 = MatchResult_1;
|
|
3522
3525
|
const PosInfo = PosInfo_1;
|
|
3523
3526
|
const Trace = Trace_1;
|
|
3524
|
-
const pexprs$
|
|
3527
|
+
const pexprs$5 = pexprs$6;
|
|
3525
3528
|
const util$3 = util$7;
|
|
3526
3529
|
|
|
3527
3530
|
// --------------------------------------------------------------------
|
|
@@ -3534,7 +3537,7 @@ util$3.awaitBuiltInRules(builtInRules => {
|
|
|
3534
3537
|
builtInApplySyntacticBody = builtInRules.rules.applySyntactic.body;
|
|
3535
3538
|
});
|
|
3536
3539
|
|
|
3537
|
-
const applySpaces = new pexprs$
|
|
3540
|
+
const applySpaces = new pexprs$5.Apply('spaces');
|
|
3538
3541
|
|
|
3539
3542
|
function MatchState$1(matcher, startExpr, optPositionToRecordFailures) {
|
|
3540
3543
|
this.matcher = matcher;
|
|
@@ -3740,7 +3743,7 @@ MatchState$1.prototype = {
|
|
|
3740
3743
|
|
|
3741
3744
|
// Returns a new trace entry, with the currently active trace array as its children.
|
|
3742
3745
|
getTraceEntry(pos, expr, succeeded, bindings) {
|
|
3743
|
-
if (expr instanceof pexprs$
|
|
3746
|
+
if (expr instanceof pexprs$5.Apply) {
|
|
3744
3747
|
const app = this.currentApplication();
|
|
3745
3748
|
const actuals = app ? app.args : [];
|
|
3746
3749
|
expr = expr.substituteParams(actuals);
|
|
@@ -3869,7 +3872,7 @@ MatchState$1.prototype = {
|
|
|
3869
3872
|
key => this.recordedFailures[key]
|
|
3870
3873
|
);
|
|
3871
3874
|
}
|
|
3872
|
-
return new MatchResult$
|
|
3875
|
+
return new MatchResult$1(
|
|
3873
3876
|
this.matcher,
|
|
3874
3877
|
this.input,
|
|
3875
3878
|
this.startExpr,
|
|
@@ -3916,7 +3919,7 @@ var MatchState_1 = MatchState$1;
|
|
|
3916
3919
|
|
|
3917
3920
|
const MatchState = MatchState_1;
|
|
3918
3921
|
|
|
3919
|
-
const pexprs$
|
|
3922
|
+
const pexprs$4 = pexprs$6;
|
|
3920
3923
|
|
|
3921
3924
|
// --------------------------------------------------------------------
|
|
3922
3925
|
// Private stuff
|
|
@@ -4000,7 +4003,7 @@ Matcher$1.prototype._getStartExpr = function(optStartApplicationStr) {
|
|
|
4000
4003
|
}
|
|
4001
4004
|
|
|
4002
4005
|
const startApp = this.grammar.parseApplication(applicationStr);
|
|
4003
|
-
return new pexprs$
|
|
4006
|
+
return new pexprs$4.Seq([startApp, pexprs$4.end]);
|
|
4004
4007
|
};
|
|
4005
4008
|
|
|
4006
4009
|
// --------------------------------------------------------------------
|
|
@@ -4015,7 +4018,7 @@ var Matcher_1 = Matcher$1;
|
|
|
4015
4018
|
|
|
4016
4019
|
const InputStream$1 = InputStream_1;
|
|
4017
4020
|
const {IterationNode} = nodes$1;
|
|
4018
|
-
const MatchResult
|
|
4021
|
+
const MatchResult = MatchResult_1;
|
|
4019
4022
|
const common$3 = common$l;
|
|
4020
4023
|
const errors$3 = errors$9;
|
|
4021
4024
|
const util$2 = util$7;
|
|
@@ -4544,7 +4547,7 @@ Semantics$2.createSemantics = function(grammar, optSuperSemantics) {
|
|
|
4544
4547
|
// To enable clients to invoke a semantics like a function, return a function that acts as a proxy
|
|
4545
4548
|
// for `s`, which is the real `Semantics` instance.
|
|
4546
4549
|
const proxy = function ASemantics(matchResult) {
|
|
4547
|
-
if (!(matchResult instanceof MatchResult
|
|
4550
|
+
if (!(matchResult instanceof MatchResult)) {
|
|
4548
4551
|
throw new TypeError(
|
|
4549
4552
|
'Semantics expected a MatchResult, but got ' +
|
|
4550
4553
|
common$3.unexpectedObjToString(matchResult)
|
|
@@ -4728,7 +4731,7 @@ const Matcher = Matcher_1;
|
|
|
4728
4731
|
const Semantics$1 = Semantics_1;
|
|
4729
4732
|
const common$2 = common$l;
|
|
4730
4733
|
const errors$2 = errors$9;
|
|
4731
|
-
const pexprs$
|
|
4734
|
+
const pexprs$3 = pexprs$6;
|
|
4732
4735
|
|
|
4733
4736
|
// --------------------------------------------------------------------
|
|
4734
4737
|
// Private stuff
|
|
@@ -4749,7 +4752,7 @@ function getSortedRuleValues(grammar) {
|
|
|
4749
4752
|
// See https://v8.dev/features/subsume-json for more details.
|
|
4750
4753
|
const jsonToJS = str => str.replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
4751
4754
|
|
|
4752
|
-
function Grammar$
|
|
4755
|
+
function Grammar$4(name, superGrammar, rules, optDefaultStartRule) {
|
|
4753
4756
|
this.name = name;
|
|
4754
4757
|
this.superGrammar = superGrammar;
|
|
4755
4758
|
this.rules = rules;
|
|
@@ -4771,12 +4774,12 @@ let ohmGrammar$2;
|
|
|
4771
4774
|
let buildGrammar$1;
|
|
4772
4775
|
|
|
4773
4776
|
// This method is called from main.js once Ohm has loaded.
|
|
4774
|
-
Grammar$
|
|
4777
|
+
Grammar$4.initApplicationParser = function(grammar, builderFn) {
|
|
4775
4778
|
ohmGrammar$2 = grammar;
|
|
4776
4779
|
buildGrammar$1 = builderFn;
|
|
4777
4780
|
};
|
|
4778
4781
|
|
|
4779
|
-
Grammar$
|
|
4782
|
+
Grammar$4.prototype = {
|
|
4780
4783
|
matcher() {
|
|
4781
4784
|
return new Matcher(this);
|
|
4782
4785
|
},
|
|
@@ -4784,7 +4787,7 @@ Grammar$5.prototype = {
|
|
|
4784
4787
|
// Return true if the grammar is a built-in grammar, otherwise false.
|
|
4785
4788
|
// NOTE: This might give an unexpected result if called before BuiltInRules is defined!
|
|
4786
4789
|
isBuiltIn() {
|
|
4787
|
-
return this === Grammar$
|
|
4790
|
+
return this === Grammar$4.ProtoBuiltInRules || this === Grammar$4.BuiltInRules;
|
|
4788
4791
|
},
|
|
4789
4792
|
|
|
4790
4793
|
equals(g) {
|
|
@@ -4923,7 +4926,7 @@ Grammar$5.prototype = {
|
|
|
4923
4926
|
if (isDefinition) {
|
|
4924
4927
|
operation = 'define';
|
|
4925
4928
|
} else {
|
|
4926
|
-
operation = body instanceof pexprs$
|
|
4929
|
+
operation = body instanceof pexprs$3.Extend ? 'extend' : 'override';
|
|
4927
4930
|
}
|
|
4928
4931
|
|
|
4929
4932
|
const metaInfo = {};
|
|
@@ -5010,7 +5013,7 @@ Grammar$5.prototype = {
|
|
|
5010
5013
|
let app;
|
|
5011
5014
|
if (str.indexOf('<') === -1) {
|
|
5012
5015
|
// simple application
|
|
5013
|
-
app = new pexprs$
|
|
5016
|
+
app = new pexprs$3.Apply(str);
|
|
5014
5017
|
} else {
|
|
5015
5018
|
// parameterized application
|
|
5016
5019
|
const cst = ohmGrammar$2.match(str, 'Base_application');
|
|
@@ -5040,43 +5043,43 @@ Grammar$5.prototype = {
|
|
|
5040
5043
|
// `BuiltInRules`. That grammar contains several convenience rules, e.g., `letter` and
|
|
5041
5044
|
// `digit`, and is implicitly the super-grammar of any grammar whose super-grammar
|
|
5042
5045
|
// isn't specified.
|
|
5043
|
-
Grammar$
|
|
5046
|
+
Grammar$4.ProtoBuiltInRules = new Grammar$4(
|
|
5044
5047
|
'ProtoBuiltInRules', // name
|
|
5045
5048
|
undefined, // supergrammar
|
|
5046
5049
|
{
|
|
5047
5050
|
any: {
|
|
5048
|
-
body: pexprs$
|
|
5051
|
+
body: pexprs$3.any,
|
|
5049
5052
|
formals: [],
|
|
5050
5053
|
description: 'any character',
|
|
5051
5054
|
primitive: true,
|
|
5052
5055
|
},
|
|
5053
5056
|
end: {
|
|
5054
|
-
body: pexprs$
|
|
5057
|
+
body: pexprs$3.end,
|
|
5055
5058
|
formals: [],
|
|
5056
5059
|
description: 'end of input',
|
|
5057
5060
|
primitive: true,
|
|
5058
5061
|
},
|
|
5059
5062
|
|
|
5060
5063
|
caseInsensitive: {
|
|
5061
|
-
body: new CaseInsensitiveTerminal(new pexprs$
|
|
5064
|
+
body: new CaseInsensitiveTerminal(new pexprs$3.Param(0)),
|
|
5062
5065
|
formals: ['str'],
|
|
5063
5066
|
primitive: true,
|
|
5064
5067
|
},
|
|
5065
5068
|
lower: {
|
|
5066
|
-
body: new pexprs$
|
|
5069
|
+
body: new pexprs$3.UnicodeChar('Ll'),
|
|
5067
5070
|
formals: [],
|
|
5068
5071
|
description: 'a lowercase letter',
|
|
5069
5072
|
primitive: true,
|
|
5070
5073
|
},
|
|
5071
5074
|
upper: {
|
|
5072
|
-
body: new pexprs$
|
|
5075
|
+
body: new pexprs$3.UnicodeChar('Lu'),
|
|
5073
5076
|
formals: [],
|
|
5074
5077
|
description: 'an uppercase letter',
|
|
5075
5078
|
primitive: true,
|
|
5076
5079
|
},
|
|
5077
5080
|
// Union of Lt (titlecase), Lm (modifier), and Lo (other), i.e. any letter not in Ll or Lu.
|
|
5078
5081
|
unicodeLtmo: {
|
|
5079
|
-
body: new pexprs$
|
|
5082
|
+
body: new pexprs$3.UnicodeChar('Ltmo'),
|
|
5080
5083
|
formals: [],
|
|
5081
5084
|
description: 'a Unicode character in Lt, Lm, or Lo',
|
|
5082
5085
|
primitive: true,
|
|
@@ -5085,11 +5088,11 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5085
5088
|
// These rules are not truly primitive (they could be written in userland) but are defined
|
|
5086
5089
|
// here for bootstrapping purposes.
|
|
5087
5090
|
spaces: {
|
|
5088
|
-
body: new pexprs$
|
|
5091
|
+
body: new pexprs$3.Star(new pexprs$3.Apply('space')),
|
|
5089
5092
|
formals: [],
|
|
5090
5093
|
},
|
|
5091
5094
|
space: {
|
|
5092
|
-
body: new pexprs$
|
|
5095
|
+
body: new pexprs$3.Range('\x00', ' '),
|
|
5093
5096
|
formals: [],
|
|
5094
5097
|
description: 'a space',
|
|
5095
5098
|
},
|
|
@@ -5100,17 +5103,17 @@ Grammar$5.ProtoBuiltInRules = new Grammar$5(
|
|
|
5100
5103
|
// Exports
|
|
5101
5104
|
// --------------------------------------------------------------------
|
|
5102
5105
|
|
|
5103
|
-
var Grammar_1 = Grammar$
|
|
5106
|
+
var Grammar_1 = Grammar$4;
|
|
5104
5107
|
|
|
5105
5108
|
// --------------------------------------------------------------------
|
|
5106
5109
|
// Imports
|
|
5107
5110
|
// --------------------------------------------------------------------
|
|
5108
5111
|
|
|
5109
|
-
const Grammar$
|
|
5112
|
+
const Grammar$3 = Grammar_1;
|
|
5110
5113
|
const InputStream = InputStream_1;
|
|
5111
5114
|
const common$1 = common$l;
|
|
5112
5115
|
const errors$1 = errors$9;
|
|
5113
|
-
const pexprs$
|
|
5116
|
+
const pexprs$2 = pexprs$6;
|
|
5114
5117
|
|
|
5115
5118
|
// --------------------------------------------------------------------
|
|
5116
5119
|
// Private Stuff
|
|
@@ -5134,7 +5137,7 @@ GrammarDecl$1.prototype.ensureSuperGrammar = function() {
|
|
|
5134
5137
|
// TODO: The conditional expression below is an ugly hack. It's kind of ok because
|
|
5135
5138
|
// I doubt anyone will ever try to declare a grammar called `BuiltInRules`. Still,
|
|
5136
5139
|
// we should try to find a better way to do this.
|
|
5137
|
-
this.name === 'BuiltInRules' ? Grammar$
|
|
5140
|
+
this.name === 'BuiltInRules' ? Grammar$3.ProtoBuiltInRules : Grammar$3.BuiltInRules
|
|
5138
5141
|
);
|
|
5139
5142
|
}
|
|
5140
5143
|
return this.superGrammar;
|
|
@@ -5205,7 +5208,7 @@ GrammarDecl$1.prototype.withSource = function(source) {
|
|
|
5205
5208
|
|
|
5206
5209
|
// Creates a Grammar instance, and if it passes the sanity checks, returns it.
|
|
5207
5210
|
GrammarDecl$1.prototype.build = function() {
|
|
5208
|
-
const grammar = new Grammar$
|
|
5211
|
+
const grammar = new Grammar$3(
|
|
5209
5212
|
this.name,
|
|
5210
5213
|
this.ensureSuperGrammar(),
|
|
5211
5214
|
this.rules,
|
|
@@ -5281,7 +5284,7 @@ GrammarDecl$1.prototype.extend = function(name, formals, fragment, descIgnored,
|
|
|
5281
5284
|
if (!ruleInfo) {
|
|
5282
5285
|
throw errors$1.cannotExtendUndeclaredRule(name, this.superGrammar.name, source);
|
|
5283
5286
|
}
|
|
5284
|
-
const body = new pexprs$
|
|
5287
|
+
const body = new pexprs$2.Extend(this.superGrammar, name, fragment);
|
|
5285
5288
|
body.source = fragment.source;
|
|
5286
5289
|
this.installOverriddenOrExtendedRule(name, formals, body, source);
|
|
5287
5290
|
return this;
|
|
@@ -5297,9 +5300,9 @@ var GrammarDecl_1 = GrammarDecl$1;
|
|
|
5297
5300
|
// Imports
|
|
5298
5301
|
// --------------------------------------------------------------------
|
|
5299
5302
|
|
|
5300
|
-
const Grammar$
|
|
5303
|
+
const Grammar$2 = Grammar_1;
|
|
5301
5304
|
const GrammarDecl = GrammarDecl_1;
|
|
5302
|
-
const pexprs$
|
|
5305
|
+
const pexprs$1 = pexprs$6;
|
|
5303
5306
|
|
|
5304
5307
|
// --------------------------------------------------------------------
|
|
5305
5308
|
// Private stuff
|
|
@@ -5320,7 +5323,7 @@ Builder$2.prototype = {
|
|
|
5320
5323
|
if (superGrammar) {
|
|
5321
5324
|
// `superGrammar` may be a recipe (i.e. an Array), or an actual grammar instance.
|
|
5322
5325
|
gDecl.withSuperGrammar(
|
|
5323
|
-
superGrammar instanceof Grammar$
|
|
5326
|
+
superGrammar instanceof Grammar$2 ? superGrammar : this.fromRecipe(superGrammar)
|
|
5324
5327
|
);
|
|
5325
5328
|
}
|
|
5326
5329
|
if (defaultStartRule) {
|
|
@@ -5355,73 +5358,73 @@ Builder$2.prototype = {
|
|
|
5355
5358
|
},
|
|
5356
5359
|
|
|
5357
5360
|
terminal(x) {
|
|
5358
|
-
return new pexprs$
|
|
5361
|
+
return new pexprs$1.Terminal(x);
|
|
5359
5362
|
},
|
|
5360
5363
|
|
|
5361
5364
|
range(from, to) {
|
|
5362
|
-
return new pexprs$
|
|
5365
|
+
return new pexprs$1.Range(from, to);
|
|
5363
5366
|
},
|
|
5364
5367
|
|
|
5365
5368
|
param(index) {
|
|
5366
|
-
return new pexprs$
|
|
5369
|
+
return new pexprs$1.Param(index);
|
|
5367
5370
|
},
|
|
5368
5371
|
|
|
5369
5372
|
alt(...termArgs) {
|
|
5370
5373
|
let terms = [];
|
|
5371
5374
|
for (let arg of termArgs) {
|
|
5372
|
-
if (!(arg instanceof pexprs$
|
|
5375
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5373
5376
|
arg = this.fromRecipe(arg);
|
|
5374
5377
|
}
|
|
5375
|
-
if (arg instanceof pexprs$
|
|
5378
|
+
if (arg instanceof pexprs$1.Alt) {
|
|
5376
5379
|
terms = terms.concat(arg.terms);
|
|
5377
5380
|
} else {
|
|
5378
5381
|
terms.push(arg);
|
|
5379
5382
|
}
|
|
5380
5383
|
}
|
|
5381
|
-
return terms.length === 1 ? terms[0] : new pexprs$
|
|
5384
|
+
return terms.length === 1 ? terms[0] : new pexprs$1.Alt(terms);
|
|
5382
5385
|
},
|
|
5383
5386
|
|
|
5384
5387
|
seq(...factorArgs) {
|
|
5385
5388
|
let factors = [];
|
|
5386
5389
|
for (let arg of factorArgs) {
|
|
5387
|
-
if (!(arg instanceof pexprs$
|
|
5390
|
+
if (!(arg instanceof pexprs$1.PExpr)) {
|
|
5388
5391
|
arg = this.fromRecipe(arg);
|
|
5389
5392
|
}
|
|
5390
|
-
if (arg instanceof pexprs$
|
|
5393
|
+
if (arg instanceof pexprs$1.Seq) {
|
|
5391
5394
|
factors = factors.concat(arg.factors);
|
|
5392
5395
|
} else {
|
|
5393
5396
|
factors.push(arg);
|
|
5394
5397
|
}
|
|
5395
5398
|
}
|
|
5396
|
-
return factors.length === 1 ? factors[0] : new pexprs$
|
|
5399
|
+
return factors.length === 1 ? factors[0] : new pexprs$1.Seq(factors);
|
|
5397
5400
|
},
|
|
5398
5401
|
|
|
5399
5402
|
star(expr) {
|
|
5400
|
-
if (!(expr instanceof pexprs$
|
|
5403
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5401
5404
|
expr = this.fromRecipe(expr);
|
|
5402
5405
|
}
|
|
5403
|
-
return new pexprs$
|
|
5406
|
+
return new pexprs$1.Star(expr);
|
|
5404
5407
|
},
|
|
5405
5408
|
|
|
5406
5409
|
plus(expr) {
|
|
5407
|
-
if (!(expr instanceof pexprs$
|
|
5410
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5408
5411
|
expr = this.fromRecipe(expr);
|
|
5409
5412
|
}
|
|
5410
|
-
return new pexprs$
|
|
5413
|
+
return new pexprs$1.Plus(expr);
|
|
5411
5414
|
},
|
|
5412
5415
|
|
|
5413
5416
|
opt(expr) {
|
|
5414
|
-
if (!(expr instanceof pexprs$
|
|
5417
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5415
5418
|
expr = this.fromRecipe(expr);
|
|
5416
5419
|
}
|
|
5417
|
-
return new pexprs$
|
|
5420
|
+
return new pexprs$1.Opt(expr);
|
|
5418
5421
|
},
|
|
5419
5422
|
|
|
5420
5423
|
not(expr) {
|
|
5421
|
-
if (!(expr instanceof pexprs$
|
|
5424
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5422
5425
|
expr = this.fromRecipe(expr);
|
|
5423
5426
|
}
|
|
5424
|
-
return new pexprs$
|
|
5427
|
+
return new pexprs$1.Not(expr);
|
|
5425
5428
|
},
|
|
5426
5429
|
|
|
5427
5430
|
la(expr) {
|
|
@@ -5430,33 +5433,33 @@ Builder$2.prototype = {
|
|
|
5430
5433
|
},
|
|
5431
5434
|
|
|
5432
5435
|
lookahead(expr) {
|
|
5433
|
-
if (!(expr instanceof pexprs$
|
|
5436
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5434
5437
|
expr = this.fromRecipe(expr);
|
|
5435
5438
|
}
|
|
5436
|
-
return new pexprs$
|
|
5439
|
+
return new pexprs$1.Lookahead(expr);
|
|
5437
5440
|
},
|
|
5438
5441
|
|
|
5439
5442
|
lex(expr) {
|
|
5440
|
-
if (!(expr instanceof pexprs$
|
|
5443
|
+
if (!(expr instanceof pexprs$1.PExpr)) {
|
|
5441
5444
|
expr = this.fromRecipe(expr);
|
|
5442
5445
|
}
|
|
5443
|
-
return new pexprs$
|
|
5446
|
+
return new pexprs$1.Lex(expr);
|
|
5444
5447
|
},
|
|
5445
5448
|
|
|
5446
5449
|
app(ruleName, optParams) {
|
|
5447
5450
|
if (optParams && optParams.length > 0) {
|
|
5448
5451
|
optParams = optParams.map(function(param) {
|
|
5449
|
-
return param instanceof pexprs$
|
|
5452
|
+
return param instanceof pexprs$1.PExpr ? param : this.fromRecipe(param);
|
|
5450
5453
|
}, this);
|
|
5451
5454
|
}
|
|
5452
|
-
return new pexprs$
|
|
5455
|
+
return new pexprs$1.Apply(ruleName, optParams);
|
|
5453
5456
|
},
|
|
5454
5457
|
|
|
5455
5458
|
// Note that unlike other methods in this class, this method cannot be used as a
|
|
5456
5459
|
// convenience constructor. It only works with recipes, because it relies on
|
|
5457
5460
|
// `this.currentDecl` and `this.currentRuleName` being set.
|
|
5458
5461
|
splice(beforeTerms, afterTerms) {
|
|
5459
|
-
return new pexprs$
|
|
5462
|
+
return new pexprs$1.Splice(
|
|
5460
5463
|
this.currentDecl.superGrammar,
|
|
5461
5464
|
this.currentRuleName,
|
|
5462
5465
|
beforeTerms.map(term => this.fromRecipe(term)),
|
|
@@ -5486,7 +5489,7 @@ Builder$2.prototype = {
|
|
|
5486
5489
|
var Builder_1 = Builder$2;
|
|
5487
5490
|
|
|
5488
5491
|
var name = "ohm-js";
|
|
5489
|
-
var version$2 = "16.3.
|
|
5492
|
+
var version$2 = "16.3.1";
|
|
5490
5493
|
var description = "An object-oriented language for parsing and pattern matching";
|
|
5491
5494
|
var repository = "https://github.com/harc/ohm";
|
|
5492
5495
|
var keywords = [
|
|
@@ -5501,7 +5504,7 @@ var keywords = [
|
|
|
5501
5504
|
"rapid",
|
|
5502
5505
|
"prototyping"
|
|
5503
5506
|
];
|
|
5504
|
-
var homepage = "https://
|
|
5507
|
+
var homepage = "https://ohmjs.org";
|
|
5505
5508
|
var bugs = "https://github.com/harc/ohm/issues";
|
|
5506
5509
|
var main = "index.js";
|
|
5507
5510
|
var module = "dist/ohm.esm.js";
|
|
@@ -5674,13 +5677,13 @@ var builtInRules = makeRecipe$3(["grammar",{"source":"BuiltInRules {\n\n alnum
|
|
|
5674
5677
|
// Imports
|
|
5675
5678
|
// --------------------------------------------------------------------
|
|
5676
5679
|
|
|
5677
|
-
const Grammar$
|
|
5680
|
+
const Grammar$1 = Grammar_1;
|
|
5678
5681
|
|
|
5679
5682
|
// --------------------------------------------------------------------
|
|
5680
5683
|
// Private stuff
|
|
5681
5684
|
// --------------------------------------------------------------------
|
|
5682
5685
|
|
|
5683
|
-
Grammar$
|
|
5686
|
+
Grammar$1.BuiltInRules = builtInRules;
|
|
5684
5687
|
|
|
5685
5688
|
var {makeRecipe: makeRecipe$2} = makeRecipe$5;
|
|
5686
5689
|
var operationsAndAttributes = makeRecipe$2(["grammar",{"source":"OperationsAndAttributes {\n\n AttributeSignature =\n name\n\n OperationSignature =\n name Formals?\n\n Formals\n = \"(\" ListOf<name, \",\"> \")\"\n\n name (a name)\n = nameFirst nameRest*\n\n nameFirst\n = \"_\"\n | letter\n\n nameRest\n = \"_\"\n | alnum\n\n}"},"OperationsAndAttributes",null,"AttributeSignature",{"AttributeSignature":["define",{"sourceInterval":[29,58]},null,[],["app",{"sourceInterval":[54,58]},"name",[]]],"OperationSignature":["define",{"sourceInterval":[62,100]},null,[],["seq",{"sourceInterval":[87,100]},["app",{"sourceInterval":[87,91]},"name",[]],["opt",{"sourceInterval":[92,100]},["app",{"sourceInterval":[92,99]},"Formals",[]]]]],"Formals":["define",{"sourceInterval":[104,143]},null,[],["seq",{"sourceInterval":[118,143]},["terminal",{"sourceInterval":[118,121]},"("],["app",{"sourceInterval":[122,139]},"ListOf",[["app",{"sourceInterval":[129,133]},"name",[]],["terminal",{"sourceInterval":[135,138]},","]]],["terminal",{"sourceInterval":[140,143]},")"]]],"name":["define",{"sourceInterval":[147,187]},"a name",[],["seq",{"sourceInterval":[168,187]},["app",{"sourceInterval":[168,177]},"nameFirst",[]],["star",{"sourceInterval":[178,187]},["app",{"sourceInterval":[178,186]},"nameRest",[]]]]],"nameFirst":["define",{"sourceInterval":[191,223]},null,[],["alt",{"sourceInterval":[207,223]},["terminal",{"sourceInterval":[207,210]},"_"],["app",{"sourceInterval":[217,223]},"letter",[]]]],"nameRest":["define",{"sourceInterval":[227,257]},null,[],["alt",{"sourceInterval":[242,257]},["terminal",{"sourceInterval":[242,245]},"_"],["app",{"sourceInterval":[252,257]},"alnum",[]]]]}]);
|
|
@@ -5753,11 +5756,11 @@ var ohmGrammar$1 = makeRecipe$1(["grammar",{"source":"Ohm {\n\n Grammars\n =
|
|
|
5753
5756
|
// --------------------------------------------------------------------
|
|
5754
5757
|
|
|
5755
5758
|
const Builder = Builder_1;
|
|
5756
|
-
const Grammar
|
|
5759
|
+
const Grammar = Grammar_1;
|
|
5757
5760
|
const Namespace = Namespace_1;
|
|
5758
5761
|
const common = common$l;
|
|
5759
5762
|
const errors = errors$9;
|
|
5760
|
-
const pexprs
|
|
5763
|
+
const pexprs = pexprs$6;
|
|
5761
5764
|
const util = util$7;
|
|
5762
5765
|
const version = version$1;
|
|
5763
5766
|
const {makeRecipe} = makeRecipe$5;
|
|
@@ -5770,7 +5773,7 @@ const {makeRecipe} = makeRecipe$5;
|
|
|
5770
5773
|
// bottom of this file because loading the grammar requires Ohm itself.
|
|
5771
5774
|
let ohmGrammar;
|
|
5772
5775
|
|
|
5773
|
-
const superSplicePlaceholder = Object.create(pexprs
|
|
5776
|
+
const superSplicePlaceholder = Object.create(pexprs.PExpr.prototype);
|
|
5774
5777
|
|
|
5775
5778
|
const isBuffer = obj =>
|
|
5776
5779
|
!!obj.constructor &&
|
|
@@ -5825,7 +5828,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5825
5828
|
currentRuleFormals = fs.children.map(c => c.visit())[0] || [];
|
|
5826
5829
|
// If there is no default start rule yet, set it now. This must be done before visiting
|
|
5827
5830
|
// the body, because it might contain an inline rule definition.
|
|
5828
|
-
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar
|
|
5831
|
+
if (!decl.defaultStartRule && decl.ensureSuperGrammar() !== Grammar.ProtoBuiltInRules) {
|
|
5829
5832
|
decl.withDefaultStartRule(currentRuleName);
|
|
5830
5833
|
}
|
|
5831
5834
|
const body = b.visit();
|
|
@@ -5869,7 +5872,7 @@ function buildGrammar(match, namespace, optOhmGrammarForTesting) {
|
|
|
5869
5872
|
if (t === superSplicePlaceholder) throw errors.multipleSuperSplices(t);
|
|
5870
5873
|
});
|
|
5871
5874
|
|
|
5872
|
-
return new pexprs
|
|
5875
|
+
return new pexprs.Splice(
|
|
5873
5876
|
decl.superGrammar,
|
|
5874
5877
|
currentRuleName,
|
|
5875
5878
|
beforeTerms,
|
|
@@ -6066,7 +6069,7 @@ main$1.exports = {
|
|
|
6066
6069
|
grammarsFromScriptElements,
|
|
6067
6070
|
makeRecipe,
|
|
6068
6071
|
ohmGrammar: null, // Initialized below, after Grammar.BuiltInRules.
|
|
6069
|
-
pexprs
|
|
6072
|
+
pexprs,
|
|
6070
6073
|
util,
|
|
6071
6074
|
version,
|
|
6072
6075
|
};
|
|
@@ -6077,10 +6080,10 @@ main$1.exports._buildGrammar = buildGrammar;
|
|
|
6077
6080
|
// Late initialization for stuff that is bootstrapped.
|
|
6078
6081
|
|
|
6079
6082
|
|
|
6080
|
-
util.announceBuiltInRules(Grammar
|
|
6083
|
+
util.announceBuiltInRules(Grammar.BuiltInRules);
|
|
6081
6084
|
|
|
6082
6085
|
main$1.exports.ohmGrammar = ohmGrammar = ohmGrammar$1;
|
|
6083
|
-
Grammar
|
|
6086
|
+
Grammar.initApplicationParser(ohmGrammar, buildGrammar);
|
|
6084
6087
|
|
|
6085
6088
|
var ohm = main$1.exports;
|
|
6086
6089
|
|
|
@@ -6254,14 +6257,6 @@ VisitorFamily.prototype.addOperation = function(signature, actions) {
|
|
|
6254
6257
|
|
|
6255
6258
|
var VisitorFamily_1 = VisitorFamily;
|
|
6256
6259
|
|
|
6257
|
-
// --------------------------------------------------------------------
|
|
6258
|
-
// Imports
|
|
6259
|
-
// --------------------------------------------------------------------
|
|
6260
|
-
|
|
6261
|
-
const pexprs = pexprs$7;
|
|
6262
|
-
const MatchResult = MatchResult_1;
|
|
6263
|
-
const Grammar = Grammar_1;
|
|
6264
|
-
|
|
6265
6260
|
// --------------------------------------------------------------------
|
|
6266
6261
|
// Operations
|
|
6267
6262
|
// --------------------------------------------------------------------
|
|
@@ -6277,11 +6272,6 @@ const defaultOperation = {
|
|
|
6277
6272
|
|
|
6278
6273
|
// without customization
|
|
6279
6274
|
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
6275
|
// lexical rule
|
|
6286
6276
|
if (this.isLexical()) {
|
|
6287
6277
|
return this.sourceString;
|
|
@@ -6365,8 +6355,8 @@ const defaultOperation = {
|
|
|
6365
6355
|
// The optional `mapping` parameter can be used to customize how the nodes of the CST
|
|
6366
6356
|
// are mapped to the AST (see /doc/extras.md#toastmatchresult-mapping).
|
|
6367
6357
|
function toAST(res, mapping) {
|
|
6368
|
-
if (
|
|
6369
|
-
throw new Error('toAST() expects a
|
|
6358
|
+
if (typeof res.failed !== 'function' || res.failed()) {
|
|
6359
|
+
throw new Error('toAST() expects a succesful MatchResult as first parameter');
|
|
6370
6360
|
}
|
|
6371
6361
|
|
|
6372
6362
|
mapping = Object.assign({}, mapping);
|
|
@@ -6384,7 +6374,7 @@ function toAST(res, mapping) {
|
|
|
6384
6374
|
|
|
6385
6375
|
// Returns a semantics containg the toAST(mapping) operation for the given grammar g.
|
|
6386
6376
|
function semanticsForToAST(g) {
|
|
6387
|
-
if (
|
|
6377
|
+
if (typeof g.createSemantics !== 'function') {
|
|
6388
6378
|
throw new Error('semanticsToAST() expects a Grammar as parameter');
|
|
6389
6379
|
}
|
|
6390
6380
|
|