private void CalculateLookAhead(ProductionPatternAlternative alt, int pos)
        {
            var previous = new LookAheadSet(0);
            var length   = 1;
            var flag     = pos >= alt.Count;

            if (!flag)
            {
                var pattern = alt.Pattern;
                var elem    = alt[pos];
                var flag2   = elem.MinCount == elem.MaxCount;
                if (flag2)
                {
                    this.CalculateLookAhead(alt, pos + 1);
                }
                else
                {
                    var first     = this.FindLookAhead(elem, 1, new CallStack(), null);
                    var follow    = this.FindLookAhead(alt, 1, pos + 1, new CallStack(), null);
                    var location  = "at position " + Conversions.ToString(pos + 1);
                    var conflicts = this.FindConflicts(pattern.Name, location, first, follow);
                    while (conflicts.Size() > 0)
                    {
                        length++;
                        conflicts.AddAll(previous);
                        first          = this.FindLookAhead(elem, length, new CallStack(), conflicts);
                        follow         = this.FindLookAhead(alt, length, pos + 1, new CallStack(), conflicts);
                        first          = first.CreateCombination(follow);
                        elem.LookAhead = first;
                        var flag3 = first.Intersects(conflicts);
                        if (flag3)
                        {
                            first = first.CreateIntersection(conflicts);
                            this.ThrowAmbiguityException(pattern.Name, location, first);
                        }
                        previous  = conflicts;
                        conflicts = this.FindConflicts(pattern.Name, location, first, follow);
                    }
                    this.CalculateLookAhead(alt, pos + 1);
                }
            }
        }
Exemple #2
0
        public bool Equals(ProductionPatternAlternative alt)
        {
            var  flag = this.elements.Count != alt.elements.Count;
            bool equals;

            if (flag)
            {
                equals = false;
            }
            else
            {
                var num = this.elements.Count - 1;
                for (var i = 0; i <= num; i++)
                {
                    var flag2 = !this.elements[i].Equals(RuntimeHelpers.GetObjectValue(alt.elements[i]));
                    if (flag2)
                    {
                        return(false);
                    }
                }
                equals = true;
            }
            return(equals);
        }