summaryrefslogtreecommitdiff
path: root/cli/lexer.ixx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-08-09 15:20:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-08-09 15:20:02 +0200
commitd311e253ca3dcabb9e52d273110dea8b950571f7 (patch)
tree3f8503433cba6425259d897d5008e7a2497a6430 /cli/lexer.ixx
parentcaa0969db07e6f252dc5c270222107a591c1ca7d (diff)
Implement lexical analyzer for the CLI language
Diffstat (limited to 'cli/lexer.ixx')
-rw-r--r--cli/lexer.ixx86
1 files changed, 86 insertions, 0 deletions
diff --git a/cli/lexer.ixx b/cli/lexer.ixx
new file mode 100644
index 0000000..f7ff77e
--- /dev/null
+++ b/cli/lexer.ixx
@@ -0,0 +1,86 @@
+// file : cli/lexer.ixx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+// Lexer::Char
+//
+inline Lexer::Char::
+Char (IntType v, std::size_t l, std::size_t c)
+ : v_ (v), l_ (l), c_ (c)
+{
+}
+
+inline Lexer::Char::
+operator CharType () const
+{
+ return Traits::to_char_type (v_);
+}
+
+inline Lexer::Char::IntType Lexer::Char::
+value () const
+{
+ return v_;
+}
+
+inline std::size_t Lexer::Char::
+line () const
+{
+ return l_;
+}
+
+inline std::size_t Lexer::Char::
+column () const
+{
+ return c_;
+}
+
+// Lexer
+//
+inline bool Lexer::
+is_alpha (char c) const
+{
+ return std::isalpha (c, loc_);
+}
+
+inline bool Lexer::
+is_oct_digit (char c) const
+{
+ return std::isdigit (c, loc_) && c != '8' && c != '9';
+}
+
+inline bool Lexer::
+is_dec_digit (char c) const
+{
+ return std::isdigit (c, loc_);
+}
+
+inline bool Lexer::
+is_hex_digit (char c) const
+{
+ return std::isxdigit (c, loc_);
+}
+
+inline bool Lexer::
+is_alnum (char c) const
+{
+ return std::isalnum (c, loc_);
+}
+
+inline bool Lexer::
+is_space (char c) const
+{
+ return std::isspace (c, loc_);
+}
+
+inline bool Lexer::
+is_eos (Char const& c) const
+{
+ return c.value () == Char::Traits::eof ();
+}
+
+inline char Lexer::
+to_upper (char c) const
+{
+ return std::toupper (c, loc_);
+}