Source: Tuple.js

"use strict";

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

/** Creates a new element of a tokenized input stream.
  * @class Represents an element of a tokenized input stream.
  *
  * @param {number} _lineno input position.
  * @param {page.BNF.T} _t terminal.
  * @param {string} _value terminal's representation in the input.
  *
  * @property {number} lineno input position.
  * @property {page.BNF.T} t terminal.
  * @property {string} value terminal's representation in the input.
  * 
  * @see page.BNF.tokenizer
  */
page.Tuple = function (_lineno, _t, _value) {
  this.assert('Tuple-1', _t instanceof page.BNF.T);
  
  this.lineno = _lineno;
  this.t = _t;
  this.value = _value;
};

page.baseclass(page.Tuple, 'page.Tuple');

/** Displays position, terminal, and associated value.
  * @returns {string}.
  */
page.Tuple.prototype.toString = function () {
  return '(' + this.lineno + ') ' + this.t +
    (this.t instanceof page.BNF.Lit ? '' : ' ' + page.escape(this.value));
};