UNPKG

parseit.js

Version:

Customizable parsing library for converting a list of tokens into an AST tree

61 lines 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GrammarEither = exports.GrammarBlockLoop = exports.GrammarBinaryLoop = exports.GrammarAtom = exports.GrammarRuleSpecialMatch = exports.GrammarAtomType = void 0; var GrammarAtomType; (function (GrammarAtomType) { GrammarAtomType[GrammarAtomType["RULE"] = 0] = "RULE"; GrammarAtomType[GrammarAtomType["TOKEN"] = 1] = "TOKEN"; })(GrammarAtomType = exports.GrammarAtomType || (exports.GrammarAtomType = {})); var GrammarRuleSpecialMatch; (function (GrammarRuleSpecialMatch) { GrammarRuleSpecialMatch[GrammarRuleSpecialMatch["PASS"] = 0] = "PASS"; GrammarRuleSpecialMatch[GrammarRuleSpecialMatch["FUNC"] = 1] = "FUNC"; })(GrammarRuleSpecialMatch = exports.GrammarRuleSpecialMatch || (exports.GrammarRuleSpecialMatch = {})); /** The grammar rule variation */ class GrammarRule { name; content = []; match; func; ignored; preventRollback = false; constructor(name, content, match, func, ignored, preventRollback = false) { this.name = name; this.content = content; this.match = match; this.func = func; this.ignored = ignored; this.preventRollback = preventRollback; } } exports.default = GrammarRule; /** A single grammar rule variation object. Can be a token or a reference to another rule */ class GrammarAtom { name; value; type; skip = false; constructor(name, type, value, skip = false) { this.name = name; this.value = value; this.type = type; this.skip = skip; } } exports.GrammarAtom = GrammarAtom; /** Binary loop grammar item */ class GrammarBinaryLoop { content = []; } exports.GrammarBinaryLoop = GrammarBinaryLoop; /** Block loop grammar item */ class GrammarBlockLoop { content = []; } exports.GrammarBlockLoop = GrammarBlockLoop; /** Either selector grammar item */ class GrammarEither { variants = []; } exports.GrammarEither = GrammarEither; //# sourceMappingURL=rule.js.map