//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ using Ilog.Language.Util; namespace Ilog.Language.Syntax { /** * Class of LR parsing actions used by the parser generator. * * @version Last modified on Sun May 29 08:29:28 2005 by hak * @author Hassan Aït-Kaci * @copyright © 2000 ILOG, S.A. */ public class Action : ArrayListIndexed { /** * Constants denoting various parse actions. */ public const int SHIFT = 0; public const int REDUCE = 1; public const int ACCEPT = 2; public const int DYNAMIC = 3; public const int CHOICE = 4; public const int ERROR = 5; /** * Constructs an action of the specified type. */ internal Action (int type) : base(ParserGenerator.Actions) { this.type = type; } /** * Constructs an action of the specified type and bearing the * specified info. */ internal Action (int type, int info) : base(ParserGenerator.Actions) { this.type = type; this.info = info; } /** * Constructs an action of the specified type and bearing the * specified info, whose index is as specified. */ internal Action (int type, int info, int index) : base(ParserGenerator.Actions,index) { this.type = type; this.info = info; } /** * This action's type; one of SHIFT, REDUCE, ACCEPT, DYNAMIC, * CHOICE, or ERROR. */ private int type; internal int Type { get { return type; } set { type = value; } } /** * This action's info datum. If the type is REDUCE, this is the * reduction rule's index; if SHIFT,, this is the next state's * index; if DYNAMIC or CHOICE, this is the current state's * dynamic actions array index. */ private int info; internal int Info { get { return info; } } /** * Returns a string representation of a conflict between this * action and the specified one. */ internal string Conflict (Action contender) { return ToString()[0] + "/" + contender.ToString()[0]; } /** * Returns true iff the specified object is an action with same * type and info. */ public override bool Equals (object other) { if (this == other) return true; if (!(other is Action)) return false; Action that = (Action)other; return (this.type == that.type) && (this.info == that.info); } /** * Returns a hash code for this action. */ public override int GetHashCode () { return type ^ info; } /** * Returns a string representation for this action. */ public override string ToString () { switch (type) { case REDUCE: return "R"+info; case SHIFT: return "S"+info; case DYNAMIC: return "D"+info; case CHOICE: return "C"+info; case ACCEPT: return "A"; default: return "E"; } } } }