Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 /// <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);
 }
Ejemplo n.º 3
0
 /// <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();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes this body as empty
 /// </summary>
 public RuleChoice()
 {
     parts     = new List <RuleBodyElement>();
     setFirsts = new TerminalSet();
 }
Ejemplo n.º 5
0
 /// <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();
 }