| 1 | #include "parseIdentifierOrStringLiteral.h" | 
|---|---|
| 2 | |
| 3 | #include "ExpressionElementParsers.h" | 
| 4 | #include "ASTLiteral.h" | 
| 5 | #include "ASTIdentifier.h" | 
| 6 | #include <Common/typeid_cast.h> | 
| 7 | |
| 8 | namespace DB | 
| 9 | { | 
| 10 | |
| 11 | bool parseIdentifierOrStringLiteral(IParser::Pos & pos, Expected & expected, String & result) | 
| 12 | { | 
| 13 | ASTPtr res; | 
| 14 | |
| 15 | if (!ParserIdentifier().parse(pos, res, expected)) | 
| 16 | { | 
| 17 | if (!ParserStringLiteral().parse(pos, res, expected)) | 
| 18 | return false; | 
| 19 | |
| 20 | result = res->as<ASTLiteral &>().value.safeGet<String>(); | 
| 21 | } | 
| 22 | else | 
| 23 | result = getIdentifierName(res); | 
| 24 | |
| 25 | return true; | 
| 26 | } | 
| 27 | |
| 28 | } | 
| 29 | 
