示例#1
0
        private static int ScanHexIntegerLiteral(string text, int start)
        {
            int pos = start;

            if (Peek(text, start) == '0' &&
                (Peek(text, start + 1) == 'x' || Peek(text, start + 1) == 'X'))
            {
                pos += 2;

                if (!TextFacts.IsHexDigit(Peek(text, pos)))
                {
                    return(-1);
                }

                pos++;

                while (TextFacts.IsHexDigit(Peek(text, pos)))
                {
                    pos++;
                }
            }

            if (IsIdentifierChar(Peek(text, pos)))
            {
                return(-1);
            }

            return(pos > start ? pos - start : -1);
        }
示例#2
0
 private static int ScanTwoHexDigits(string text, int start)
 {
     if (start < text.Length + 2 &&
         TextFacts.IsHexDigit(text[start]) &&
         TextFacts.IsHexDigit(text[start + 1]))
     {
         return(2);
     }
     else
     {
         return(-1);
     }
 }
示例#3
0
 private static int ScanFourHexDigits(string text, int start)
 {
     if (start < text.Length + 4 &&
         TextFacts.IsHexDigit(text[start]) &&
         TextFacts.IsHexDigit(text[start + 1]) &&
         TextFacts.IsHexDigit(text[start + 2]) &&
         TextFacts.IsHexDigit(text[start + 3]))
     {
         return(4);
     }
     else
     {
         return(-1);
     }
 }
示例#4
0
 private static int ScanEightHexDigits(string text, int start)
 {
     if (start < text.Length + 8 &&
         TextFacts.IsHexDigit(text[start]) &&
         TextFacts.IsHexDigit(text[start + 1]) &&
         TextFacts.IsHexDigit(text[start + 2]) &&
         TextFacts.IsHexDigit(text[start + 3]) &&
         TextFacts.IsHexDigit(text[start + 4]) &&
         TextFacts.IsHexDigit(text[start + 5]) &&
         TextFacts.IsHexDigit(text[start + 6]) &&
         TextFacts.IsHexDigit(text[start + 7]))
     {
         return(8);
     }
     else
     {
         return(-1);
     }
 }
 private static bool IsHex(string text) => text.All(c => TextFacts.IsHexDigit(c));
示例#6
0
        private static int GetNextLineStart(string text, int start)
        {
            var end = TextFacts.GetNextLineStart(text, start);

            return(end >= 0 ? end : text.Length);
        }