OSDN Git Service

lexerに関係するソースをsrc/lexer配下に移動。
[simplecms/utakata.git] / src / lexer / lexer_interface.h
similarity index 69%
rename from src/lexer_interface.h
rename to src/lexer/lexer_interface.h
index b35f54a..65606d9 100644 (file)
@@ -20,7 +20,7 @@ class UniString;
 }
 
 namespace reader {
-class StreamReader;
+class EncodingReader;
 };
 
 namespace lexeme {
@@ -30,14 +30,21 @@ class ILexeme;
 namespace lexer {
 
 class LexException : public exception::Exception {
+  // 字句解析時に発生した例外を送出します。
  public:
+
   LexException(const std::string& message,
-               const utakata::exception::ExceptionInfo& info) :
-      Exception(message, info) {}
+               const utakata::exception::ExceptionInfo& info)
+      Exception(message, info) {}
   LexException(const utakata::exception::Exception& exception,
                const std::string& message,
-               const utakata::exception::ExceptionInfo& info) :
-      Exception(exception, message, info) {}
+               const utakata::exception::ExceptionInfo& info)
+      : Exception(message, info) {}
+
+
+ private:
+  // LexExceptionが発生した▼文字列
+  const utility::smart_ptr<unicode::UniString> error_string_;
 };
 
 class ILexerDispatchTerm {
@@ -59,23 +66,23 @@ class IPartOfLexer {
 
   // 読出しストリームへのポインタを受け取って、結果として生成した
   // ILexemeインターフェースの派生クラスを返します。
-  virtual utility::smart_ptr<lexeme::ILexeme> Lex(
-      const unicode::UniString& string, reader::StreamReader* stream) = 0;
+  virtual lexeme::ILexeme* Lex(const unicode::UniString& string,
+                               reader::EncodingReader* stream) = 0;
+
+  // このIPartOfLexerへとDispatchする条件を記載したDispatchTermを作成して
+  // 返します。返されたポインタは、取得側で削除する必要があります。
+  // 返された値の保持については、utility::scoped_ptrの利用を推奨します。
+  virtual ILexerDispatchTerm* GetTerm() const = 0;
 };
 
 class ILexerCreator {
-  // IPartOfLexerの生成と、生成したLexerの条件を設定した
-  // LexerDispatchTerm生成するインターフェースとなります。
-  // LexerDispatchTermには、Lexerの条件を設定する必要があります。
+  // IPartOfLexerを生成するインターフェースとなります。
+  // 各IPartOfLexerにつき一つのインターフェースが必要となります。
  public:
   virtual ~ILexerCreator() {}
 
   // 各非終端記号に該当するIPartOfLexer派生のLexerを作成します。
   virtual IPartOfLexer* Create() const = 0;
-
-  // このILexerCreatorが生成するIPartOfLexerへとDispatchする条件を記載
-  // したDispatchTermを返します。
-  virtual ILexerDispatchTerm* GetTerm() const = 0;
 };
 };
 };