Aktueller Stand
This commit is contained in:
3
backend/node_modules/@chevrotain/gast/lib/src/api.d.ts
generated
vendored
Normal file
3
backend/node_modules/@chevrotain/gast/lib/src/api.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export { Rule, Terminal, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Alternation, Alternative, serializeGrammar, serializeProduction } from "./model";
|
||||
export { GAstVisitor } from "./visitor";
|
||||
export { getProductionDslName, isOptionalProd, isBranchingProd, isSequenceProd } from "./helpers";
|
||||
24
backend/node_modules/@chevrotain/gast/lib/src/api.js
generated
vendored
Normal file
24
backend/node_modules/@chevrotain/gast/lib/src/api.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isSequenceProd = exports.isBranchingProd = exports.isOptionalProd = exports.getProductionDslName = exports.GAstVisitor = exports.serializeProduction = exports.serializeGrammar = exports.Alternative = exports.Alternation = exports.RepetitionWithSeparator = exports.RepetitionMandatoryWithSeparator = exports.RepetitionMandatory = exports.Repetition = exports.Option = exports.NonTerminal = exports.Terminal = exports.Rule = void 0;
|
||||
var model_1 = require("./model");
|
||||
Object.defineProperty(exports, "Rule", { enumerable: true, get: function () { return model_1.Rule; } });
|
||||
Object.defineProperty(exports, "Terminal", { enumerable: true, get: function () { return model_1.Terminal; } });
|
||||
Object.defineProperty(exports, "NonTerminal", { enumerable: true, get: function () { return model_1.NonTerminal; } });
|
||||
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return model_1.Option; } });
|
||||
Object.defineProperty(exports, "Repetition", { enumerable: true, get: function () { return model_1.Repetition; } });
|
||||
Object.defineProperty(exports, "RepetitionMandatory", { enumerable: true, get: function () { return model_1.RepetitionMandatory; } });
|
||||
Object.defineProperty(exports, "RepetitionMandatoryWithSeparator", { enumerable: true, get: function () { return model_1.RepetitionMandatoryWithSeparator; } });
|
||||
Object.defineProperty(exports, "RepetitionWithSeparator", { enumerable: true, get: function () { return model_1.RepetitionWithSeparator; } });
|
||||
Object.defineProperty(exports, "Alternation", { enumerable: true, get: function () { return model_1.Alternation; } });
|
||||
Object.defineProperty(exports, "Alternative", { enumerable: true, get: function () { return model_1.Alternative; } });
|
||||
Object.defineProperty(exports, "serializeGrammar", { enumerable: true, get: function () { return model_1.serializeGrammar; } });
|
||||
Object.defineProperty(exports, "serializeProduction", { enumerable: true, get: function () { return model_1.serializeProduction; } });
|
||||
var visitor_1 = require("./visitor");
|
||||
Object.defineProperty(exports, "GAstVisitor", { enumerable: true, get: function () { return visitor_1.GAstVisitor; } });
|
||||
var helpers_1 = require("./helpers");
|
||||
Object.defineProperty(exports, "getProductionDslName", { enumerable: true, get: function () { return helpers_1.getProductionDslName; } });
|
||||
Object.defineProperty(exports, "isOptionalProd", { enumerable: true, get: function () { return helpers_1.isOptionalProd; } });
|
||||
Object.defineProperty(exports, "isBranchingProd", { enumerable: true, get: function () { return helpers_1.isBranchingProd; } });
|
||||
Object.defineProperty(exports, "isSequenceProd", { enumerable: true, get: function () { return helpers_1.isSequenceProd; } });
|
||||
//# sourceMappingURL=api.js.map
|
||||
1
backend/node_modules/@chevrotain/gast/lib/src/api.js.map
generated
vendored
Normal file
1
backend/node_modules/@chevrotain/gast/lib/src/api.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":";;;AAAA,iCAagB;AAZd,6FAAA,IAAI,OAAA;AACJ,iGAAA,QAAQ,OAAA;AACR,oGAAA,WAAW,OAAA;AACX,+FAAA,MAAM,OAAA;AACN,mGAAA,UAAU,OAAA;AACV,4GAAA,mBAAmB,OAAA;AACnB,yHAAA,gCAAgC,OAAA;AAChC,gHAAA,uBAAuB,OAAA;AACvB,oGAAA,WAAW,OAAA;AACX,oGAAA,WAAW,OAAA;AACX,yGAAA,gBAAgB,OAAA;AAChB,4GAAA,mBAAmB,OAAA;AAGrB,qCAAuC;AAA9B,sGAAA,WAAW,OAAA;AAEpB,qCAKkB;AAJhB,+GAAA,oBAAoB,OAAA;AACpB,yGAAA,cAAc,OAAA;AACd,0GAAA,eAAe,OAAA;AACf,yGAAA,cAAc,OAAA"}
|
||||
10
backend/node_modules/@chevrotain/gast/lib/src/helpers.d.ts
generated
vendored
Normal file
10
backend/node_modules/@chevrotain/gast/lib/src/helpers.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NonTerminal } from "./model";
|
||||
import { IProduction, IProductionWithOccurrence } from "@chevrotain/types";
|
||||
export declare function isSequenceProd(prod: IProduction): prod is {
|
||||
definition: IProduction[];
|
||||
} & IProduction;
|
||||
export declare function isOptionalProd(prod: IProduction, alreadyVisited?: NonTerminal[]): boolean;
|
||||
export declare function isBranchingProd(prod: IProduction): prod is {
|
||||
definition: IProduction[];
|
||||
} & IProduction;
|
||||
export declare function getProductionDslName(prod: IProductionWithOccurrence): string;
|
||||
91
backend/node_modules/@chevrotain/gast/lib/src/helpers.js
generated
vendored
Normal file
91
backend/node_modules/@chevrotain/gast/lib/src/helpers.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getProductionDslName = exports.isBranchingProd = exports.isOptionalProd = exports.isSequenceProd = void 0;
|
||||
var some_1 = __importDefault(require("lodash/some"));
|
||||
var every_1 = __importDefault(require("lodash/every"));
|
||||
var includes_1 = __importDefault(require("lodash/includes"));
|
||||
var model_1 = require("./model");
|
||||
function isSequenceProd(prod) {
|
||||
return (prod instanceof model_1.Alternative ||
|
||||
prod instanceof model_1.Option ||
|
||||
prod instanceof model_1.Repetition ||
|
||||
prod instanceof model_1.RepetitionMandatory ||
|
||||
prod instanceof model_1.RepetitionMandatoryWithSeparator ||
|
||||
prod instanceof model_1.RepetitionWithSeparator ||
|
||||
prod instanceof model_1.Terminal ||
|
||||
prod instanceof model_1.Rule);
|
||||
}
|
||||
exports.isSequenceProd = isSequenceProd;
|
||||
function isOptionalProd(prod, alreadyVisited) {
|
||||
if (alreadyVisited === void 0) { alreadyVisited = []; }
|
||||
var isDirectlyOptional = prod instanceof model_1.Option ||
|
||||
prod instanceof model_1.Repetition ||
|
||||
prod instanceof model_1.RepetitionWithSeparator;
|
||||
if (isDirectlyOptional) {
|
||||
return true;
|
||||
}
|
||||
// note that this can cause infinite loop if one optional empty TOP production has a cyclic dependency with another
|
||||
// empty optional top rule
|
||||
// may be indirectly optional ((A?B?C?) | (D?E?F?))
|
||||
if (prod instanceof model_1.Alternation) {
|
||||
// for OR its enough for just one of the alternatives to be optional
|
||||
return (0, some_1.default)(prod.definition, function (subProd) {
|
||||
return isOptionalProd(subProd, alreadyVisited);
|
||||
});
|
||||
}
|
||||
else if (prod instanceof model_1.NonTerminal && (0, includes_1.default)(alreadyVisited, prod)) {
|
||||
// avoiding stack overflow due to infinite recursion
|
||||
return false;
|
||||
}
|
||||
else if (prod instanceof model_1.AbstractProduction) {
|
||||
if (prod instanceof model_1.NonTerminal) {
|
||||
alreadyVisited.push(prod);
|
||||
}
|
||||
return (0, every_1.default)(prod.definition, function (subProd) {
|
||||
return isOptionalProd(subProd, alreadyVisited);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.isOptionalProd = isOptionalProd;
|
||||
function isBranchingProd(prod) {
|
||||
return prod instanceof model_1.Alternation;
|
||||
}
|
||||
exports.isBranchingProd = isBranchingProd;
|
||||
function getProductionDslName(prod) {
|
||||
/* istanbul ignore else */
|
||||
if (prod instanceof model_1.NonTerminal) {
|
||||
return "SUBRULE";
|
||||
}
|
||||
else if (prod instanceof model_1.Option) {
|
||||
return "OPTION";
|
||||
}
|
||||
else if (prod instanceof model_1.Alternation) {
|
||||
return "OR";
|
||||
}
|
||||
else if (prod instanceof model_1.RepetitionMandatory) {
|
||||
return "AT_LEAST_ONE";
|
||||
}
|
||||
else if (prod instanceof model_1.RepetitionMandatoryWithSeparator) {
|
||||
return "AT_LEAST_ONE_SEP";
|
||||
}
|
||||
else if (prod instanceof model_1.RepetitionWithSeparator) {
|
||||
return "MANY_SEP";
|
||||
}
|
||||
else if (prod instanceof model_1.Repetition) {
|
||||
return "MANY";
|
||||
}
|
||||
else if (prod instanceof model_1.Terminal) {
|
||||
return "CONSUME";
|
||||
}
|
||||
else {
|
||||
throw Error("non exhaustive match");
|
||||
}
|
||||
}
|
||||
exports.getProductionDslName = getProductionDslName;
|
||||
//# sourceMappingURL=helpers.js.map
|
||||
1
backend/node_modules/@chevrotain/gast/lib/src/helpers.js.map
generated
vendored
Normal file
1
backend/node_modules/@chevrotain/gast/lib/src/helpers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,qDAA8B;AAC9B,uDAAgC;AAEhC,6DAAsC;AACtC,iCAYgB;AAIhB,SAAgB,cAAc,CAC5B,IAAiB;IAEjB,OAAO,CACL,IAAI,YAAY,mBAAW;QAC3B,IAAI,YAAY,cAAM;QACtB,IAAI,YAAY,kBAAU;QAC1B,IAAI,YAAY,2BAAmB;QACnC,IAAI,YAAY,wCAAgC;QAChD,IAAI,YAAY,+BAAuB;QACvC,IAAI,YAAY,gBAAQ;QACxB,IAAI,YAAY,YAAI,CACrB,CAAA;AACH,CAAC;AAbD,wCAaC;AAED,SAAgB,cAAc,CAC5B,IAAiB,EACjB,cAAkC;IAAlC,+BAAA,EAAA,mBAAkC;IAElC,IAAM,kBAAkB,GACtB,IAAI,YAAY,cAAM;QACtB,IAAI,YAAY,kBAAU;QAC1B,IAAI,YAAY,+BAAuB,CAAA;IACzC,IAAI,kBAAkB,EAAE;QACtB,OAAO,IAAI,CAAA;K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,YAAY,+BAAuB,EAAE;QAClD,OAAO,UAAU,CAAA;KAClB;SAAM,IAAI,IAAI,YAAY,kBAAU,EAAE;QACrC,OAAO,MAAM,CAAA;KACd;SAAM,IAAI,IAAI,YAAY,gBAAQ,EAAE;QACnC,OAAO,SAAS,CAAA;KACjB;SAAM;QACL,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;KACpC;AACH,CAAC;AArBD,oDAqBC"}
|
||||
144
backend/node_modules/@chevrotain/gast/lib/src/model.d.ts
generated
vendored
Normal file
144
backend/node_modules/@chevrotain/gast/lib/src/model.d.ts
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
import { IGASTVisitor, IProduction, IProductionWithOccurrence, ISerializedGast, TokenType } from "@chevrotain/types";
|
||||
export declare abstract class AbstractProduction<T extends IProduction = IProduction> implements IProduction {
|
||||
protected _definition: T[];
|
||||
get definition(): T[];
|
||||
set definition(value: T[]);
|
||||
constructor(_definition: T[]);
|
||||
accept(visitor: IGASTVisitor): void;
|
||||
}
|
||||
export declare class NonTerminal extends AbstractProduction implements IProductionWithOccurrence {
|
||||
nonTerminalName: string;
|
||||
label?: string;
|
||||
referencedRule: Rule;
|
||||
idx: number;
|
||||
constructor(options: {
|
||||
nonTerminalName: string;
|
||||
label?: string;
|
||||
referencedRule?: Rule;
|
||||
idx?: number;
|
||||
});
|
||||
set definition(definition: IProduction[]);
|
||||
get definition(): IProduction[];
|
||||
accept(visitor: IGASTVisitor): void;
|
||||
}
|
||||
export declare class Rule extends AbstractProduction {
|
||||
name: string;
|
||||
orgText: string;
|
||||
constructor(options: {
|
||||
name: string;
|
||||
definition: IProduction[];
|
||||
orgText?: string;
|
||||
});
|
||||
}
|
||||
export declare class Alternative extends AbstractProduction {
|
||||
ignoreAmbiguities: boolean;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
ignoreAmbiguities?: boolean;
|
||||
});
|
||||
}
|
||||
export declare class Option extends AbstractProduction implements IProductionWithOccurrence {
|
||||
idx: number;
|
||||
maxLookahead?: number;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
idx?: number;
|
||||
maxLookahead?: number;
|
||||
});
|
||||
}
|
||||
export declare class RepetitionMandatory extends AbstractProduction implements IProductionWithOccurrence {
|
||||
idx: number;
|
||||
maxLookahead?: number;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
idx?: number;
|
||||
maxLookahead?: number;
|
||||
});
|
||||
}
|
||||
export declare class RepetitionMandatoryWithSeparator extends AbstractProduction implements IProductionWithOccurrence {
|
||||
separator: TokenType;
|
||||
idx: number;
|
||||
maxLookahead?: number;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
separator: TokenType;
|
||||
idx?: number;
|
||||
});
|
||||
}
|
||||
export declare class Repetition extends AbstractProduction implements IProductionWithOccurrence {
|
||||
separator: TokenType;
|
||||
idx: number;
|
||||
maxLookahead?: number;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
idx?: number;
|
||||
maxLookahead?: number;
|
||||
});
|
||||
}
|
||||
export declare class RepetitionWithSeparator extends AbstractProduction implements IProductionWithOccurrence {
|
||||
separator: TokenType;
|
||||
idx: number;
|
||||
maxLookahead?: number;
|
||||
constructor(options: {
|
||||
definition: IProduction[];
|
||||
separator: TokenType;
|
||||
idx?: number;
|
||||
});
|
||||
}
|
||||
export declare class Alternation extends AbstractProduction<Alternative> implements IProductionWithOccurrence {
|
||||
idx: number;
|
||||
ignoreAmbiguities: boolean;
|
||||
hasPredicates: boolean;
|
||||
maxLookahead?: number;
|
||||
get definition(): Alternative[];
|
||||
set definition(value: Alternative[]);
|
||||
constructor(options: {
|
||||
definition: Alternative[];
|
||||
idx?: number;
|
||||
ignoreAmbiguities?: boolean;
|
||||
hasPredicates?: boolean;
|
||||
maxLookahead?: number;
|
||||
});
|
||||
}
|
||||
export declare class Terminal implements IProductionWithOccurrence {
|
||||
terminalType: TokenType;
|
||||
label?: string;
|
||||
idx: number;
|
||||
constructor(options: {
|
||||
terminalType: TokenType;
|
||||
label?: string;
|
||||
idx?: number;
|
||||
});
|
||||
accept(visitor: IGASTVisitor): void;
|
||||
}
|
||||
export interface ISerializedBasic extends ISerializedGast {
|
||||
type: "Alternative" | "Option" | "RepetitionMandatory" | "Repetition" | "Alternation";
|
||||
idx?: number;
|
||||
}
|
||||
export interface ISerializedGastRule extends ISerializedGast {
|
||||
type: "Rule";
|
||||
name: string;
|
||||
orgText: string;
|
||||
}
|
||||
export interface ISerializedNonTerminal extends ISerializedGast {
|
||||
type: "NonTerminal";
|
||||
name: string;
|
||||
label?: string;
|
||||
idx: number;
|
||||
}
|
||||
export interface ISerializedTerminal extends ISerializedGast {
|
||||
type: "Terminal";
|
||||
name: string;
|
||||
terminalLabel?: string;
|
||||
label?: string;
|
||||
pattern?: string;
|
||||
idx: number;
|
||||
}
|
||||
export interface ISerializedTerminalWithSeparator extends ISerializedGast {
|
||||
type: "RepetitionMandatoryWithSeparator" | "RepetitionWithSeparator";
|
||||
idx: number;
|
||||
separator: ISerializedTerminal;
|
||||
}
|
||||
export type ISerializedGastAny = ISerializedBasic | ISerializedGastRule | ISerializedNonTerminal | ISerializedTerminal | ISerializedTerminalWithSeparator;
|
||||
export declare function serializeGrammar(topRules: Rule[]): ISerializedGast[];
|
||||
export declare function serializeProduction(node: IProduction): ISerializedGast;
|
||||
304
backend/node_modules/@chevrotain/gast/lib/src/model.js
generated
vendored
Normal file
304
backend/node_modules/@chevrotain/gast/lib/src/model.js
generated
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
"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.serializeProduction = exports.serializeGrammar = exports.Terminal = exports.Alternation = exports.RepetitionWithSeparator = exports.Repetition = exports.RepetitionMandatoryWithSeparator = exports.RepetitionMandatory = exports.Option = exports.Alternative = exports.Rule = exports.NonTerminal = exports.AbstractProduction = void 0;
|
||||
var map_1 = __importDefault(require("lodash/map"));
|
||||
var forEach_1 = __importDefault(require("lodash/forEach"));
|
||||
var isString_1 = __importDefault(require("lodash/isString"));
|
||||
var isRegExp_1 = __importDefault(require("lodash/isRegExp"));
|
||||
var pickBy_1 = __importDefault(require("lodash/pickBy"));
|
||||
var assign_1 = __importDefault(require("lodash/assign"));
|
||||
// TODO: duplicated code to avoid extracting another sub-package -- how to avoid?
|
||||
function tokenLabel(tokType) {
|
||||
if (hasTokenLabel(tokType)) {
|
||||
return tokType.LABEL;
|
||||
}
|
||||
else {
|
||||
return tokType.name;
|
||||
}
|
||||
}
|
||||
// TODO: duplicated code to avoid extracting another sub-package -- how to avoid?
|
||||
function hasTokenLabel(obj) {
|
||||
return (0, isString_1.default)(obj.LABEL) && obj.LABEL !== "";
|
||||
}
|
||||
var AbstractProduction = /** @class */ (function () {
|
||||
function AbstractProduction(_definition) {
|
||||
this._definition = _definition;
|
||||
}
|
||||
Object.defineProperty(AbstractProduction.prototype, "definition", {
|
||||
get: function () {
|
||||
return this._definition;
|
||||
},
|
||||
set: function (value) {
|
||||
this._definition = value;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
AbstractProduction.prototype.accept = function (visitor) {
|
||||
visitor.visit(this);
|
||||
(0, forEach_1.default)(this.definition, function (prod) {
|
||||
prod.accept(visitor);
|
||||
});
|
||||
};
|
||||
return AbstractProduction;
|
||||
}());
|
||||
exports.AbstractProduction = AbstractProduction;
|
||||
var NonTerminal = /** @class */ (function (_super) {
|
||||
__extends(NonTerminal, _super);
|
||||
function NonTerminal(options) {
|
||||
var _this = _super.call(this, []) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(NonTerminal.prototype, "definition", {
|
||||
get: function () {
|
||||
if (this.referencedRule !== undefined) {
|
||||
return this.referencedRule.definition;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
set: function (definition) {
|
||||
// immutable
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
NonTerminal.prototype.accept = function (visitor) {
|
||||
visitor.visit(this);
|
||||
// don't visit children of a reference, we will get cyclic infinite loops if we do so
|
||||
};
|
||||
return NonTerminal;
|
||||
}(AbstractProduction));
|
||||
exports.NonTerminal = NonTerminal;
|
||||
var Rule = /** @class */ (function (_super) {
|
||||
__extends(Rule, _super);
|
||||
function Rule(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.orgText = "";
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return Rule;
|
||||
}(AbstractProduction));
|
||||
exports.Rule = Rule;
|
||||
var Alternative = /** @class */ (function (_super) {
|
||||
__extends(Alternative, _super);
|
||||
function Alternative(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.ignoreAmbiguities = false;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return Alternative;
|
||||
}(AbstractProduction));
|
||||
exports.Alternative = Alternative;
|
||||
var Option = /** @class */ (function (_super) {
|
||||
__extends(Option, _super);
|
||||
function Option(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return Option;
|
||||
}(AbstractProduction));
|
||||
exports.Option = Option;
|
||||
var RepetitionMandatory = /** @class */ (function (_super) {
|
||||
__extends(RepetitionMandatory, _super);
|
||||
function RepetitionMandatory(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return RepetitionMandatory;
|
||||
}(AbstractProduction));
|
||||
exports.RepetitionMandatory = RepetitionMandatory;
|
||||
var RepetitionMandatoryWithSeparator = /** @class */ (function (_super) {
|
||||
__extends(RepetitionMandatoryWithSeparator, _super);
|
||||
function RepetitionMandatoryWithSeparator(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return RepetitionMandatoryWithSeparator;
|
||||
}(AbstractProduction));
|
||||
exports.RepetitionMandatoryWithSeparator = RepetitionMandatoryWithSeparator;
|
||||
var Repetition = /** @class */ (function (_super) {
|
||||
__extends(Repetition, _super);
|
||||
function Repetition(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return Repetition;
|
||||
}(AbstractProduction));
|
||||
exports.Repetition = Repetition;
|
||||
var RepetitionWithSeparator = /** @class */ (function (_super) {
|
||||
__extends(RepetitionWithSeparator, _super);
|
||||
function RepetitionWithSeparator(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
return RepetitionWithSeparator;
|
||||
}(AbstractProduction));
|
||||
exports.RepetitionWithSeparator = RepetitionWithSeparator;
|
||||
var Alternation = /** @class */ (function (_super) {
|
||||
__extends(Alternation, _super);
|
||||
function Alternation(options) {
|
||||
var _this = _super.call(this, options.definition) || this;
|
||||
_this.idx = 1;
|
||||
_this.ignoreAmbiguities = false;
|
||||
_this.hasPredicates = false;
|
||||
(0, assign_1.default)(_this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
return _this;
|
||||
}
|
||||
Object.defineProperty(Alternation.prototype, "definition", {
|
||||
get: function () {
|
||||
return this._definition;
|
||||
},
|
||||
set: function (value) {
|
||||
this._definition = value;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
return Alternation;
|
||||
}(AbstractProduction));
|
||||
exports.Alternation = Alternation;
|
||||
var Terminal = /** @class */ (function () {
|
||||
function Terminal(options) {
|
||||
this.idx = 1;
|
||||
(0, assign_1.default)(this, (0, pickBy_1.default)(options, function (v) { return v !== undefined; }));
|
||||
}
|
||||
Terminal.prototype.accept = function (visitor) {
|
||||
visitor.visit(this);
|
||||
};
|
||||
return Terminal;
|
||||
}());
|
||||
exports.Terminal = Terminal;
|
||||
function serializeGrammar(topRules) {
|
||||
return (0, map_1.default)(topRules, serializeProduction);
|
||||
}
|
||||
exports.serializeGrammar = serializeGrammar;
|
||||
function serializeProduction(node) {
|
||||
function convertDefinition(definition) {
|
||||
return (0, map_1.default)(definition, serializeProduction);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (node instanceof NonTerminal) {
|
||||
var serializedNonTerminal = {
|
||||
type: "NonTerminal",
|
||||
name: node.nonTerminalName,
|
||||
idx: node.idx
|
||||
};
|
||||
if ((0, isString_1.default)(node.label)) {
|
||||
serializedNonTerminal.label = node.label;
|
||||
}
|
||||
return serializedNonTerminal;
|
||||
}
|
||||
else if (node instanceof Alternative) {
|
||||
return {
|
||||
type: "Alternative",
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof Option) {
|
||||
return {
|
||||
type: "Option",
|
||||
idx: node.idx,
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof RepetitionMandatory) {
|
||||
return {
|
||||
type: "RepetitionMandatory",
|
||||
idx: node.idx,
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof RepetitionMandatoryWithSeparator) {
|
||||
return {
|
||||
type: "RepetitionMandatoryWithSeparator",
|
||||
idx: node.idx,
|
||||
separator: (serializeProduction(new Terminal({ terminalType: node.separator }))),
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof RepetitionWithSeparator) {
|
||||
return {
|
||||
type: "RepetitionWithSeparator",
|
||||
idx: node.idx,
|
||||
separator: (serializeProduction(new Terminal({ terminalType: node.separator }))),
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof Repetition) {
|
||||
return {
|
||||
type: "Repetition",
|
||||
idx: node.idx,
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof Alternation) {
|
||||
return {
|
||||
type: "Alternation",
|
||||
idx: node.idx,
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else if (node instanceof Terminal) {
|
||||
var serializedTerminal = {
|
||||
type: "Terminal",
|
||||
name: node.terminalType.name,
|
||||
label: tokenLabel(node.terminalType),
|
||||
idx: node.idx
|
||||
};
|
||||
if ((0, isString_1.default)(node.label)) {
|
||||
serializedTerminal.terminalLabel = node.label;
|
||||
}
|
||||
var pattern = node.terminalType.PATTERN;
|
||||
if (node.terminalType.PATTERN) {
|
||||
serializedTerminal.pattern = (0, isRegExp_1.default)(pattern)
|
||||
? pattern.source
|
||||
: pattern;
|
||||
}
|
||||
return serializedTerminal;
|
||||
}
|
||||
else if (node instanceof Rule) {
|
||||
return {
|
||||
type: "Rule",
|
||||
name: node.name,
|
||||
orgText: node.orgText,
|
||||
definition: convertDefinition(node.definition)
|
||||
};
|
||||
}
|
||||
else {
|
||||
throw Error("non exhaustive match");
|
||||
}
|
||||
}
|
||||
exports.serializeProduction = serializeProduction;
|
||||
//# sourceMappingURL=model.js.map
|
||||
1
backend/node_modules/@chevrotain/gast/lib/src/model.js.map
generated
vendored
Normal file
1
backend/node_modules/@chevrotain/gast/lib/src/model.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
backend/node_modules/@chevrotain/gast/lib/src/visitor.d.ts
generated
vendored
Normal file
15
backend/node_modules/@chevrotain/gast/lib/src/visitor.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Alternation, Alternative, NonTerminal, Option, Repetition, RepetitionMandatory, RepetitionMandatoryWithSeparator, RepetitionWithSeparator, Rule, Terminal } from "./model";
|
||||
import { IProduction } from "@chevrotain/types";
|
||||
export declare abstract class GAstVisitor {
|
||||
visit(node: IProduction): any;
|
||||
visitNonTerminal(node: NonTerminal): any;
|
||||
visitAlternative(node: Alternative): any;
|
||||
visitOption(node: Option): any;
|
||||
visitRepetition(node: Repetition): any;
|
||||
visitRepetitionMandatory(node: RepetitionMandatory): any;
|
||||
visitRepetitionMandatoryWithSeparator(node: RepetitionMandatoryWithSeparator): any;
|
||||
visitRepetitionWithSeparator(node: RepetitionWithSeparator): any;
|
||||
visitAlternation(node: Alternation): any;
|
||||
visitTerminal(node: Terminal): any;
|
||||
visitRule(node: Rule): any;
|
||||
}
|
||||
59
backend/node_modules/@chevrotain/gast/lib/src/visitor.js
generated
vendored
Normal file
59
backend/node_modules/@chevrotain/gast/lib/src/visitor.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GAstVisitor = void 0;
|
||||
var model_1 = require("./model");
|
||||
var GAstVisitor = /** @class */ (function () {
|
||||
function GAstVisitor() {
|
||||
}
|
||||
GAstVisitor.prototype.visit = function (node) {
|
||||
var nodeAny = node;
|
||||
switch (nodeAny.constructor) {
|
||||
case model_1.NonTerminal:
|
||||
return this.visitNonTerminal(nodeAny);
|
||||
case model_1.Alternative:
|
||||
return this.visitAlternative(nodeAny);
|
||||
case model_1.Option:
|
||||
return this.visitOption(nodeAny);
|
||||
case model_1.RepetitionMandatory:
|
||||
return this.visitRepetitionMandatory(nodeAny);
|
||||
case model_1.RepetitionMandatoryWithSeparator:
|
||||
return this.visitRepetitionMandatoryWithSeparator(nodeAny);
|
||||
case model_1.RepetitionWithSeparator:
|
||||
return this.visitRepetitionWithSeparator(nodeAny);
|
||||
case model_1.Repetition:
|
||||
return this.visitRepetition(nodeAny);
|
||||
case model_1.Alternation:
|
||||
return this.visitAlternation(nodeAny);
|
||||
case model_1.Terminal:
|
||||
return this.visitTerminal(nodeAny);
|
||||
case model_1.Rule:
|
||||
return this.visitRule(nodeAny);
|
||||
/* istanbul ignore next */
|
||||
default:
|
||||
throw Error("non exhaustive match");
|
||||
}
|
||||
};
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitNonTerminal = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitAlternative = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitOption = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitRepetition = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitRepetitionMandatory = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitRepetitionMandatoryWithSeparator = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitRepetitionWithSeparator = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitAlternation = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitTerminal = function (node) { };
|
||||
/* istanbul ignore next - testing the fact a NOOP function exists is non-trivial */
|
||||
GAstVisitor.prototype.visitRule = function (node) { };
|
||||
return GAstVisitor;
|
||||
}());
|
||||
exports.GAstVisitor = GAstVisitor;
|
||||
//# sourceMappingURL=visitor.js.map
|
||||
1
backend/node_modules/@chevrotain/gast/lib/src/visitor.js.map
generated
vendored
Normal file
1
backend/node_modules/@chevrotain/gast/lib/src/visitor.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"visitor.js","sourceRoot":"","sources":["../../src/visitor.ts"],"names":[],"mappings":";;;AAAA,iCAWgB;AAGhB;IAAA;IA6DA,CAAC;IA5DQ,2BAAK,GAAZ,UAAa,IAAiB;QAC5B,IAAM,OAAO,GAAQ,IAAI,CAAA;QACzB,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,mBAAW;gBACd,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;YACvC,KAAK,mBAAW;gBACd,OAAO,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;YACvC,KAAK,cAAM;gBACT,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAClC,KAAK,2BAAmB;gBACtB,OAAO,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;YAC/C,KAAK,wCAAgC;gBACnC,OAAO,IAAI,CAAC,qCAAqC,CAAC,OAAO,CAAC,CAAA;YAC5D,KAAK,+BAAuB;gBAC1B,OAAO,I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