public void MakeFunctor(string name, ExprFunc exprFunc, SymbolKindEnum symbol = SymbolKindEnum.FUNCTION) { if (String.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException("name"); } if (exprFunc == null) { throw new ArgumentNullException("exprFunc"); } // Search optimization if (name.EndsWith("_")) { name = name.Remove(name.Length - 1); } IDictionary <string, ExprOp> items = GetOrCreate(symbol); ExprOp op; if (items.TryGetValue(name, out op)) { throw new InvalidOperationException(String.Format("Functor '{0}' is already defined", name)); } items.Add(name, ExprOp.WrapFunctor(exprFunc)); }
public void MakeOptionHandlers(OptionCollection options) { if (options == null) { throw new ArgumentNullException("options"); } Tuple <OptionCollection, IDictionary <Option, ExprOp> > optionItems = new Tuple <OptionCollection, IDictionary <Option, ExprOp> > (options, new Dictionary <Option, ExprOp>()); foreach (Option option in options.Options) { optionItems.Item2[option] = ExprOp.WrapFunctor(scope => option.Handler((CallScope)scope)); } LookupKindOptionItems.Add(SymbolKindEnum.OPTION, optionItems); }