private LuaInnerTable():base(null,null) { string[] global = { "assert", "collectgarbage", "dofile", "error", "getfenv", "getmetatable", "ipairs", "load", "loadfile", "loadstring", "module", "next", "pairs", "pcall", "print", "rawequal", "rawget", "rawset", "require", "select", "setfenv", "setmetatable", "tonumber", "tostring", "type", "unpack", "xpcall", "class", "new", "delete" }; foreach (var str in global) { this.Members.Add(new LuaFunction(str, -1, null)); } var tbs = new Dictionary<string, HashSet<string>>(); tbs["coroutine"] = new HashSet<string>() { "create", "resume", "running", "status", "wrap", "yield", }; tbs["debug"] = new HashSet<string>() { "debug", "getfenv", "gethook", "getinfo", "getlocal", "getmetatable", "getregistry", "getupvalue", "setfenv", "sethook", "setlocal", "setmetatable", "setupvalue", "traceback", }; tbs["io"] = new HashSet<string>() { "close", "flush", "input", "lines", "open", "output", "popen", "read", "stderr", "stdin", "stdout", "tmpfile", "type", "write", }; tbs["math"] = new HashSet<string>() { "abs", "acos", "asin", "atan", "atan2", "ceil", "cos", "cosh", "deg", "exp", "floor", "fmod", "frexp", "huge", "ldexp", "log", "log10", "max", "min", "modf", "pi", "pow", "rad", "random", "randomseed", "sin", "sinh", "sqrt", "tan", "tanh", }; tbs["os"] = new HashSet<string>() { "clock", "date", "difftime", "execute", "exit", "getenv", "remove", "rename", "setlocale", "time", "tmpname", }; tbs["package"] = new HashSet<string>() { "cpath", "loaded", "loaders", "loadlib", "path", "preload", "seeall", }; tbs["string"] = new HashSet<string>() { "byte", "char", "dump", "find", "format", "gmatch", "gsub", "len", "lower", "match", "rep", "reverse", "sub", "upper", }; tbs["table"] = new HashSet<string>() { "concat", "sort", "maxn", "remove", "insert", }; foreach (var tb in tbs) { LuaTable lt = new LuaTable(tb.Key, -1); foreach (var st in tb.Value) { lt.AddFunction(new LuaFunction(st, -1, null)); } this.AddTable(lt); } string[] keywords = {"and","break","do","else","elseif", "end","false","for","function","if", "in","local","nil","not","or", "repeat","return","then","true","until","while"}; foreach (var str in keywords) { this.Members.Add(new LuaMember(str,-1,-1)); } }
void HandleTableConstructor(Token token, ParseTreeNode node) { var table = new LuaTable(File, token.ValueString, token.Location.Line); var fieldlist = node.ChildNodes[1].ChildNodes[0]; if (fieldlist.ChildNodes != null && fieldlist.ChildNodes.Count > 0) { fieldlist = fieldlist.ChildNodes[0]; var fields = new List<ParseTreeNode>(); FilterChildren(fieldlist, LuaTerminalNames.Field, ref fields, 2); foreach (var field in fields) { var exp = field.ChildNodes.Last().ChildNodes[0]; if (field.ChildNodes.Count == 3)// name = xxx { if (exp.Term.Name == LuaTerminalNames.NamelessFunction) { table.AddFunction(new LuaFunction(field.ChildNodes[0].Token.Text, field.ChildNodes[0].Token.Location.Line, GetFunctionArgs(exp.ChildNodes[1]))); } else table.Members.Add(new LuaMember(field.ChildNodes[0].Token)); } else if (field.ChildNodes.Count == 5)//[expr] = xxx { var expr = field.ChildNodes[1]; if (expr.ChildNodes.Count == 1 && expr.ChildNodes[0].Term.Name == LuaTerminalNames.String) { if (exp.Term.Name == LuaTerminalNames.NamelessFunction) { table.AddFunction(new LuaFunction(expr.ChildNodes[0].Token.ValueString, expr.ChildNodes[0].Token.Location.Line, GetFunctionArgs(exp.ChildNodes[1]))); } else table.Members.Add(new LuaMember(expr.ChildNodes[0].Token)); } } } } File.AddTable(table); }
public static ClassificationTag GetTag(Irony.Parsing.Token token) { ClassificationTag tag = null; if (token.EditorInfo.Type == Irony.Parsing.TokenType.Identifier) { if (UserTags != null) { for (int i = 0; i < UserTags.Count; i++) { if (Users[i].Contains(token.Text)) tag = UserTags[i]; } } if (m_table != null) { var mem = m_table.Members.Find((lm) => { return lm is LuaFunction && lm.Name == token.Text; }); if (mem != null) { m_table = null; m_clear = false; if (tag == null) tag = LuaFunctionTag; } else if (m_clear == true) { m_table = null; m_clear = false; } else { m_clear = true; } } else if (IntellisenseHelper.ContainsFunction(token.Text)) { if (tag == null) tag = LuaFunctionTag; } else if ((m_table = IntellisenseHelper.GetTable(token.Text)) != null) { if (tag == null) tag = LuaTableTag; } } if(OtherTags.ContainsKey(token.EditorInfo.Type) && tag == null) tag = OtherTags[token.EditorInfo.Type]; return tag; }