OSDN Git Service

-- NestedCommentLexer、StringLexerの実装を完了。
[simplecms/utakata.git] / lexer.h
1 #ifndef _LEXER_H_
2 #define _LEXER_H_
3
4 #include "smart_ptr.h"
5 #include "utf8.h"
6 #include "utf8_string.h"
7 #include "lexeme.h"
8
9 #include <exception>
10 #include <string>
11
12 namespace utakata {
13
14     namespace lexer {
15
16         class Lexer
17         {
18             /**
19                scheme構文の字句解析器。
20                単純な字句解析器として働く。ストリームから文字列を読みだし、
21                BNF構文に基づいたそれぞれのオブジェクトに変換される。
22                Schemeの構文解析処理は、どちらかというとこの字句解析が大半を占める。
23                それぞれの字句解析は、該当するオブジェクトに変換される。
24                処理としてはそれほど難しくはない、と思いたい。
25
26                基本方針としては、シンプル->リファクタリングを繰り返すことを基本とする。
27                なので、最初はlex関数一つしか無いが、状況に応じて随時メンバ関数を増やしたりfunctor
28                として分離させたりする。
29                でも基本的にこれひとつで済むようにした方が楽かもしんない。
30             */
31         public:
32             Lexer(){}
33             virtual ~Lexer(){}
34
35             /**
36                渡されたUTF8を解釈するstreamから、データを解釈して、結果を返す。
37                結果は、smart_ptr<CLexeme>で返される。
38             */
39             smart_ptr<utakata::lexeme::ILexeme> lex(smart_ptr<utakata::utf8::UTF8InputStream>& stream);
40
41         };
42
43
44     };
45
46 };
47
48 #endif /* _LEXER_H_ */