Source: BNF/Lit.js

"use strict";

/** @fileOverview Implements `class page.BNF.Lit extends page.BNF.T`.
  * @author Axel T. Schreiner <ats@cs.rit.edu>
  * @version 1.5.0
  */

/** Creates a new literal for BNF.
  * @class Represents a (unique!) literal for BNF.
  * @extends page.BNF.T
  * @private
  *
  * @param {string} _literal a value for the literal.
  *
  * @property {string} literal value for the literal.
  */
page.BNF.Lit = function (_literal) {
  page.BNF.T.call(this);
  this.literal = _literal;
};

page.subclass(page.BNF.Lit, 'page.BNF.Lit', page.BNF.T);

/** Displays string value of a literal.
  * @override
  * @variation BNF
  * @returns {string}
  */
page.BNF.Lit.prototype.toString = function () {
  return this.literal.length ? page.escape(this.literal) : '$eof';
};