mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
dbms: development.
This commit is contained in:
parent
8fc01e90d7
commit
e5d9895b57
@ -17,7 +17,7 @@ using Poco::SharedPtr;
|
||||
class ParserString : public IParserBase
|
||||
{
|
||||
private:
|
||||
const String & s;
|
||||
String s;
|
||||
public:
|
||||
ParserString(const String & s_) : s(s_) {}
|
||||
protected:
|
||||
@ -25,7 +25,7 @@ protected:
|
||||
|
||||
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, String & expected)
|
||||
{
|
||||
if (static_cast<ssize_t>(s.size()) < end - pos || std::strncmp(pos, s.data(), s.size()))
|
||||
if (static_cast<ssize_t>(s.size()) > end - pos || std::strncmp(pos, s.data(), s.size()))
|
||||
return false;
|
||||
else
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ typedef std::map<String, String> Operators_t;
|
||||
class ParserLeftAssociativeBinaryOperatorList : public IParserBase
|
||||
{
|
||||
private:
|
||||
const Operators_t & operators;
|
||||
Operators_t operators;
|
||||
ParserPtr elem_parser;
|
||||
|
||||
public:
|
||||
@ -50,7 +50,7 @@ protected:
|
||||
class ParserPrefixUnaryOperatorExpression : public IParserBase
|
||||
{
|
||||
private:
|
||||
const Operators_t & operators;
|
||||
Operators_t operators;
|
||||
ParserPtr elem_parser;
|
||||
|
||||
public:
|
||||
@ -76,7 +76,7 @@ public:
|
||||
ParserAccessExpression();
|
||||
|
||||
protected:
|
||||
String getName() { return "acess expression"; }
|
||||
String getName() { return "access expression"; }
|
||||
|
||||
bool parseImpl(Pos & pos, Pos end, ASTPtr & node, String & expected)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <DB/Core/Types.h>
|
||||
#include <DB/Parsers/IParser.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -19,7 +20,16 @@ public:
|
||||
bool parse(Pos & pos, Pos end, ASTPtr & node, String & expected)
|
||||
{
|
||||
expected = getName();
|
||||
return parseImpl(pos, end, node, expected);
|
||||
|
||||
Pos begin = pos;
|
||||
bool res = parseImpl(pos, end, node, expected);
|
||||
if (res)
|
||||
{
|
||||
String s(begin, pos - begin);
|
||||
std::cerr << getName() << ": " << s << std::endl;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
protected:
|
||||
virtual bool parseImpl(Pos & pos, Pos end, ASTPtr & node, String & expected) = 0;
|
||||
|
@ -95,8 +95,6 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
||||
{
|
||||
ParserWhiteSpaceOrComments ws;
|
||||
|
||||
ws.ignore(pos, end);
|
||||
|
||||
/// пробуем найти какой-нибудь из допустимых операторов
|
||||
Pos begin = pos;
|
||||
Operators_t::const_iterator it;
|
||||
@ -107,9 +105,14 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
||||
break;
|
||||
}
|
||||
|
||||
if (it == operators.end())
|
||||
ASTPtr elem;
|
||||
if (!elem_parser->parse(pos, end, elem, expected))
|
||||
return false;
|
||||
|
||||
if (it == operators.end())
|
||||
node = elem;
|
||||
else
|
||||
{
|
||||
ws.ignore(pos, end);
|
||||
|
||||
/// функция, соответствующая оператору
|
||||
@ -122,10 +125,6 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
||||
ASTExpressionList & exp_list = *p_exp_list;
|
||||
ASTPtr exp_list_node = p_exp_list;
|
||||
|
||||
ASTPtr elem;
|
||||
if (!elem_parser->parse(pos, end, elem, expected))
|
||||
return false;
|
||||
|
||||
function.range.first = begin;
|
||||
function.range.second = pos;
|
||||
function.name = it->second;
|
||||
@ -135,6 +134,7 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
||||
exp_list.range.second = pos;
|
||||
|
||||
node = function_node;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user