mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
support bool literal
This commit is contained in:
parent
e264b4dcba
commit
dd54b4aa26
@ -1524,6 +1524,23 @@ bool ParserNull::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ParserBool::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
if (ParserKeyword("true").parse(pos, node, expected))
|
||||
{
|
||||
node = std::make_shared<ASTLiteral>(true);
|
||||
return true;
|
||||
}
|
||||
else if (ParserKeyword("false").parse(pos, node, expected))
|
||||
{
|
||||
node = std::make_shared<ASTLiteral>(false);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool parseNumber(char * buffer, size_t size, bool negative, int base, Field & res)
|
||||
{
|
||||
errno = 0; /// Functions strto* don't clear errno.
|
||||
@ -1755,6 +1772,7 @@ bool ParserLiteral::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
ParserNull null_p;
|
||||
ParserNumber num_p;
|
||||
ParserBool bool_p;
|
||||
ParserStringLiteral str_p;
|
||||
|
||||
if (null_p.parse(pos, node, expected))
|
||||
@ -1763,6 +1781,9 @@ bool ParserLiteral::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
if (num_p.parse(pos, node, expected))
|
||||
return true;
|
||||
|
||||
if (bool_p.parse(pos, node, expected))
|
||||
return true;
|
||||
|
||||
if (str_p.parse(pos, node, expected))
|
||||
return true;
|
||||
|
||||
|
@ -294,6 +294,14 @@ protected:
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
};
|
||||
|
||||
/** Bool literal.
|
||||
*/
|
||||
class ParserBool : public IParserBase
|
||||
{
|
||||
protected:
|
||||
const char * getName() const override { return "Bool"; }
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
};
|
||||
|
||||
/** Numeric literal.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user