示例#1
0
        private static void UpdateXshdWithScriptInfo(XDocument doc, OpcodeLookup opcodes)
        {
            XNamespace df                = doc.Root.Name.Namespace;
            var        keyWords          = doc.Root.Descendants(df + "Keywords");
            XElement   scriptTypeElement = keyWords.Where(x => x.Attribute("color")?.Value == "ScriptType")?.First();
            XElement   valueTypeElement  = keyWords.Where(x => x.Attribute("color")?.Value == "ValueType")?.First();
            XElement   functionElement   = keyWords.Where(x => x.Attribute("color")?.Value == "Function")?.First();

            foreach (string scriptType in opcodes.GetAllScriptTypeNames())
            {
                XElement element = StringToWordElement(scriptType, df);
                scriptTypeElement.Add(element);
            }

            foreach (string type in opcodes.GetAllValueTypeNames())
            {
                XElement element = StringToWordElement(type, df);
                valueTypeElement.Add(element);
            }

            foreach (string function in opcodes.GetAllUniqueFunctionNames())
            {
                XElement element = StringToWordElement(function, df);
                functionElement.Add(element);
            }
        }
示例#2
0
        private void CreateRegex()
        {
            string valueTypePattern  = "(?<ValueType>" + string.Join("|", _opcodes.GetAllValueTypeNames()) + ")";
            string scriptTypePattern = "(?<ScriptType>" + string.Join("|", _opcodes.GetAllScriptTypeNames()) + ")";
            string scriptPattern     = @"\bscript\s+" + scriptTypePattern + @"\s+" + valueTypePattern + @"\s+(?<Name>\S+)";
            string globalsPattern    = @"\bglobal\s+" + valueTypePattern + @"\s+(?<Name>\S+)";

            _scriptRegex  = new Regex(scriptPattern, RegexOptions.Compiled);
            _globalsRegex = new Regex(globalsPattern, RegexOptions.Compiled);
        }