ClickHouse/dbms/src/Parsers/parseIdentifierOrStringLiteral.cpp

29 lines
606 B
C++
Raw Normal View History

2017-11-21 19:17:24 +00:00
#include "parseIdentifierOrStringLiteral.h"
#include "ExpressionElementParsers.h"
#include "ASTLiteral.h"
#include "ASTIdentifier.h"
#include <Common/typeid_cast.h>
namespace DB
{
bool parseIdentifierOrStringLiteral(IParser::Pos & pos, Expected & expected, String & result)
{
ASTPtr res;
if (!ParserIdentifier().parse(pos, res, expected))
{
if (!ParserStringLiteral().parse(pos, res, expected))
return false;
result = typeid_cast<const ASTLiteral &>(*res).value.safeGet<String>();
}
else
result = *getIdentifierName(res);
2017-11-21 19:17:24 +00:00
return true;
}
2018-02-26 03:37:08 +00:00
}