public (RegexLexer, PrototypeDictionary, Rules <IASTNode>) ParseParser(string code) { pd = new PrototypeDictionary(); resultSd = new SymbolDictionary(); var tokens = pl.ParseAll(code).ToList(); return(((RegexLexer, PrototypeDictionary, Rules <IASTNode>))pParser.Parse(tokens)); }
public static PrototypeDictionary ConvertToDictionary(Type type, object obj, bool showNonPublic) { var flags = BindingFlags.Public | (obj == null ? BindingFlags.Static : BindingFlags.Instance) | BindingFlags.FlattenHierarchy; if (showNonPublic) { flags |= BindingFlags.NonPublic; } var members = type.GetMembers(flags); var dict = new PrototypeDictionary(); foreach (var m in members) { var name = m.Name; object value = null; try { if (m is PropertyInfo) { var p = (PropertyInfo)m; if (p.GetGetMethod() != null && p.GetGetMethod().GetParameters().Length == 0) { value = p.GetValue(obj, new object[0]); dict[name.LispName()] = value; } } else if (m is FieldInfo) { var f = (FieldInfo)m; value = f.GetValue(obj); dict[name.LispName()] = value; } } catch { } } return dict; }
//[Lisp( "get-lexical-variables-dictionary" )] public static Prototype GetLexicalVariablesDictionary(int pos) { Frame frame = GetFrameAt(pos); if (frame == null) { return null; } var env = new PrototypeDictionary(); for (; frame != null; frame = frame.Link) { if (frame.Names != null) { for (var i = 0; i < frame.Names.Count; ++i) { var key = frame.Names[i].DiagnosticsName; object value = null; if (frame.Values != null && i < frame.Values.Count) { value = frame.Values[i]; } if (key == Symbols.Tilde.Name) { if (frame == CurrentThreadContext.Frame) { env[key] = value; } else if (!env.ContainsKey(key)) { env[key] = value; } } else if (!env.ContainsKey(key)) { env[key] = value; } } } } return Prototype.FromDictionary(env); }
//[Lisp( "get-global-variables-dictionary" )] public static Prototype GetGlobalVariablesDictionary(string pattern) { var env = new PrototypeDictionary(); var pat = (pattern ?? "").ToLower(); foreach (var package in Packages.Values) { if (package.Name != "") { foreach (Symbol sym in package.Dict.Values) { var name = sym.DiagnosticsName; if (!sym.IsUndefined && (pattern == null || name.ToLower().IndexOf(pat) != -1)) { env[name] = sym.Value; } } } } return Prototype.FromDictionary(env); }
//[Lisp( "get-dynamic-variables-dictionary" )] public static Prototype GetDynamicVariablesDictionary(int pos) { var env = new PrototypeDictionary(); for (var entry = GetSpecialVariablesAt(pos); entry != null; entry = entry.Link) { var key = entry.Sym.DiagnosticsName; if (!env.ContainsKey(key)) { env[key] = entry.Value; } } return Prototype.FromDictionary(env); }
public static PrototypeDictionary ConvertToLispDictionary(IDictionary obj, bool caseInsensitive) { var dict = new PrototypeDictionary(caseInsensitive); foreach (DictionaryEntry item in obj) { dict[item.Key] = item.Value; } return dict; }