2011-10-31 06:37:12 +00:00
|
|
|
#pragma once
|
2010-06-24 19:12:10 +00:00
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/IParserBase.h>
|
2010-06-24 19:12:10 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-06-18 03:07:03 +00:00
|
|
|
/** Parse specified keyword such as SELECT or compound keyword such as ORDER BY.
|
|
|
|
* All case insensitive. Requires word boundary.
|
|
|
|
* For compound keywords, any whitespace characters and comments could be in the middle.
|
|
|
|
*/
|
|
|
|
/// Example: ORDER/* Hello */BY
|
|
|
|
class ParserKeyword : public IParserBase
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
const char * s;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ParserKeyword(const char * s_);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const char * getName() const override;
|
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
2017-06-18 03:07:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-07-10 03:28:12 +00:00
|
|
|
class ParserToken : public IParserBase
|
2010-06-24 19:12:10 +00:00
|
|
|
{
|
2017-07-10 03:28:12 +00:00
|
|
|
private:
|
|
|
|
TokenType token_type;
|
2011-10-31 06:37:12 +00:00
|
|
|
public:
|
2017-07-10 03:28:12 +00:00
|
|
|
ParserToken(TokenType token_type) : token_type(token_type) {}
|
2010-06-24 19:12:10 +00:00
|
|
|
protected:
|
2017-07-10 03:28:12 +00:00
|
|
|
const char * getName() const override { return "token"; }
|
|
|
|
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override
|
|
|
|
{
|
|
|
|
if (pos->type != token_type)
|
|
|
|
return false;
|
|
|
|
++pos;
|
|
|
|
return true;
|
|
|
|
}
|
2010-06-24 19:12:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|