Antlr4.Codegen.Model.RuleFunction.GetDeclsForAllElements C# (CSharp) Метод

GetDeclsForAllElements() публичный Метод

public GetDeclsForAllElements ( IList altASTs ) : ISet
altASTs IList
Результат ISet
        public virtual ISet<Decl.Decl> GetDeclsForAllElements(IList<AltAST> altASTs)
        {
            ISet<string> needsList = new HashSet<string>();
            ISet<string> optional = new HashSet<string>();
            ISet<string> suppress = new HashSet<string>();
            IList<GrammarAST> allRefs = new List<GrammarAST>();
            foreach (AltAST ast in altASTs)
            {
                IntervalSet reftypes = new IntervalSet(ANTLRParser.RULE_REF, ANTLRParser.TOKEN_REF);
                IList<GrammarAST> refs = ast.GetNodesWithType(reftypes);
                foreach (var @ref in refs)
                    allRefs.Add(@ref);

                System.Tuple<FrequencySet<string>, FrequencySet<string>> minAndAltFreq = GetElementFrequenciesForAlt(ast);
                FrequencySet<string> minFreq = minAndAltFreq.Item1;
                FrequencySet<string> altFreq = minAndAltFreq.Item2;
                foreach (GrammarAST t in refs)
                {
                    string refLabelName = GetLabelName(rule.g, t);
                    if (altFreq.GetCount(refLabelName) == 0)
                    {
                        suppress.Add(refLabelName);
                    }
                    if (minFreq.GetCount(refLabelName) == 0)
                    {
                        optional.Add(refLabelName);
                    }
                    if (altFreq.GetCount(refLabelName) > 1)
                    {
                        needsList.Add(refLabelName);
                    }
                }
            }

            ISet<Decl.Decl> decls = new LinkedHashSet<Decl.Decl>();
            foreach (GrammarAST t in allRefs)
            {
                string refLabelName = GetLabelName(rule.g, t);
                if (suppress.Contains(refLabelName))
                {
                    continue;
                }

                IList<Decl.Decl> d = GetDeclForAltElement(t,
                                                    refLabelName,
                                                    needsList.Contains(refLabelName),
                                                    optional.Contains(refLabelName));
                decls.UnionWith(d);
            }

            return decls;
        }