diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-07-22 14:33:21 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-07-22 14:33:21 +0200 |
commit | cea6fb57ac8c9a893c0f404fef6c1469f0b6222b (patch) | |
tree | fed8b6ffa8ea2cb6347ece69c0cb81003d0ccbf6 /odb/sql-token.hxx | |
parent | 5f71c55a1c24c23af1eeb0d664922497a0e5c071 (diff) |
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.
Diffstat (limited to 'odb/sql-token.hxx')
-rw-r--r-- | odb/sql-token.hxx | 79 |
1 files changed, 79 insertions, 0 deletions
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 <boris@codesynthesis.com> +// 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 <string> +#include <cstddef> // 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 <odb/sql-token.ixx> + +#endif // ODB_SQL_TOKEN_HXX |