private string dumpNfaCell(NfaCell <int, object> nfaCell, string symbolTypeName, Func <int, string> symbolNameConvert, string treeNodeName) { string code_str = null; if (nfaCell.ProductionUserAction != null) { // launch the fake action to retrieve the code of the action stored as string CodeLambda code = (CodeLambda)nfaCell.ProductionUserAction.Code(null); code_str = "ProductionAction<" + treeNodeName + ">.Convert(" + code.Make() + "," + code.RhsUnusedParamsCount + ")"; //code_str = (string)nfaCell.ProductionUserAction(null); } return("NfaCell<" + symbolTypeName + "," + treeNodeName + ">.Create(" + Environment.NewLine + symbolNameConvert(nfaCell.LhsSymbol) + "," + Environment.NewLine + nfaCell.RhsSeenCount + "," + Environment.NewLine + (!nfaCell.RecoveryTerminals.Any() ? CodeWords.Null : (CodeWords.New + "[]{" + nfaCell.RecoveryTerminals.Select(it => symbolNameConvert(it)).Join(",") + "}")) + "," + Environment.NewLine // markings are really raw ints (they are not symbols) + nfaCell.ProductionMark + "," + Environment.NewLine + "\"" + nfaCell.ProductionCoordinates + "\"," + Environment.NewLine + (nfaCell.ProductionTabooSymbols.Any(col => col.Count > 0) ? (CodeWords.New + " []{" + String.Join(",", nfaCell.ProductionTabooSymbols.Select(col => CodeWords.New + " HashSet<int>(" + CodeWords.New + " int[]{" + String.Join(",", col.Select(it => it)) + "})")) + "}") : CodeWords.Null) + "," + Environment.NewLine + (code_str == null ? CodeWords.Null : code_str) + ")" + Environment.NewLine); }
internal string Add(CodeLambda code) { if (code == null) { throw new ArgumentNullException(); } var key = code.Make(); Tuple <int, HashSet <string> > value; if (!revRegistry.TryGetValue(key, out value)) { value = Tuple.Create(revRegistry.Count, new HashSet <string>()); revRegistry.Add(key, value); } value.Item2.Add(code.LhsSymbol); return(functionEntryName(value.Item1)); }