自作言語nullptrのインタープリターです。
修订版 | ed684ba4bf71042a3c88f1a07ab15cce9d0d04fc (tree) |
---|---|
时间 | 2015-08-08 16:35:37 |
作者 | Diverge <diverge.vosystems@gmai...> |
Commiter | Diverge |
外部モジュールローダの実装開始
@@ -148,23 +148,32 @@ std::vector<std::string> Nullptr::ProcBrackets(std::vector<std::string> lex) | ||
148 | 148 | std::string Nullptr::CalcBracket(std::string inBracket) |
149 | 149 | { |
150 | 150 | vector<BasicTypes::Int> num; |
151 | + BasicTypes::Int intd; | |
152 | + | |
151 | 153 | bool minus=false; |
154 | + unsigned char operate=0; | |
155 | + enum Operator{ | |
156 | + plus=1, | |
157 | + minus=2, | |
158 | + multiple=4, | |
159 | + divide=8, | |
160 | + mod=16, | |
161 | + }; | |
162 | + | |
152 | 163 | for(size_t C=0; C<inBracket.size(); C++){ |
153 | 164 | switch(inBracket[C]){ |
154 | - case '+': | |
155 | - | |
156 | - break; | |
157 | 165 | case '-': |
158 | - | |
166 | + minus=!minus; | |
167 | + case '+': | |
159 | 168 | break; |
160 | 169 | case '*': |
161 | - | |
170 | + operate=multiple; | |
162 | 171 | break; |
163 | 172 | case '/': |
164 | - | |
173 | + operate=divide; | |
165 | 174 | break; |
166 | 175 | case '%': |
167 | - | |
176 | + operate=mod; | |
168 | 177 | break; |
169 | 178 | |
170 | 179 | default: |
@@ -174,6 +183,17 @@ std::string Nullptr::CalcBracket(std::string inBracket) | ||
174 | 183 | n[c-C]=inBracket[c]; |
175 | 184 | } |
176 | 185 | num.push_back({!minus,stoull(n)}); |
186 | + switch(operate){ | |
187 | + case multiple: | |
188 | + num.push_back((*num.end())*(*(num.end()-1))); | |
189 | + break; | |
190 | + case divide: | |
191 | + num.push_back((*(num.end()-1))/(*num.end())); | |
192 | + break; | |
193 | + case mod: | |
194 | + num.push_back((*(num.end()-1))%(*num.end())); | |
195 | + break; | |
196 | + } | |
177 | 197 | break; |
178 | 198 | } |
179 | 199 | } |
@@ -0,0 +1,40 @@ | ||
1 | +/* | |
2 | +nullptr interpreter | |
3 | +(C) 2015 VOSystems. | |
4 | +*/ | |
5 | + | |
6 | +#include"nullptr.h" | |
7 | +#include"nullptrInterpreter.h" | |
8 | + | |
9 | +using namespace std; | |
10 | +using namespace VOSystemsNullptr; | |
11 | + | |
12 | +bool Nullptr::ModuleInfoLoader(std::string name) | |
13 | +{ | |
14 | + string src=m_src; | |
15 | + string work=m_workline; | |
16 | + | |
17 | + m_src=name+".nullptrmodule"; | |
18 | + do{ | |
19 | + LineLoad(); | |
20 | + | |
21 | + }while(!m_workline.empty()); | |
22 | + | |
23 | + m_src=src; | |
24 | + m_workline=work; | |
25 | +} | |
26 | + | |
27 | +bool Nullptr::ModuleConnect(std::string name) | |
28 | +{ | |
29 | + | |
30 | +} | |
31 | + | |
32 | +bool Nullptr::ModuleRun(std::string name) | |
33 | +{ | |
34 | + | |
35 | +} | |
36 | + | |
37 | +bool Nullptr::ModuleDisConnect(std::string name) | |
38 | +{ | |
39 | + | |
40 | +} |
@@ -119,6 +119,11 @@ ErrorNext:; | ||
119 | 119 | m_src = "./NullptrTmp/Extracted.nullptr"; |
120 | 120 | } |
121 | 121 | |
122 | +void Nullptr::Trim(void) | |
123 | +{ | |
124 | + | |
125 | +} | |
126 | + | |
122 | 127 | void Nullptr::Work(void) |
123 | 128 | { |
124 | 129 | do{ |
@@ -74,5 +74,23 @@ namespace VOSystemsNullptr | ||
74 | 74 | }Identifier; |
75 | 75 | |
76 | 76 | typedef std::vector<Identifier> IdentifierList; |
77 | + | |
78 | + enum ModuleMode{ | |
79 | + NotFound=0, | |
80 | + ReturnBool=1, | |
81 | + ReturnInt=2, | |
82 | + ReturnString=4, | |
83 | + }; | |
84 | + | |
85 | + struct ModuleFunction{ | |
86 | + std::string name; | |
87 | + unsigned char mode; | |
88 | + unsigned char ArguInt,ArguBool,ArguString; | |
89 | + }; | |
90 | + | |
91 | + typedef struct _Module{ | |
92 | + std::string name; | |
93 | + std::vector<struct ModuleFunction> modules; | |
94 | + }Module; | |
77 | 95 | } |
78 | 96 | } |
\ No newline at end of file |
@@ -126,6 +126,7 @@ | ||
126 | 126 | <ClCompile Include="ControlManager.cpp" /> |
127 | 127 | <ClCompile Include="int.cpp" /> |
128 | 128 | <ClCompile Include="ManageVar.cpp" /> |
129 | + <ClCompile Include="ModuleLoader.cpp" /> | |
129 | 130 | <ClCompile Include="nullptr.cpp" /> |
130 | 131 | <ClCompile Include="open.cpp" /> |
131 | 132 | </ItemGroup> |
@@ -41,6 +41,9 @@ | ||
41 | 41 | <ClCompile Include="ControlManager.cpp"> |
42 | 42 | <Filter>ソース ファイル</Filter> |
43 | 43 | </ClCompile> |
44 | + <ClCompile Include="ModuleLoader.cpp"> | |
45 | + <Filter>ソース ファイル</Filter> | |
46 | + </ClCompile> | |
44 | 47 | </ItemGroup> |
45 | 48 | <ItemGroup> |
46 | 49 | <None Include="iostream.nullptrmodule" /> |
@@ -28,6 +28,15 @@ namespace VOSystemsNullptr | ||
28 | 28 | |
29 | 29 | void LineLoad(void);//行読み込み |
30 | 30 | void Extract(void);//プリプロセッサー、展開 |
31 | + void Trim(void);//プリプロセッサー、除去 | |
32 | + | |
33 | + bool ModuleInfoLoader(std::string name); | |
34 | + bool ModuleConnect(std::string name); | |
35 | + bool ModuleRun(std::string name); | |
36 | + bool ModuleDisConnect(std::string name); | |
37 | + | |
38 | + std::vector<System::Module> m_modules; | |
39 | + System::Module m_CurrentConnectModule; | |
31 | 40 | |
32 | 41 | std::string m_stdout,m_stdin,m_stderr;//標準入出力系の名前 |
33 | 42 |