Example #1
0
        public static CLType Parse(string s)
        {
            var m = Regex.Match(s.Trim(), @"^(?<type>[a-z]+)(?<dim>\d*)(?<isPointer>\*?)$");

            if (!m.Success)
            {
                return(null);
            }
            var result = new CLType();

            result.IsPointer = m.Groups["isPointer"].Value != "";
            result.Dim       = 1;
            if (m.Groups["dim"].Value != "")
            {
                result.Dim = int.Parse(m.Groups["dim"].Value);
            }
            result.BaseType = m.Groups["type"].Value;

            return(result);
        }
Example #2
0
        private static List <FunctionArgument> ParseFuncArgs(string text)
        {
            List <FunctionArgument> res = new List <FunctionArgument>();
            var parts = text.Trim().Split(',');

            foreach (var part in parts)
            {
                var parts2 = part.Split(new char[] { ' ', '*' }, StringSplitOptions.RemoveEmptyEntries);
                if (parts2.Length < 2)
                {
                    continue;
                }
                bool isPointer = part.Contains("*");
                var  arg       = new FunctionArgument()
                {
                    name = parts2[parts2.Length - 1], type = CLType.Parse(parts2[parts2.Length - 2] + (isPointer ? "*" : ""))
                };
                res.Add(arg);
            }

            return(res);
        }
Example #3
0
        public static List <ExplorerItem> BuildExplorerItems(Range range)
        {
            List <ExplorerItem> list = new List <ExplorerItem>();

            foreach (var r in range.GetRanges(FuncSignatureRegex))
            {
                var m = FuncSignatureParserRegex.Match(r.Text);
                if (!m.Success)
                {
                    continue;
                }
                var item = new ExplorerItem()
                {
                    type = ExplorerItemType.Method, line = r.Start.iLine, funcName = m.Groups["name"].Value, funcType = CLType.Parse(m.Groups["type"].Value)
                };
                item.args = ParseFuncArgs(m.Groups["args"].Value);
                list.Add(item);
            }

            list.Sort(new ExplorerItemComparer());

            return(list);
        }