1 #ifndef _LEXEME_IMPL_H_
2 #define _LEXEME_IMPL_H_
6 #include "utf8_string.h"
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,
37 smart_ptr<ILexeme> makeInfImaginary (const utakata::utf8_string::UTF8String& str,
39 smart_ptr<ILexeme> makeImaginaryOnly (const utakata::utf8_string::UTF8String& str,
41 smart_ptr<ILexeme> makeBoolean (const smart_ptr<utakata::utf8_string::UTF8Char>& ch);
44 ////////////////////////////////////////////
45 // 実際に利用する lexeme は以下に実装する. //
46 ////////////////////////////////////////////
48 class PureLexeme : public ILexeme
50 // LiteralDataを必要としないデータに対して処理を行うためのクラス。
51 // 文字列と該当するLexemeIDを渡すことで実現する。
53 PureLexeme(const smart_ptr<utakata::utf8_string::UTF8String>& str,
54 const lexeme::LexemeID id);
55 virtual ~PureLexeme() {}
57 const lexeme::LexemeID getID() const ;
58 smart_ptr<utakata::utf8_string::UTF8String> toString() const;
59 smart_ptr<utakata::interpreter::LiteralData> getData() const;
63 smart_ptr<utakata::utf8_string::UTF8String> str_;
64 const lexeme::LexemeID& id_;
71 class String : public ILexeme
75 String (const utakata::utf8_string::UTF8String& ident);
77 const lexeme::LexemeID getID () const;
78 smart_ptr<utakata::utf8_string::UTF8String> toString () const;
79 smart_ptr<utakata::interpreter::LiteralData> getData() const;
83 smart_ptr<utakata::utf8_string::UTF8String> str_;
91 class Identifier : public ILexeme
95 Identifier (const utakata::utf8_string::UTF8String& ident);
96 virtual ~Identifier (){}
97 const lexeme::LexemeID getID () const;
98 smart_ptr<utakata::utf8_string::UTF8String> toString () const;
99 smart_ptr<utakata::interpreter::LiteralData> getData() const;
103 smart_ptr<utakata::utf8_string::UTF8String> str_;
111 class Number : public ILexeme
114 Number (const utf8_string::UTF8String& real, const utf8_string::UTF8String& imagin,
115 bool exact, int radix);
117 const lexeme::LexemeID getID () const;
118 smart_ptr<utakata::utf8_string::UTF8String> toString () const;
119 smart_ptr<utakata::interpreter::LiteralData> getData() const;
122 smart_ptr<utakata::interpreter::LiteralData> data_;
129 class Charactor : public ILexeme
132 Charactor (const utf8_string::UTF8String& ch);
133 virtual ~Charactor (){}
135 const lexeme::LexemeID getID () const;
136 smart_ptr<utakata::utf8_string::UTF8String> toString() const;
137 smart_ptr<utakata::interpreter::LiteralData> getData() const;
141 smart_ptr<utakata::utf8_string::UTF8String> ch_;
148 class Boolean : public ILexeme
151 Boolean (const smart_ptr<utf8_string::UTF8Char>& ch);
152 virtual ~Boolean (){}
154 const lexeme::LexemeID getID () const;
155 smart_ptr<utakata::utf8_string::UTF8String> toString () const;
156 smart_ptr<utakata::interpreter::LiteralData> getData() const;
159 smart_ptr<utf8_string::UTF8String> bool_;
166 #endif /* _LEXEME_IMPL_H_ */