aboutsummaryrefslogtreecommitdiff
path: root/odb/sql-lexer.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-07-22 14:33:21 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-07-22 14:33:21 +0200
commitcea6fb57ac8c9a893c0f404fef6c1469f0b6222b (patch)
treefed8b6ffa8ea2cb6347ece69c0cb81003d0ccbf6 /odb/sql-lexer.ixx
parent5f71c55a1c24c23af1eeb0d664922497a0e5c071 (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-lexer.ixx')
-rw-r--r--odb/sql-lexer.ixx86
1 files changed, 86 insertions, 0 deletions
diff --git a/odb/sql-lexer.ixx b/odb/sql-lexer.ixx
new file mode 100644
index 0000000..96deed1
--- /dev/null
+++ b/odb/sql-lexer.ixx
@@ -0,0 +1,86 @@
+// file : odb/sql-lexer.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// sql_lexer::xchar
+//
+inline sql_lexer::xchar::
+xchar (int_type v, std::size_t l, std::size_t c)
+ : v_ (v), l_ (l), c_ (c)
+{
+}
+
+inline sql_lexer::xchar::
+operator char_type () const
+{
+ return traits_type::to_char_type (v_);
+}
+
+inline sql_lexer::xchar::int_type sql_lexer::xchar::
+value () const
+{
+ return v_;
+}
+
+inline std::size_t sql_lexer::xchar::
+line () const
+{
+ return l_;
+}
+
+inline std::size_t sql_lexer::xchar::
+column () const
+{
+ return c_;
+}
+
+// lexer
+//
+inline bool sql_lexer::
+is_alpha (char c) const
+{
+ return std::isalpha (c, loc_);
+}
+
+inline bool sql_lexer::
+is_oct_digit (char c) const
+{
+ return std::isdigit (c, loc_) && c != '8' && c != '9';
+}
+
+inline bool sql_lexer::
+is_dec_digit (char c) const
+{
+ return std::isdigit (c, loc_);
+}
+
+inline bool sql_lexer::
+is_hex_digit (char c) const
+{
+ return std::isxdigit (c, loc_);
+}
+
+inline bool sql_lexer::
+is_alnum (char c) const
+{
+ return std::isalnum (c, loc_);
+}
+
+inline bool sql_lexer::
+is_space (char c) const
+{
+ return std::isspace (c, loc_);
+}
+
+inline bool sql_lexer::
+is_eos (xchar const& c) const
+{
+ return c.value () == xchar::traits_type::eof ();
+}
+
+inline char sql_lexer::
+to_upper (char c) const
+{
+ return std::toupper (c, loc_);
+}