mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
fix parsing of ternary operator
This commit is contained in:
parent
2b79bf838f
commit
fad4e6c335
@ -65,4 +65,17 @@ bool ParserKeyword::parseImpl(Pos & pos, ASTPtr & /*node*/, Expected & expected)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ParserDoubleColon::parseImpl(Pos & pos, ASTPtr & /*node*/, Expected & expected)
|
||||
{
|
||||
/// Do not move position if only one colon mathced.
|
||||
Pos begin = pos;
|
||||
if (parser_colon.ignore(begin, expected) && parser_colon.ignore(begin, expected))
|
||||
{
|
||||
pos = begin;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,4 +56,15 @@ public:
|
||||
bool parseImpl(Pos & /*pos*/, ASTPtr & /*node*/, Expected & /*expected*/) override { return true; }
|
||||
};
|
||||
|
||||
class ParserDoubleColon : public IParserBase
|
||||
{
|
||||
public:
|
||||
const char * getName() const override { return "double colon"; }
|
||||
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
|
||||
private:
|
||||
ParserToken parser_colon{TokenType::Colon};
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -866,11 +866,9 @@ bool ParserCastOperator::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
|
||||
return false;
|
||||
|
||||
ASTPtr type_ast;
|
||||
ParserToken parser_colon(TokenType::Colon);
|
||||
const char * data_end = pos->begin;
|
||||
|
||||
if (parser_colon.ignore(pos, expected)
|
||||
&& parser_colon.ignore(pos, expected)
|
||||
if (ParserDoubleColon().ignore(pos, expected)
|
||||
&& ParserDataType().parse(pos, type_ast, expected))
|
||||
{
|
||||
auto type = DataTypeFactory::instance().get(type_ast);
|
||||
|
@ -564,9 +564,7 @@ bool ParserCastExpression::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
|
||||
return false;
|
||||
|
||||
ASTPtr type_ast;
|
||||
ParserToken parser_colon(TokenType::Colon);
|
||||
if (parser_colon.ignore(pos, expected)
|
||||
&& parser_colon.ignore(pos, expected)
|
||||
if (ParserDoubleColon().ignore(pos, expected)
|
||||
&& ParserDataType().parse(pos, type_ast, expected))
|
||||
{
|
||||
node = createFunctionCast(expr_ast, type_ast);
|
||||
|
Loading…
Reference in New Issue
Block a user