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;
|
|
|
|
|
2019-03-15 16:14:13 +00:00
|
|
|
result = res->as<ASTLiteral &>().value.safeGet<String>();
|
2017-11-21 19:17:24 +00:00
|
|
|
}
|
|
|
|
else
|
2019-08-08 20:02:30 +00:00
|
|
|
result = getIdentifierName(res);
|
2017-11-21 19:17:24 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-02-26 03:37:08 +00:00
|
|
|
}
|