"use strict"; /** @fileOverview Implements `class page.EBNF.NT extends page.BNF.NT`. * @author Axel T. Schreiner <ats@cs.rit.edu> * @version 1.5.0 */ /** Creates a new non-terminal representation for EBNF. * @class Represents a (unique!) non-terminal for EBNF. * @extends page.BNF.NT * @private * * @param {string} _name non-terminal's name. * @param {number} _index non-terminal's index in {@link page.EBNF}`.nts`. * * @property {string} name non-terminal's name. * @property {number} index non-terminal's index in {@link page.EBNF}`.nts`; * transient, maintained by {@link page.BNF#nt}. * @property {number} ord non-terminal's global index; * transient, set in {@link page.EBNF#init}. * @property {page.BNF.NT} nt corresponding non-terminal for BNF. * @property {boolean} empty true if no input can be accepted. * @property {Map} first terminals at front, maps ord to {@link page.BNF.T}. * @property {Map} follow terminals following, maps ord to {@link page.BNF.T}. * @property {page.EBNF.Rule} rule defining `this`; * transient, maintained when a rule is constructed. */ page.EBNF.NT = function (_name, _index) { page.BNF.NT.call(this, _name, _index); delete this.rules; delete this.reached; delete this.finite; this.nt = undefined; this.rule = undefined; }; page.subclass(page.EBNF.NT, 'page.EBNF.NT', page.BNF.NT); /** Called once by {@link page.EBNF#init} to recursively translate into BNF. * @private * * @param {page.EBNF} _grammar object to which the construct belongs. * * @returns {page.BNF.NT} non-terminal with the same name. */ page.EBNF.NT.prototype.toBNF = function (_grammar) { return this.nt = _grammar.bnf.nt(this.name); }; /** Called by {@link page.EBNF#init} to complete EBNF grammar initialization. * Imports {@link page.BNF.NT}`.empty`, {@link page.BNF.NT}`.first`, and * {@link page.BNF.NT}`.follow` from {@link page.EBNF.NT}`.nt`. * @private */ page.EBNF.NT.prototype.init = function () { this.empty = this.nt.empty; this.first = this.nt.first; this.follow = this.nt.follow; };