From cea6fb57ac8c9a893c0f404fef6c1469f0b6222b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 22 Jul 2010 14:33:21 +0200 Subject: Next chunk of functionality Add SQL language lexer. Implement MySQL type declaration parser. Create sub-directories for databases, currently mysql and tracer. Create MySQL-specific context. --- odb/sql-token.hxx | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 odb/sql-token.hxx (limited to 'odb/sql-token.hxx') diff --git a/odb/sql-token.hxx b/odb/sql-token.hxx new file mode 100644 index 0000000..464c9a5 --- /dev/null +++ b/odb/sql-token.hxx @@ -0,0 +1,79 @@ +// file : odb/sql-token.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_SQL_TOKEN_HXX +#define ODB_SQL_TOKEN_HXX + +#include +#include // std::size_t + +class sql_token +{ +public: + enum token_type + { + t_eos, + t_identifier, + t_punctuation, + t_string_lit, + t_int_lit, + t_float_lit, + }; + + token_type + type () const; + + // Identifier + // +public: + std::string const& + identifier () const; + + // Punctuation + // +public: + enum punctuation_type + { + p_semi, + p_comma, + p_lparen, + p_rparen, + p_eq, + p_invalid + }; + + // Return the punctuation id if type is t_punctuation and p_invalid + // otherwise. + // + punctuation_type + punctuation () const; + + // Literals. + // +public: + std::string const& + literal () const; + + // C-tors. + // +public: + // EOS and punctuations. + // + sql_token (); + sql_token (punctuation_type p); + + // Identifier and literals. + // + sql_token (token_type t, std::string const& s); + +private: + token_type type_; + punctuation_type punctuation_; + std::string str_; +}; + +#include + +#endif // ODB_SQL_TOKEN_HXX -- cgit v1.1