public static void Closure(LRConfigSet ConfigSet) { LRConfigSet setB = new LRConfigSet(); short num3 = (short)(ConfigSet.Count() - 1); for (short i = 0; i <= num3; i = (short)(i + 1)) { LRConfig config2 = ConfigSet[i]; LookaheadSymbolSet set = TotalLookahead(config2); SymbolBuild build = config2.NextSymbol(0); if ((build != null) && (build.Type == SymbolType.Nonterminal)) { LRConfigSet partialClosure = build.PartialClosure; short num4 = (short)(partialClosure.Count() - 1); for (short j = 0; j <= num4; j = (short)(j + 1)) { LRConfig config = partialClosure[j]; LRConfig item = new LRConfig(config.Parent, 0, config.LookaheadSet); if (config.InheritLookahead) { item.LookaheadSet.UnionWith(set); } setB.Add(item); } } } ConfigSet.UnionWith(setB); }
private static LRConfigSet GetClosureConfigSet(SymbolBuild Sym) { bool flag; LRConfig config; short num2; SymbolBuild build; LRConfig config2; ProductionBuild build2; LRConfigSet setB = new LRConfigSet(); LRConfigSet set = new LRConfigSet(); short num3 = (short)(BuilderApp.BuildTables.Production.Count() - 1); short num = 0; while (num <= num3) { build2 = BuilderApp.BuildTables.Production[num]; if (build2.Head.IsEqualTo(Sym)) { config2 = new LRConfig { Position = 0, Modified = true, LookaheadSet = new LookaheadSymbolSet(), Parent = build2, InheritLookahead = true }; set.Add(config2); } num = (short)(num + 1); } do { setB.Clear(); flag = false; short num4 = (short)(set.Count() - 1); num2 = 0; while (num2 <= num4) { config = set[num2]; if (!config.IsComplete() & config.Modified) { build = config.NextSymbol(0); if (build.Type == SymbolType.Nonterminal) { short num5 = (short)(BuilderApp.BuildTables.Production.Count() - 1); num = 0; while (num <= num5) { build2 = BuilderApp.BuildTables.Production[num]; if (build2.Head.IsEqualTo(build)) { config2 = new LRConfig(build2, 0, TotalLookahead(config)); setB.Add(config2); } num = (short)(num + 1); } } set[num2].Modified = false; } num2 = (short)(num2 + 1); } }while (set.UnionWith(setB)); do { flag = false; short num6 = (short)(set.Count() - 1); for (num2 = 0; num2 <= num6; num2 = (short)(num2 + 1)) { config = set[num2]; build = config.NextSymbol(0); if ((build != null) && ((config.InheritLookahead & PopulateLookahead(config)) & (build.Type == SymbolType.Nonterminal))) { short num7 = (short)(set.Count() - 1); for (num = 0; num <= num7; num = (short)(num + 1)) { config = set[num]; if (((config.Position == 0) & config.Parent.Head.IsEqualTo(build)) & !config.InheritLookahead) { config.InheritLookahead = true; flag = true; } } } } }while (flag); return(set); }