protected void TryExtractTo(List<CodeLexem> res, ref SourcePart text, string lex, LexemType type, string except = null)
 {
     var index = text.IndexOf(lex);
     if (except != null)
     {
         while (index >= 0 && text.Substring(0, index + 1).EndsWith(except))
         {
             index = text.IndexOf(lex, index + 1);
         }
     }
     
     if (index < 0)
         return;
     
     LineBreaks(res, ref text, index + lex.Length, type);
 }
Example #2
0
        private void ParseJsonPropertyName(ICollection<CodeLexem> res, ref SourcePart text)
        {
            var index = text.IndexOf("\":");
            if (index <= 0)
                return;

            res.Add(new CodeLexem(LexemType.Property, CutString(ref text, index)));
        }
        protected void ParseValue(List<CodeLexem> res, ref SourcePart text)
        {
            const string lex = "\"";
            var index = text.IndexOf(lex);

            if (index < 0)
                return;
            
            LineBreaks(res, ref text, index + lex.Length - 1, LexemType.Value);
        }
Example #4
0
        protected void TryExtractTo(List <CodeLexem> res, ref SourcePart text, string lex, LexemType type, string except = null)
        {
            var index = text.IndexOf(lex);

            if (except != null)
            {
                while (index >= 0 && text.Substring(0, index + 1).EndsWith(except))
                {
                    index = text.IndexOf(lex, index + 1);
                }
            }

            if (index < 0)
            {
                return;
            }

            LineBreaks(res, ref text, index + lex.Length, type);
        }
Example #5
0
        private void ParseJsonPropertyName(ICollection <CodeLexem> res, ref SourcePart text)
        {
            var index = text.IndexOf("\":");

            if (index <= 0)
            {
                return;
            }

            res.Add(new CodeLexem(LexemType.Property, CutString(ref text, index)));
        }
Example #6
0
        protected void ParseValue(List <CodeLexem> res, ref SourcePart text)
        {
            const string lex   = "\"";
            var          index = text.IndexOf(lex);

            if (index < 0)
            {
                return;
            }

            LineBreaks(res, ref text, index + lex.Length - 1, LexemType.Value);
        }
 private void ParseXmlKeyWord(ICollection<CodeLexem> res, ref SourcePart text, LexemType type)
 {
     var index = text.IndexOfAny(XmlEndOfTerm);
     if (index <= 0)
         return;
     
     var delimiterIndex = text.IndexOf(XmlNamespaceDelimeter);
     if (delimiterIndex > 0 && delimiterIndex < index)
     {
         res.Add(new CodeLexem(type, CutString(ref text, delimiterIndex)));
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
         res.Add(new CodeLexem(type, CutString(ref text, index - delimiterIndex - 1)));
         return;
     }
     res.Add(new CodeLexem(type, CutString(ref text, index)));
 }
        protected void LineBreaks(List<CodeLexem> res, ref SourcePart text, int to, LexemType type)
        {
            while (text.Length > 0 && to > 0)
            {
                var index = text.IndexOf("\n");
                if (index >= to)
                {
                    res.Add(new CodeLexem(type, CutString(ref text, to)));
                    return;
                }

                if (index != 0)
                {
                    res.Add(new CodeLexem(type, CutString(ref text, index)));
                }

                res.Add(new CodeLexem(LexemType.LineBreak, CutString(ref text, 1)));
                to -= index + 1;
            }
        }
Example #9
0
        private void ParseXmlKeyWord(ICollection <CodeLexem> res, ref SourcePart text, LexemType type)
        {
            var index = text.IndexOfAny(XmlEndOfTerm);

            if (index <= 0)
            {
                return;
            }

            var delimiterIndex = text.IndexOf(XmlNamespaceDelimeter);

            if (delimiterIndex > 0 && delimiterIndex < index)
            {
                res.Add(new CodeLexem(type, CutString(ref text, delimiterIndex)));
                res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
                res.Add(new CodeLexem(type, CutString(ref text, index - delimiterIndex - 1)));
                return;
            }
            res.Add(new CodeLexem(type, CutString(ref text, index)));
        }
Example #10
0
        protected void LineBreaks(List <CodeLexem> res, ref SourcePart text, int to, LexemType type)
        {
            while (text.Length > 0 && to > 0)
            {
                var index = text.IndexOf("\n");
                if (index >= to)
                {
                    res.Add(new CodeLexem(type, CutString(ref text, to)));
                    return;
                }

                if (index != 0)
                {
                    res.Add(new CodeLexem(type, CutString(ref text, index)));
                }

                res.Add(new CodeLexem(LexemType.LineBreak, CutString(ref text, 1)));
                to -= index + 1;
            }
        }
 private void TryExtractValue(List<CodeLexem> res, ref SourcePart text)
 {
     if (text[0] == '{')
     {
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
     else if (text[0] == '[')
     {
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
     else if (text[0] == '"')
     {
         res.Add(new CodeLexem(LexemType.Quotes, CutString(ref text, 1)));
         var end = text.IndexOf('"');
         res.Add(new CodeLexem(LexemType.Value, CutString(ref text, end)));
         res.Add(new CodeLexem(LexemType.Quotes, CutString(ref text, 1)));
     }
     else
     {
         var end = text.IndexOfAny(new[] { ',', '}' });
         res.Add(new CodeLexem(LexemType.Value, CutString(ref text, end)));
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
 }
Example #12
0
 private void TryExtractValue(List <CodeLexem> res, ref SourcePart text)
 {
     if (text[0] == '{')
     {
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
     else if (text[0] == '[')
     {
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
     else if (text[0] == '"')
     {
         res.Add(new CodeLexem(LexemType.Quotes, CutString(ref text, 1)));
         var end = text.IndexOf('"');
         res.Add(new CodeLexem(LexemType.Value, CutString(ref text, end)));
         res.Add(new CodeLexem(LexemType.Quotes, CutString(ref text, 1)));
     }
     else
     {
         var end = text.IndexOfAny(new[] { ',', '}' });
         res.Add(new CodeLexem(LexemType.Value, CutString(ref text, end)));
         res.Add(new CodeLexem(LexemType.Symbol, CutString(ref text, 1)));
     }
 }