Ejemplo n.º 1
0
        private MyArrayList GenerateFollowList(MyArrayList NonTerms)
        {
            MyArrayList Follows = new MyArrayList();

            for (int i = 0; i < NonTerms.Count; i++)
            {
                RuleElement re     = (RuleElement)NonTerms[i];
                RuleStart   rs     = re.GetBegin();
                BNFRule     rl     = rs.GetRuleConnect();
                RuleElement nextRe = re.GetNext();
                if (nextRe == null)
                {
                    Follows = ParseHelper.UnionSet(Follows, rl.FollowSet);
                }
                else
                {
                    if (nextRe.IsTerminal())
                    {
                        Follows.Add(nextRe);
                    }
                    else
                    {
                        RuleToken   rt          = (RuleToken)nextRe;
                        MyArrayList AllFirstSet = BetaTotalRuleFirstSet(rt);
                        Follows = ParseHelper.UnionSet(Follows, AllFirstSet);
                        if (!BetaTotalRuleEpsFree(rt))
                        {
                            Follows = ParseHelper.UnionSet(Follows, rl.FollowSet);
                        }
                    }
                }
            }
            return(Follows);
        }