From c3f7f0c0556270ced988a7adddec885270bc1ea7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 10 Aug 2009 17:54:32 +0200 Subject: Inline file for the Token class --- cli/token.hxx | 58 +++++++++++-------------------------------------- cli/token.ixx | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 45 deletions(-) create mode 100644 cli/token.ixx (limited to 'cli') diff --git a/cli/token.hxx b/cli/token.hxx index 0f4f714..c12d097 100644 --- a/cli/token.hxx +++ b/cli/token.hxx @@ -27,22 +27,13 @@ public: }; Type - type () const - { - return type_; - } + type () const; std::size_t - line () const - { - return l_; - } + line () const; std::size_t - column () const - { - return c_; - } + column () const; // Keyword // @@ -65,19 +56,13 @@ public: }; Keyword - keyword () const - { - return keyword_; - } + keyword () const; // Identifier // public: std::string const& - identifier () const - { - return str_; - } + identifier () const; // Punctuation // @@ -96,46 +81,27 @@ public: }; Punctuation - punctuation () const - { - return punctuation_; - } + punctuation () const; // Literals. // public: std::string const& - literal () const - { - return str_; - } + literal () const; // C-tors. // public: // EOS. // - Token (std::size_t l, std::size_t c) - : l_ (l), c_ (c), type_ (t_eos) - { - } - - Token (Keyword k, std::size_t l, std::size_t c) - : l_ (l), c_ (c), type_ (t_keyword), keyword_ (k) - { - } + Token (std::size_t l, std::size_t c); - Token (Punctuation p, std::size_t l, std::size_t c) - : l_ (l), c_ (c), type_ (t_punctuation), punctuation_ (p) - { - } + Token (Keyword k, std::size_t l, std::size_t c); + Token (Punctuation p, std::size_t l, std::size_t c); // Identifier & literals. // - Token (Type t, std::string const& s, std::size_t l, std::size_t c) - : l_ (l), c_ (c), type_ (t), str_ (s) - { - } + Token (Type t, std::string const& s, std::size_t l, std::size_t c); private: std::size_t l_; @@ -148,4 +114,6 @@ private: std::string str_; }; +#include "token.ixx" + #endif // CLI_TOKEN_HXX diff --git a/cli/token.ixx b/cli/token.ixx new file mode 100644 index 0000000..bcf040a --- /dev/null +++ b/cli/token.ixx @@ -0,0 +1,70 @@ +// file : cli/token.ixx +// author : Boris Kolpackov +// copyright : Copyright (c) 2009 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +inline Token::Type Token:: +type () const +{ + return type_; +} + +inline std::size_t Token:: +line () const +{ + return l_; +} + +inline std::size_t Token:: +column () const +{ + return c_; +} + +inline Token::Keyword Token:: +keyword () const +{ + return keyword_; +} + +inline std::string const& Token:: +identifier () const +{ + return str_; +} + +inline Token::Punctuation Token:: +punctuation () const +{ + return punctuation_; +} + +inline std::string const& Token:: +literal () const +{ + return str_; +} + +inline Token:: +Token (std::size_t l, std::size_t c) + : l_ (l), c_ (c), type_ (t_eos) +{ +} + +inline Token:: +Token (Keyword k, std::size_t l, std::size_t c) + : l_ (l), c_ (c), type_ (t_keyword), keyword_ (k) +{ +} + +inline Token:: +Token (Punctuation p, std::size_t l, std::size_t c) + : l_ (l), c_ (c), type_ (t_punctuation), punctuation_ (p) +{ +} + +inline Token:: +Token (Type t, std::string const& s, std::size_t l, std::size_t c) + : l_ (l), c_ (c), type_ (t), str_ (s) +{ +} -- cgit v1.1