/// <summary> /// Computes the FIRSTS set for this variable /// </summary> /// <returns><c>true</c> if there has been modifications</returns> public bool ComputeFirsts() { bool mod = false; foreach (Rule rule in rules) { TerminalSet rulefirsts = rule.Body.Firsts; if (rulefirsts != null) { mod |= firsts.AddRange(rulefirsts); } mod |= rule.Body.ComputeFirsts(); } return(mod); }
/// <summary> /// Initializes this set as a copy of the given set /// </summary> /// <param name="copied">The set to copy</param> public TerminalSet(TerminalSet copied) { content = new SortedList <int, Terminal>(copied.content); }
/// <summary> /// Initializes this body as containing a single element /// </summary> /// <param name="symbol">The single element's symbol</param> public RuleChoice(Symbol symbol) { parts = new List <RuleBodyElement>(); parts.Add(new RuleBodyElement(symbol, TreeAction.None)); setFirsts = new TerminalSet(); }
/// <summary> /// Initializes this body as empty /// </summary> public RuleChoice() { parts = new List <RuleBodyElement>(); setFirsts = new TerminalSet(); }
/// <summary> /// Initializes this symbol /// </summary> /// <param name="sid">The symbol's unique identifier</param> /// <param name="name">The symbol's name</param> public Variable(int sid, string name) : base(sid, name) { rules = new List <Rule>(); firsts = new TerminalSet(); followers = new TerminalSet(); }