Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
d4974b07
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4974b07
编写于
7月 13, 2017
作者:
A
Alexey Milovidov
提交者:
alexey-milovidov
7月 13, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using lexer (development) [#CLICKHOUSE-2].
上级
f6ff1f7e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
48 addition
and
29 deletion
+48
-29
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
+2
-2
dbms/src/Parsers/ExpressionElementParsers.cpp
dbms/src/Parsers/ExpressionElementParsers.cpp
+8
-2
dbms/src/Parsers/Lexer.cpp
dbms/src/Parsers/Lexer.cpp
+38
-25
未找到文件。
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
浏览文件 @
d4974b07
...
...
@@ -277,10 +277,10 @@ private:
ErrorCodes
::
SYNTAX_ERROR
};
};
auto
match
=
[
&
](
const
char
*
str
)
auto
match
=
[
&
pos
](
const
char
*
str
)
mutable
{
size_t
length
=
strlen
(
str
);
if
(
pos
+
length
<
end
&&
0
==
memcmp
(
pos
,
str
,
length
))
if
(
pos
+
length
<
=
end
&&
0
==
memcmp
(
pos
,
str
,
length
))
{
pos
+=
length
;
return
true
;
...
...
dbms/src/Parsers/ExpressionElementParsers.cpp
浏览文件 @
d4974b07
...
...
@@ -431,7 +431,7 @@ bool ParserNumber::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
char
*
pos_double
=
buf
;
errno
=
0
;
/// Functions strto* don't clear errno.
Float64
float_value
=
std
::
strtod
(
buf
,
&
pos_double
);
if
(
pos_double
==
buf
||
errno
==
ERANGE
)
if
(
pos_double
!=
buf
+
pos
->
size
()
||
errno
==
ERANGE
)
{
expected
=
"number"
;
return
false
;
...
...
@@ -475,7 +475,7 @@ bool ParserUnsignedInteger::parseImpl(Pos & pos, ASTPtr & node, Expected & expec
UInt64
x
=
0
;
ReadBufferFromMemory
in
(
pos
->
begin
,
pos
->
size
());
if
(
!
tryReadIntText
(
x
,
in
)
||
in
.
count
()
==
0
)
if
(
!
tryReadIntText
(
x
,
in
)
||
in
.
count
()
!=
pos
->
size
()
)
{
expected
=
"unsigned integer"
;
return
false
;
...
...
@@ -506,6 +506,12 @@ bool ParserStringLiteral::parseImpl(Pos & pos, ASTPtr & node, Expected & expecte
return
false
;
}
if
(
in
.
count
()
!=
pos
->
size
())
{
expected
=
"string literal"
;
return
false
;
}
++
pos
;
node
=
std
::
make_shared
<
ASTLiteral
>
(
StringRange
(
pos
->
begin
,
pos
->
end
),
s
);
return
true
;
...
...
dbms/src/Parsers/Lexer.cpp
浏览文件 @
d4974b07
...
...
@@ -98,39 +98,51 @@ Token Lexer::nextTokenImpl()
{
/// The task is not to parse a number or check correctness, but only to skip it.
/// 0x, 0b
bool
hex
=
false
;
if
(
pos
+
2
<
end
&&
*
pos
==
'0'
&&
(
pos
[
1
]
==
'x'
||
pos
[
1
]
==
'b'
||
pos
[
1
]
==
'X'
||
pos
[
1
]
==
'B'
))
/// Disambiguation: if previous token was dot, then we could parse only simple integer,
/// for chained tuple access operators (x.1.1) to work.
// Otherwise it will be tokenized as x . 1.1, not as x . 1 . 1
if
(
prev_significant_token_type
==
TokenType
::
Dot
)
{
if
(
pos
[
1
]
==
'x'
||
pos
[
1
]
==
'X'
)
hex
=
true
;
pos
+=
2
;
++
pos
;
while
(
pos
<
end
&&
isNumericASCII
(
*
pos
))
++
pos
;
}
else
++
pos
;
while
(
pos
<
end
&&
(
hex
?
isHexDigit
(
*
pos
)
:
isNumericASCII
(
*
pos
)))
++
pos
;
/// decimal point
if
(
pos
<
end
&&
*
pos
==
'.'
)
{
++
pos
;
while
(
pos
<
end
&&
(
hex
?
isHexDigit
(
*
pos
)
:
isNumericASCII
(
*
pos
)))
/// 0x, 0b
bool
hex
=
false
;
if
(
pos
+
2
<
end
&&
*
pos
==
'0'
&&
(
pos
[
1
]
==
'x'
||
pos
[
1
]
==
'b'
||
pos
[
1
]
==
'X'
||
pos
[
1
]
==
'B'
))
{
if
(
pos
[
1
]
==
'x'
||
pos
[
1
]
==
'X'
)
hex
=
true
;
pos
+=
2
;
}
else
++
pos
;
}
/// exponentation (base 10 or base 2)
if
(
pos
+
1
<
end
&&
(
hex
?
(
*
pos
==
'p'
||
*
pos
==
'P'
)
:
(
*
pos
==
'e'
||
*
pos
==
'E'
)))
{
++
pos
;
while
(
pos
<
end
&&
(
hex
?
isHexDigit
(
*
pos
)
:
isNumericASCII
(
*
pos
)))
++
pos
;
/// sign of exponent. It is always decimal.
if
(
pos
+
1
<
end
&&
(
*
pos
==
'-'
||
*
pos
==
'+'
))
/// decimal point
if
(
pos
<
end
&&
*
pos
==
'.'
)
{
++
pos
;
while
(
pos
<
end
&&
(
hex
?
isHexDigit
(
*
pos
)
:
isNumericASCII
(
*
pos
)))
++
pos
;
}
while
(
pos
<
end
&&
isNumericASCII
(
*
pos
))
/// exponentation (base 10 or base 2)
if
(
pos
+
1
<
end
&&
(
hex
?
(
*
pos
==
'p'
||
*
pos
==
'P'
)
:
(
*
pos
==
'e'
||
*
pos
==
'E'
)))
{
++
pos
;
/// sign of exponent. It is always decimal.
if
(
pos
+
1
<
end
&&
(
*
pos
==
'-'
||
*
pos
==
'+'
))
++
pos
;
while
(
pos
<
end
&&
isNumericASCII
(
*
pos
))
++
pos
;
}
}
/// word character cannot go just after number (SELECT 123FROM)
...
...
@@ -168,13 +180,14 @@ Token Lexer::nextTokenImpl()
case
'.'
:
/// qualifier, tuple access operator or start of floating point number
{
/// Just after identifier or complex expression.
/// Just after identifier or complex expression
or number (for chained tuple access like x.1.1 to work properly)
.
if
(
pos
>
begin
&&
(
!
(
pos
+
1
<
end
&&
isNumericASCII
(
pos
[
1
]))
||
prev_significant_token_type
==
TokenType
::
ClosingRoundBracket
||
prev_significant_token_type
==
TokenType
::
ClosingSquareBracket
||
prev_significant_token_type
==
TokenType
::
BareWord
||
prev_significant_token_type
==
TokenType
::
QuotedIdentifier
))
||
prev_significant_token_type
==
TokenType
::
QuotedIdentifier
||
prev_significant_token_type
==
TokenType
::
Number
))
return
Token
(
TokenType
::
Dot
,
token_begin
,
++
pos
);
++
pos
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录