UNPKG

pegisland

Version:

General PEG-based parser supporting island grammars with lake symbols

47 lines 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BeginningCalculator = void 0; // Copyright (C) 2021- Katsumi Okuda. All rights reserved. const FirstCalculator_1 = require("./FirstCalculator"); const set_operations_1 = require("../set-operations"); const SetCalculator_1 = require("./SetCalculator"); class BeginningCalculator extends FirstCalculator_1.FirstCalculator { constructor(rules, isSpecial = false) { super(rules); this.isSpecial = isSpecial; } visitNonterminal(pe) { if (this.get(pe.rule.rhs).has(SetCalculator_1.EPSILON)) { this.set(pe, new Set([pe, SetCalculator_1.EPSILON])); } else { this.set(pe, new Set([pe])); } } visitNot(pe) { if (this.isSpecial) { this.set(pe, (0, set_operations_1.union)(this.get(pe.operand), new Set([SetCalculator_1.EPSILON]))); } else { this.set(pe, new Set([SetCalculator_1.EPSILON])); } } visitColon(pe) { if (this.isSpecial) { this.set(pe, (0, set_operations_1.union)(this.get(pe.lhs), this.get(pe.rhs))); } else { this.set(pe, new Set(this.get(pe.rhs))); } } visitColonNot(pe) { if (this.isSpecial) { this.set(pe, (0, set_operations_1.union)(this.get(pe.lhs), this.get(pe.rhs))); } else { this.set(pe, new Set(this.get(pe.lhs))); } } } exports.BeginningCalculator = BeginningCalculator; //# sourceMappingURL=BeginningCalculator.js.map