internal void AddFlag <T>(Flag <T> flag) { foreach (var name in flag.Name.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { Formal.Add(name.Trim(), flag); } }
public Formal AddFormal(InputElement id, MessageWriter msg) { Formal f = new Formal(id, locals); f.Add(id, msg); signature.Add(f); return(f); }
/// <summary> /// Pass a user-implemented IFlag directly to the FlagSet /// </summary> /// <typeparam name="T"></typeparam> /// <param name="flag"></param> /// <returns></returns> public T Var <T>(T flag) where T : IFlag { if (Formal != null && Formal.ContainsKey(flag.Name)) { var msg = Name == "" ? $"flag redefined: {flag.Name}" : $"{Name} flag redefined: {flag.Name}"; Output().WriteLine(msg); throw new InvalidOperationException(msg); } if (Formal == null) { Formal = new Dictionary <string, IFlag>(); } Formal.Add(flag.Name, flag); return(flag); }