OSDN Git Service

-lexeme_idを、private inherit Enum idiomで書き直した。なんかよくわからないエラーが出るけど気にしない。
[simplecms/utakata.git] / lexeme_impl.h
1 #ifndef _LEXEME_IMPL_H_
2 #define _LEXEME_IMPL_H_
3
4 #include "lexeme.h"
5 #include "smart_ptr.h"
6 #include "utf8_string.h"
7 #include "lexeme_id.h"
8
9 // lexemeの様々な実装を定義する。
10 namespace utakata {
11
12     namespace lexeme {
13
14         // 各lexemeをsmart_ptrにして取得する。
15         smart_ptr<ILexeme> makeOpenParen();
16         smart_ptr<ILexeme> makeEOS();
17         smart_ptr<ILexeme> makeCloseParen();
18         smart_ptr<ILexeme> makeBackQuote();
19         smart_ptr<ILexeme> makeQuote();
20         smart_ptr<ILexeme> makeDot();
21         smart_ptr<ILexeme> makeUnquoteSplicing(const utakata::utf8_string::UTF8String& str);
22         smart_ptr<ILexeme> makeUnquote();
23         smart_ptr<ILexeme> makeSyntax();
24         smart_ptr<ILexeme> makeQuasiSyntax();
25         smart_ptr<ILexeme> makeUnsyntaxSplicing();
26         smart_ptr<ILexeme> makeUnsyntax();
27         smart_ptr<ILexeme> makeByteVector();
28         smart_ptr<ILexeme> makeVector();
29         smart_ptr<ILexeme> makeIdentifier(const utakata::utf8_string::UTF8String& str);
30         smart_ptr<ILexeme> makeString(const utakata::utf8_string::UTF8String& str);
31         smart_ptr<ILexeme> makeNumber(const utakata::utf8_string::UTF8String& real,
32                                       const utakata::utf8_string::UTF8String& imaginary,
33                                       bool exact, int radix);
34         smart_ptr<ILexeme> makeCharactor(const utakata::utf8_string::UTF8String& str);
35         smart_ptr<ILexeme> makeNanImaginary(const utakata::utf8_string::UTF8String& str,
36                                             bool exact);
37         smart_ptr<ILexeme> makeInfImaginary(const utakata::utf8_string::UTF8String& str,
38                                             bool exact);
39         smart_ptr<ILexeme> makeImaginaryOnly(const utakata::utf8_string::UTF8String& str,
40                                              bool exact);
41         smart_ptr<ILexeme> makeBoolean(const smart_ptr<utakata::utf8_string::UTF8Char>& ch);
42
43
44         ////////////////////////////////////////////
45         // 実際に利用するlexemeは以下に実装する。 //
46         ////////////////////////////////////////////
47
48         class OpenParen : public ILexeme
49         {
50         public:
51             OpenParen(){}
52             virtual ~OpenParen() {}
53
54             const lexeme::LexemeID getID() const;
55             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
56         };
57
58         class EOS : public ILexeme
59         {
60         public:
61             EOS(){}
62             virtual ~EOS() {}
63
64             const lexeme::LexemeID getID() const;
65             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
66         };
67
68         class CloseParen : public ILexeme
69         {
70         public:
71             CloseParen(){}
72             virtual ~CloseParen() {}
73             const lexeme::LexemeID getID() const;
74             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
75
76         };
77
78         class BackQuote : public ILexeme
79         {
80         public:
81             BackQuote(){}
82             virtual ~BackQuote(){}
83             const lexeme::LexemeID getID() const;
84             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
85         };
86
87         class Quote : public ILexeme
88         {
89         public:
90             Quote(){}
91             virtual ~Quote(){}
92             const lexeme::LexemeID getID() const;
93             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
94
95         };
96
97         class Dot : public ILexeme
98         {
99         public:
100             Dot(){}
101             virtual ~Dot(){}
102             const lexeme::LexemeID getID() const;
103             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
104         };
105
106         class UnquoteSplicing : public ILexeme
107         {
108         public:
109             UnquoteSplicing(){}
110             virtual ~UnquoteSplicing(){}
111             const lexeme::LexemeID getID() const;
112             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
113
114         };
115
116         class Unquote : public ILexeme
117         {
118         public:
119             Unquote(){}
120             virtual ~Unquote(){}
121             const lexeme::LexemeID getID() const;
122             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
123         };
124
125         class Syntax : public ILexeme
126         {
127         public:
128             Syntax() {}
129             virtual ~Syntax() {}
130             const lexeme::LexemeID getID() const;
131             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
132         };
133
134         class QuasiSyntax : public ILexeme
135         {
136         public:
137             QuasiSyntax(){}
138             virtual ~QuasiSyntax(){}
139             const lexeme::LexemeID getID() const;
140             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
141
142         };
143
144         class UnsyntaxSplicing : public ILexeme
145         {
146         public:
147             UnsyntaxSplicing(){}
148             virtual ~UnsyntaxSplicing(){}
149
150             const lexeme::LexemeID getID() const;
151             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
152
153         };
154
155         class Unsyntax : public ILexeme
156         {
157         public:
158             Unsyntax(){}
159             virtual ~Unsyntax(){}
160             const lexeme::LexemeID getID() const;
161             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
162
163         };
164
165         ////////////////
166         // Vector //
167         ////////////////
168
169         class Vector : public ILexeme
170         {
171         public:
172             Vector(){}
173             virtual ~Vector(){}
174             const lexeme::LexemeID getID() const;
175             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
176
177         };
178
179         ////////////////
180         // ByteVector //
181         ////////////////
182
183         class ByteVector : public ILexeme
184         {
185         public:
186             ByteVector(){}
187             virtual ~ByteVector(){}
188             const lexeme::LexemeID getID() const;
189             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
190
191         };
192
193
194         class String : public ILexeme
195         {
196         public:
197             
198             String(const utakata::utf8_string::UTF8String& ident);
199             virtual ~String(){}
200             const lexeme::LexemeID getID() const;
201             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
202
203         private:
204
205             smart_ptr<utakata::utf8_string::UTF8String> str_;
206         };
207
208         class Identifier : public ILexeme
209         {
210         public:
211             
212             Identifier(const utakata::utf8_string::UTF8String& ident);
213             virtual ~Identifier(){}
214             const lexeme::LexemeID getID() const;
215             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
216
217         private:
218
219             smart_ptr<utakata::utf8_string::UTF8String> str_;
220         };
221
222         class Number : public ILexeme
223         {
224         public:
225             Number(const utf8_string::UTF8String& real, const utf8_string::UTF8String& imagin,
226                    bool exact, int radix);
227             virtual ~Number(){}
228             const lexeme::LexemeID getID() const;
229             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
230
231         private:
232
233             smart_ptr<utakata::utf8_string::UTF8String> real_;
234             smart_ptr<utakata::utf8_string::UTF8String> imagin_;
235             bool exact_;
236             int radix_;
237         };
238
239         class Charactor : public ILexeme
240         {
241         public:
242             Charactor(const utf8_string::UTF8String& ch);
243             virtual ~Charactor(){}
244
245             const lexeme::LexemeID getID() const;
246             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
247
248         private:
249
250             smart_ptr<utakata::utf8_string::UTF8String> ch_;
251         };
252
253         class Boolean : public ILexeme
254         {
255         public:
256             Boolean(const smart_ptr<utf8_string::UTF8Char>& ch);
257             virtual ~Boolean(){}
258
259             const lexeme::LexemeID getID() const;
260             smart_ptr<utakata::utf8_string::UTF8String> toString() const;
261
262         private:
263
264             smart_ptr<utakata::utf8_string::UTF8String> str_;
265         };
266
267     };
268
269 };
270
271 #endif /* _LEXEME_IMPL_H_ */