//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ // PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\ //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ using System.Collections; using Ilog.Language.Util; namespace Ilog.Language.Syntax { /** * This the class of objects stored in the path table of a nonterminal. * It consists of a sequence of rule paths between a pair of nonterminals, * and a set of terminals, which is the union of all the FIRST sets of * these paths. It also contains the start and end nonterminals. * * @version Last modified on Sat May 21 20:22:00 2005 by hak * @author Hassan Aït-Kaci * @copyright © 2000 ILOG, S.A. */ internal class RulePaths { /** * The nonterminal at the origin of the paths. */ private NonTerminal start; internal NonTerminal Start { get { return start; } } /** * The nonterminal at the end of the paths. */ private NonTerminal end; internal NonTerminal End { get { return end; } } /** * The arrayList of paths. */ private ArrayList paths; internal ArrayList Paths { get { return paths; } } /** * The FIRST set; it is the union of all paths between Start and End. */ private SetOf first; internal SetOf First { get { return first; } } /** * This is true whenever one of the paths in this derives * the EMPTY symbol. */ private bool isNullable; internal bool IsNullable { get { return isNullable; } } //\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\ /** * Constructs a new Paths object with the given rule path. */ internal RulePaths (RulePath path) { (paths = new ArrayList()).Add(path); start = path.Start; end = path.End; first = new SetOf(path.First); start.Paths.Add(path); isNullable = path.IsNullable; } /** * Adds the given path to this Paths object, and returns true * iff the given path contributes to the FIRST union or empty derivation. */ internal bool Add (RulePath path) { if ((path.First <= first) && (isNullable || !path.IsNullable)) return false; paths.Add(path); path.Start.Paths.Add(path); first.Union(path.First); isNullable |= path.IsNullable; return true; } } }