dbms: development.

This commit is contained in:
Alexey Milovidov 2010-03-17 20:33:47 +00:00
parent c788fd5bcc
commit e3d91b90f2
2 changed files with 4 additions and 22 deletions

View File

@ -31,7 +31,8 @@ namespace DB
*/
namespace ExpressionGrammarTypes
{
typedef boost::variant<UInt64, Int64, Float64> NumberConstant; /// 1, -1, 0.1
/// с тем, какой конкретно тип у числа, будем разбираться потом
typedef Float64 NumberConstant; /// 1, -1, 0.1
typedef String StringConstant; /// 'abc', 'ab\'c', 'abc\\'
typedef Null NullConstant; /// NULL, null, NuLl
@ -103,7 +104,7 @@ struct ExpressionGrammar : qi::grammar<Iterator, ExpressionGrammarTypes::Express
name %= raw[lexeme[alpha >> -*(alnum | '_')]];
constant %= number | string | null;
function %= name >> '(' >> expression >> ')';
number %= ulong_long | long_long | double_;
number %= double_;
null = eps[_val = boost::none] >> no_case["NULL"];
string %= raw[lexeme['\'' >> *((char_ - (char_('\\') | '\'')) | (char_('\'') >> char_)) >> '\'']];
}

View File

@ -12,31 +12,12 @@ namespace ascii = boost::spirit::ascii;
typedef DB::ExpressionGrammarTypes::Expression Expr;
class dumpNumber : public boost::static_visitor<>
{
public:
void operator() (const DB::UInt64 & x) const
{
std::cout << "UInt64: " << x << std::endl;
}
void operator() (const DB::Int64 & x) const
{
std::cout << "Int64: " << x << std::endl;
}
void operator() (const DB::Float64 & x) const
{
std::cout << "Float64: " << x << std::endl;
}
};
class dumpConst : public boost::static_visitor<>
{
public:
void operator() (const DB::ExpressionGrammarTypes::NumberConstant & x) const
{
boost::apply_visitor(dumpNumber(), x);
std::cout << "Number: " << x << std::endl;
}
void operator() (const DB::ExpressionGrammarTypes::StringConstant & x) const