예제 #1
0
        private Token LexInteger()
        {
            var    location = GetLocation();
            var    start    = cursor++;
            string image;

            if (source[start] == '0')
            {
                if (AdvanceIfDesired('x') || AdvanceIfDesired('X'))
                {
                    while (source.Length > cursor && IsHexadecimal(source[cursor]))
                    {
                        ++cursor;
                    }

                    image = source.GetString(start, cursor - start);
                    return(new Token(location, TokenType.Integer, image));
                }
            }

            while (source.Length > cursor && IsDecimal(source[cursor]))
            {
                ++cursor;
            }

            image = source.GetString(start, cursor - start);
            return(new Token(location, TokenType.Integer, image));
        }