mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
dbms: development.
This commit is contained in:
parent
a3470586b9
commit
ba83040cb0
@ -44,6 +44,7 @@ namespace ErrorCodes
|
|||||||
CANNOT_READ_ALL_DATA,
|
CANNOT_READ_ALL_DATA,
|
||||||
TOO_MUCH_ARGUMENTS_FOR_FUNCTION,
|
TOO_MUCH_ARGUMENTS_FOR_FUNCTION,
|
||||||
TOO_LESS_ARGUMENTS_FOR_FUNCTION,
|
TOO_LESS_ARGUMENTS_FOR_FUNCTION,
|
||||||
|
UNKNOWN_ELEMENT_IN_AST,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ protected:
|
|||||||
if (end - pos >= 4 && pos[0] == '/' && pos[1] == '*')
|
if (end - pos >= 4 && pos[0] == '/' && pos[1] == '*')
|
||||||
{
|
{
|
||||||
pos += 2;
|
pos += 2;
|
||||||
while (end - pos >= 2 && pos[0] != '*' && pos[1] != '/')
|
while (end - pos >= 2 && (pos[0] != '*' || pos[1] != '/'))
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
if (end - pos < 2)
|
if (end - pos < 2)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
String s(begin, pos - begin);
|
String s(begin, pos - begin);
|
||||||
std::cerr << getName() << ": " << s << std::endl;
|
//std::cerr << getName() << ": " << s << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include <DB/Parsers/ExpressionElementParsers.h>
|
#include <DB/Parsers/ExpressionElementParsers.h>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
namespace DB
|
namespace DB
|
||||||
{
|
{
|
||||||
@ -63,7 +62,7 @@ bool ParserParenthesisExpression::parseImpl(Pos & pos, Pos end, ASTPtr & node, S
|
|||||||
if (!close.ignore(pos, end, expected))
|
if (!close.ignore(pos, end, expected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ASTExpressionList & expr_list = dynamic_cast<ASTExpressionList &>(*node);
|
ASTExpressionList & expr_list = dynamic_cast<ASTExpressionList &>(*contents_node);
|
||||||
|
|
||||||
/// пустое выражение в скобках недопустимо
|
/// пустое выражение в скобках недопустимо
|
||||||
if (expr_list.children.empty())
|
if (expr_list.children.empty())
|
||||||
|
@ -22,7 +22,7 @@ bool ParserLeftAssociativeBinaryOperatorList::parseImpl(Pos & pos, Pos end, ASTP
|
|||||||
{
|
{
|
||||||
ASTPtr elem;
|
ASTPtr elem;
|
||||||
if (!elem_parser->parse(pos, end, elem, expected))
|
if (!elem_parser->parse(pos, end, elem, expected))
|
||||||
break;
|
return false;
|
||||||
|
|
||||||
node = elem;
|
node = elem;
|
||||||
}
|
}
|
||||||
@ -105,6 +105,8 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ws.ignore(pos, end);
|
||||||
|
|
||||||
ASTPtr elem;
|
ASTPtr elem;
|
||||||
if (!elem_parser->parse(pos, end, elem, expected))
|
if (!elem_parser->parse(pos, end, elem, expected))
|
||||||
return false;
|
return false;
|
||||||
@ -113,8 +115,6 @@ bool ParserPrefixUnaryOperatorExpression::parseImpl(Pos & pos, Pos end, ASTPtr &
|
|||||||
node = elem;
|
node = elem;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ws.ignore(pos, end);
|
|
||||||
|
|
||||||
/// функция, соответствующая оператору
|
/// функция, соответствующая оператору
|
||||||
ASTFunction * p_function = new ASTFunction;
|
ASTFunction * p_function = new ASTFunction;
|
||||||
ASTFunction & function = *p_function;
|
ASTFunction & function = *p_function;
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
#include <DB/Parsers/ASTSelectQuery.h>
|
#include <DB/Parsers/ASTSelectQuery.h>
|
||||||
#include <DB/Parsers/ParserSelectQuery.h>
|
#include <DB/Parsers/ParserSelectQuery.h>
|
||||||
|
#include <DB/Parsers/formatAST.h>
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
DB::ParserSelectQuery parser;
|
DB::ParserSelectQuery parser;
|
||||||
DB::ASTPtr ast;
|
DB::ASTPtr ast;
|
||||||
std::string input = "SELECT f(x), 1, 2, 3, x, NULL, 'abc\\\\def\\'\\\\''";
|
std::string input = "SELECT f(1), '\\\\', [a, b, c], (a, b, c), 1 + 2 * -3, a = b OR c > d.1 + 2 * -g[0] AND NOT e < f * (x + y)";
|
||||||
std::string expected;
|
std::string expected;
|
||||||
|
|
||||||
const char * begin = input.data();
|
const char * begin = input.data();
|
||||||
@ -20,6 +21,8 @@ int main(int argc, char ** argv)
|
|||||||
if (parser.parse(pos, end, ast, expected))
|
if (parser.parse(pos, end, ast, expected))
|
||||||
{
|
{
|
||||||
std::cout << "Success." << std::endl;
|
std::cout << "Success." << std::endl;
|
||||||
|
DB::formatAST(*ast, std::cout);
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user