Пример #1
0
        public DocRange GetErrorRange(ConvertTextToElement tte)
        {
            string localStream = tte.LocalStream;
            int    endLine = tte.Line, endCharacter = tte.Character;

            for (int i = 0; i < localStream.Length; i++)
            {
                // Get the range up until the next whitespace.
                if (char.IsWhiteSpace(localStream[i]) || char.IsSymbol(localStream[i]))
                {
                    break;
                }
                // When a newline is enountered, increment the end line and reset the end character.
                else if (localStream[i] == '\n')
                {
                    endLine++;
                    endCharacter = 0;
                }
                // Otherwise, increment the end character.
                else
                {
                    endCharacter++;
                }
            }

            return(new DocPos(tte.Line, tte.Character) + new DocPos(endLine, endCharacter));
        }
Пример #2
0
 public DecompileResult(ConvertTextToElement tte, string code)
 {
     Code     = code;
     Original = tte.Content;
     if (tte.ReachedEnd)
     {
         Result = "success";
     }
     else
     {
         Result     = "incompleted";
         ErrorRange = GetErrorRange(tte);
     }
 }