protected virtual void PopulateFirstCache() { LookaheadRule temp = new LookaheadRule(); foreach (var v in skipList) { temp.Repurpose(v.Key); temp.Repurpose(v.Value); First(temp, 0); } }
protected virtual void PopulateSinglesCache() { var symbs = TargetGrammar.TerminalSymbols.Concat(new string[] { TerminateSymbol }).ToArray(); for (int i = 0; i < TargetGrammar.Count; i++) { var v = TargetGrammar[i]; singles[v.Name] = new Dictionary <string, Dictionary <AdvanceableProduction, LookaheadRule> >(); var ii = initialListing[v]; for (int j = 0; j < ii.Count; j++) { var p = ii[j]; for (int k = 0; k < symbs.Length; k++) //foreach(var symb in TargetGrammar.TerminalSymbols.Concat(new string[] { TerminateSymbol } )) { var symb = symbs[k]; if (!singles[v.Name].ContainsKey(symb)) { singles[v.Name][symb] = new Dictionary <AdvanceableProduction, LookaheadRule>(); } var iter = p; while (iter.HasNext) { var tmp = advancementDict[iter]; LookaheadRule lr = new LookaheadRule(); lr.Repurpose(v.Name); lr.LookaheadSymbol = symb; lr.Add(tmp); singles[v.Name][symb][iter] = lr; iter = tmp; } LookaheadRule lr2 = new LookaheadRule(); lr2.Repurpose(v.Name); lr2.LookaheadSymbol = symb; lr2.Add(iter); singles[v.Name][symb][iter] = lr2; } } } }