Initial commit
This commit is contained in:
commit
b3a51a4115
10336 changed files with 2381973 additions and 0 deletions
74
node_modules/chevrotain/lib/src/parse/grammar/follow.js
generated
vendored
Normal file
74
node_modules/chevrotain/lib/src/parse/grammar/follow.js
generated
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
if (typeof b !== "function" && b !== null)
|
||||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildInProdFollowPrefix = exports.buildBetweenProdsFollowPrefix = exports.computeAllProdsFollows = exports.ResyncFollowsWalker = void 0;
|
||||
var rest_1 = require("./rest");
|
||||
var first_1 = require("./first");
|
||||
var forEach_1 = __importDefault(require("lodash/forEach"));
|
||||
var assign_1 = __importDefault(require("lodash/assign"));
|
||||
var constants_1 = require("../constants");
|
||||
var gast_1 = require("@chevrotain/gast");
|
||||
// This ResyncFollowsWalker computes all of the follows required for RESYNC
|
||||
// (skipping reference production).
|
||||
var ResyncFollowsWalker = /** @class */ (function (_super) {
|
||||
__extends(ResyncFollowsWalker, _super);
|
||||
function ResyncFollowsWalker(topProd) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.topProd = topProd;
|
||||
_this.follows = {};
|
||||
return _this;
|
||||
}
|
||||
ResyncFollowsWalker.prototype.startWalking = function () {
|
||||
this.walk(this.topProd);
|
||||
return this.follows;
|
||||
};
|
||||
ResyncFollowsWalker.prototype.walkTerminal = function (terminal, currRest, prevRest) {
|
||||
// do nothing! just like in the public sector after 13:00
|
||||
};
|
||||
ResyncFollowsWalker.prototype.walkProdRef = function (refProd, currRest, prevRest) {
|
||||
var followName = buildBetweenProdsFollowPrefix(refProd.referencedRule, refProd.idx) +
|
||||
this.topProd.name;
|
||||
var fullRest = currRest.concat(prevRest);
|
||||
var restProd = new gast_1.Alternative({ definition: fullRest });
|
||||
var t_in_topProd_follows = (0, first_1.first)(restProd);
|
||||
this.follows[followName] = t_in_topProd_follows;
|
||||
};
|
||||
return ResyncFollowsWalker;
|
||||
}(rest_1.RestWalker));
|
||||
exports.ResyncFollowsWalker = ResyncFollowsWalker;
|
||||
function computeAllProdsFollows(topProductions) {
|
||||
var reSyncFollows = {};
|
||||
(0, forEach_1.default)(topProductions, function (topProd) {
|
||||
var currRefsFollow = new ResyncFollowsWalker(topProd).startWalking();
|
||||
(0, assign_1.default)(reSyncFollows, currRefsFollow);
|
||||
});
|
||||
return reSyncFollows;
|
||||
}
|
||||
exports.computeAllProdsFollows = computeAllProdsFollows;
|
||||
function buildBetweenProdsFollowPrefix(inner, occurenceInParent) {
|
||||
return inner.name + occurenceInParent + constants_1.IN;
|
||||
}
|
||||
exports.buildBetweenProdsFollowPrefix = buildBetweenProdsFollowPrefix;
|
||||
function buildInProdFollowPrefix(terminal) {
|
||||
var terminalName = terminal.terminalType.name;
|
||||
return terminalName + terminal.idx + constants_1.IN;
|
||||
}
|
||||
exports.buildInProdFollowPrefix = buildInProdFollowPrefix;
|
||||
//# sourceMappingURL=follow.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue