mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-23 18:20:50 +00:00
Using lexer (development) [#CLICKHOUSE-2].
This commit is contained in:
parent
cd8d8bf972
commit
a8b6920eab
@ -71,7 +71,7 @@ std::string getOrdinalSuffix(T n)
|
||||
}
|
||||
}
|
||||
|
||||
/// More efficient than libc, because doesn't respect locale.
|
||||
/// More efficient than libc, because doesn't respect locale. But for some functions table implementation could be better.
|
||||
|
||||
inline bool isASCII(char c)
|
||||
{
|
||||
@ -89,6 +89,13 @@ inline bool isNumericASCII(char c)
|
||||
return (c >= '0' && c <= '9');
|
||||
}
|
||||
|
||||
inline bool isHexDigit(char c)
|
||||
{
|
||||
return isNumericASCII(c)
|
||||
|| (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F');
|
||||
}
|
||||
|
||||
inline bool isAlphaNumericASCII(char c)
|
||||
{
|
||||
return isAlphaASCII(c)
|
||||
|
@ -88,19 +88,24 @@ Token Lexer::nextToken()
|
||||
case '0'...'9':
|
||||
{
|
||||
/// 0x, 0b
|
||||
bool allow_hex = false;
|
||||
if (pos < end - 2 && *pos == '0' && (pos[1] == 'x' || pos[1] == 'b'))
|
||||
{
|
||||
if (pos[1] == 'x')
|
||||
allow_hex = true;
|
||||
pos += 2;
|
||||
}
|
||||
else
|
||||
++pos;
|
||||
|
||||
while (pos < end && isNumericASCII(*pos))
|
||||
while (pos < end && (allow_hex ? isHexDigit(*pos) : isNumericASCII(*pos)))
|
||||
++pos;
|
||||
|
||||
/// decimal point
|
||||
if (pos < end && *pos == '.')
|
||||
{
|
||||
++pos;
|
||||
while (pos < end && isNumericASCII(*pos))
|
||||
while (pos < end && (allow_hex ? isHexDigit(*pos) : isNumericASCII(*pos)))
|
||||
++pos;
|
||||
}
|
||||
|
||||
@ -113,7 +118,7 @@ Token Lexer::nextToken()
|
||||
if (pos < end - 1 && (*pos == '-' || *pos == '+'))
|
||||
++pos;
|
||||
|
||||
while (pos < end && isNumericASCII(*pos))
|
||||
while (pos < end && (allow_hex ? isHexDigit(*pos) : isNumericASCII(*pos)))
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user