//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ using Ilog.Language.Util; using Ilog.Language.Tools; namespace Ilog.Language.Parsing { using Stack = Util.Stack; using IList = System.Collections.IList; /** * This implements the type of choice points pushed on the choice * stack by a dynamic parser. * * @see DynamicParser * * @version Last modified on Sun May 29 09:18:03 2005 by hak * @author Hassan Aït-Kaci * @copyright © 2000 ILOG, S.A. */ internal class Choice : TimeStamped { /** * Constructs an empty choice point. */ internal Choice () { options = new Stack(2); } /** * Constructs an empty choice point with the specified * option stack size. */ internal Choice (int size) { options = new Stack(size); } /** * Constructs a choice point with the specified option stack. */ internal Choice (Stack options) { this.options = options; } /** * This choice point's time stamp. */ private long stamp; public long TimeStamp { get { return stamp; } set { stamp = value; } } /** * This is true iff this choice point is among dynamic tokens. * This is true by default. */ private bool isTokenChoice = true; internal bool IsTokenChoice { get { return isTokenChoice; } set { isTokenChoice = value; } } /** * This choice point's option stack. */ private Stack options; internal Stack Options { get { return options; } } /** * This is true iff there no options left for this choice point. */ internal bool IsEmpty { get { return options.Count == 0; } } /** * Adds the specified object as an option for this choice point. */ internal void AddOption (object elt) { options.Push(elt); } /** * Adds the specified list of objects as options for this choice * point. */ internal void AddOptions (Stack stack) { foreach (object elt in stack) options.Push(elt); } /** * Returns a string description of this choice point. */ public override string ToString () { return Misc.View(options,"(stamp:"+TimeStamp+") ",18,64); } } }