"use strict";
/** @fileOverview Implements `class page.SLR1.Action`.
* @author Axel T. Schreiner <ats@cs.rit.edu>
* @version 1.5.0
*/
/** Creates a new action.
* @class Represents an action of the SLR(1) automaton.
* @private
*
* @param {string} _action one of `'accept'`, `'goto'`, `'reduce'`, or `'shift'`.
* @param {page.BNF.T|page.BNF.NT} _symbol symbol on which to take the action.
* @param {page.BNF.T|page.BNF.Rule} [_info] additional information.
*
* @property {string} action one of `'accept'`, `'error'`, `'goto'`, `'reduce'`, or `'shift'`.
* @property {page.BNF.T|page.BNF.NT} symbol symbol on which to take the action.
* @property {Number|page.BNF.Rule} info additional information, if any.
*/
page.SLR1.Action = function (_action, _symbol, _info) {
this.action = _action;
this.symbol = _symbol;
this.info = _info;
};
page.baseclass(page.SLR1.Action, 'page.SLR1.Action');
/** Displays symbol, action, and additional information if any.
* @returns {string}
*/
page.SLR1.Action.prototype.toString = function () {
var result = (this.symbol + ' ').substr(0, 13) + this.action;
switch (this.action) {
case 'goto':
case 'shift': result += ' ' + this.info; break;
case 'reduce': result += ' (' + this.info + ')'; break;
}
return result;
};