Exemplo n.º 1
0
        public void Parse(string text, int start, int end)
        {
            _tags.Clear();
            if (text.IsNullOrEmpty() || end <= start)
            {
                return;
            }


            var wordStart = 0;

            for (var ii = start; ii < end; ii++)
            {
                if (!_syntaxProvider.IsSeparator(text[ii]))
                {
                    continue;
                }
                if (ii > 0 && !(_syntaxProvider.IsSeparator(text[ii - 1])))
                {
                    var wordEnd = ii;
                    var word    = text.Substring(wordStart, wordEnd - wordStart);

                    var type = _syntaxProvider.GetTypeOf(word);
                    if (type != TagType.Nothing)
                    {
                        var tag = new Tag
                        {
                            Type          = type,
                            StartPosition = wordStart,
                            Length        = word.Length,
                        };
                        _tags.Add(tag);
                    }
                }
                wordStart = ii + 1;
            }

            _tags.AddRange(GetCodeBlockTagsIn(text));
            _tags.AddRange(GetStringsTagsIn(text));
            _tags.AddRange(GetParameterTagsIn(text));
        }
Exemplo n.º 2
0
        private string GetWord(string text)
        {
            var lastIndex = text.Length;
            var start     = lastIndex - 1;

            while (start > 0)
            {
                if (_syntaxProvider.IsSeparator(text[start - 1]))
                {
                    break;
                }
                start--;
            }

            var end = lastIndex - 1;

            while (end < lastIndex && !_syntaxProvider.IsSeparator(text[end]))
            {
                end++;
            }

            return(text.Substring(start, end - start));
        }