public Production <SYMBOL_ENUM, TREE_NODE> AddProduction(SYMBOL_ENUM nonterm, RecursiveEnum recursive, Func <TREE_NODE> action) { return(addProduction(new Production <SYMBOL_ENUM, TREE_NODE>(symbolsRep, nonterm, recursive, new SYMBOL_ENUM[] { }, ProductionAction <TREE_NODE> .Convert(action)))); }
public Production <SYMBOL_ENUM, TREE_NODE> AddProduction(SYMBOL_ENUM nonterm, RecursiveEnum recursive, SYMBOL_ENUM s1, SYMBOL_ENUM s2, SYMBOL_ENUM s3, SYMBOL_ENUM s4, Func <object, object, object, object, TREE_NODE> action) { return(addProduction(new Production <SYMBOL_ENUM, TREE_NODE>(symbolsRep, nonterm, recursive, new SYMBOL_ENUM[] { s1, s2, s3, s4 }, ProductionAction <TREE_NODE> .Convert(action)))); }
public Production <SYMBOL_ENUM, TREE_NODE> AddProduction(SYMBOL_ENUM nonterm, RecursiveEnum recursive, SYMBOL_ENUM s1, SYMBOL_ENUM s2, SYMBOL_ENUM s3, Func <object, object, object, TREE_NODE> action, int identityParamIndex = Production.NoIdentityFunction) { return(addProduction(new Production <SYMBOL_ENUM, TREE_NODE>(symbolsRep, nonterm, recursive, new SYMBOL_ENUM[] { s1, s2, s3 }, ProductionAction <TREE_NODE> .Convert(action), identityParamIndex))); }
private void feedProdBuilder(IEnumerable <ProductionInfo> prodInfos) { // we have to make sure, that the identical code (as string) is converted into identical code (as C#) // otherwise each production would get different C# code reference, which would make DFA builder think every action is unique var user_actions_pool = new Dictionary <CodeLambda, UserActionInfo <object> >(); foreach (ProductionInfo prod_info in prodInfos) { Production <int, object> production = productionBuilder.AddProduction(grammar.GetSymbolId(prod_info.LhsSymbol), prod_info.Recursive, prod_info.RhsSymbols.Select(it => grammar.GetSymbolId(it.SymbolName)).ToArray()); production.MarkWith = prod_info.EffectiveMarkedWith; production.TabooSymbols = prod_info.TabooSymbols; production.PositionDescription = "Action for \\\"" + prod_info.LhsSymbol + "\\\" " + (prod_info.Position.Equals(SymbolPosition.None) ? ("added by NLT generator for " + prod_info.CodeComment) : ("at " + prod_info.Position.XYString())); if (prod_info.ActionCode != null) { UserActionInfo <object> func; if (!user_actions_pool.TryGetValue(prod_info.ActionCode, out func)) { // this dummy variable serves as anti-closure, so DO NOT remove it CodeLambda anti_capture = prod_info.ActionCode; func = ProductionAction <object> .Convert(() => anti_capture, anti_capture.RhsUnusedParamsCount); user_actions_pool.Add(prod_info.ActionCode, func); } production.UserAction = func; if (prod_info.IdentityOuterFunctionParamIndex != ProductionInfo.NoIdentityFunction) { production.IdentityOuterFunctionParamIndex = prod_info.IdentityOuterFunctionParamIndex; } } } }