• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

自作言語nullptrのインタープリターです。


Commit MetaInfo

Revision2f9a4d9b0c2432c2e2929890c583fe939b5ced02 (tree)
Time2015-08-10 23:29:32
AuthorDiverge <diverge.vosystems@gmai...>
CommiterDiverge

Log Message

Begin to split Interpreter source file
Nullptr
|--Preprocessor
|--Module
|--Interpreter

Change Summary

Incremental Difference

Binary files a/nullptr.sdf and b/nullptr.sdf differ
--- a/nullptr/BasicModule.cpp
+++ b/nullptr/BasicModule.cpp
@@ -4,7 +4,7 @@
44 */
55
66 #include"nullptr.h"
7-#include"nullptrInterpreter.h"
7+#include"Interpreter.h"
88 #include<iostream>
99 #include<fstream>
1010 #include<direct.h>
--- a/nullptr/ControlManager.cpp
+++ b/nullptr/ControlManager.cpp
@@ -4,7 +4,7 @@
44 */
55
66 #include"nullptr.h"
7-#include"nullptrInterpreter.h"
7+#include"Interpreter.h"
88 #include<iostream>
99 #include<fstream>
1010 #include<direct.h>
Binary files a/nullptr/Debug/nullptr.tlog/CL.command.1.tlog and b/nullptr/Debug/nullptr.tlog/CL.command.1.tlog differ
Binary files a/nullptr/Debug/nullptr.tlog/CL.read.1.tlog and b/nullptr/Debug/nullptr.tlog/CL.read.1.tlog differ
Binary files a/nullptr/Debug/nullptr.tlog/CL.write.1.tlog and b/nullptr/Debug/nullptr.tlog/CL.write.1.tlog differ
--- a/nullptr/Debug/nullptr.tlog/nullptr.lastbuildstate
+++ b/nullptr/Debug/nullptr.tlog/nullptr.lastbuildstate
@@ -1,2 +1,2 @@
11 #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit
2-Debug|Win32|C:\Users\VOSystems\Documents\Visual Studio 2015\Projects\nullptr\|
2+Debug|Win32|C:\Users\VOSystems\documents\visual studio 2015\Projects\nullptr\|
Binary files a/nullptr/Debug/vc140.idb and b/nullptr/Debug/vc140.idb differ
--- /dev/null
+++ b/nullptr/Interpreter.h
@@ -0,0 +1,84 @@
1+/*
2+nullptr Interpreter.
3+(C) 2015 VOSystems.
4+*/
5+
6+#pragma once
7+
8+#include<vector>
9+#include<string>
10+#include<regex>
11+#include<fstream>
12+#include"nullptr.h"
13+
14+namespace VOSystemsNullptr
15+{
16+ namespace Core
17+ {
18+ class Interpreter
19+ {
20+ private:
21+ std::vector<BasicTypes::IntManager> m_int;//Int変数リスト
22+ std::vector<BasicTypes::String> m_string;//String変数リスト
23+ std::vector<BasicTypes::Bool> m_bool;//bool変数リスト
24+ System::IdentifierList m_list;//識別子リスト
25+
26+ std::string m_workline;//行の内容(セミコロンの次からセミコロンまで)
27+
28+ std::streamoff m_eip;//x86のEIPと同じ、命令ポインタ
29+ std::string m_src;//ソースファイル名
30+
31+ void LineLoad(void);//行読み込み
32+ void Extract(void);//プリプロセッサー、展開
33+ void Trim(void);//プリプロセッサー、除去
34+
35+
36+ std::string m_stdout,m_stdin,m_stderr;//標準入出力系の名前
37+
38+ std::vector<std::string> Split(const std::string &str, const std::string &delim);//文字列分割
39+ std::string Replace(std::string src, std::string before, std::string after);//文字列置き換え
40+ bool Find(const std::string& str, const std::string& find);//文字列検索
41+
42+ void Screen(std::string line);//ベーシックモジュール->標準出力
43+ void Keyboard(std::string line);//ベーシックモジュール->標準入力
44+ void EScreen(std::string line);//ベーシックモジュール標準エラー出力
45+
46+ bool NewInt(std::string name, BasicTypes::Int value);//Int変数作成
47+ bool AssignInt(std::string name, BasicTypes::Int value);//Int変数代入
48+ bool GetInt(std::string name, BasicTypes::Int& target);//Int変数、値取得
49+
50+ bool NewStr(std::string name, std::string value);//String変数作成
51+ bool AssignStr(std::string name, std::string value);//String変数代入
52+ bool GetStr(std::string name, std::string& target);//String変数、値取得
53+
54+ bool NewVar(std::string line);//変数作成
55+
56+ bool If(std::string line);
57+ bool For(std::string line);
58+ bool While(std::string line);
59+ bool Loop(std::string line);
60+ bool Switch(std::string line);
61+ bool Goto(std::string line);
62+ bool GetBool(std::string judge);
63+
64+ std::vector<std::string> Lex(std::string formula);
65+ std::vector<std::string> ReplaceVar2Num(std::vector<std::string> formula);
66+ BasicTypes::Int Calc(std::vector<std::string> lex);
67+ std::vector<std::string> ProcBrackets(std::vector<std::string> lex);
68+ std::string CalcBracket(std::string inBracket);
69+ /*バージョン*/
70+ unsigned int
71+ m_major=0,
72+ m_minor=0,
73+ m_build=12,
74+ m_revision=30;
75+
76+
77+ public:
78+ Nullptr(std::string file);
79+ ~Nullptr(void);
80+
81+ void Work(void);
82+ };
83+ }
84+}
\ No newline at end of file
--- a/nullptr/ManageVar.cpp
+++ b/nullptr/ManageVar.cpp
@@ -4,7 +4,7 @@
44 */
55
66 #include"nullptr.h"
7-#include"nullptrInterpreter.h"
7+#include"Interpreter.h"
88 #include<regex>
99 #include<vector>
1010 #include<string>
--- /dev/null
+++ b/nullptr/Module.h
@@ -0,0 +1,26 @@
1+#pragma once
2+
3+#include<string>
4+
5+#include"nullptr.h"
6+#include"Preprocessor.h"
7+#include"Interpreter.h"
8+
9+namespace VOSystemsNullptr
10+{
11+ namespace Core
12+ {
13+ class Module
14+ {
15+ private:
16+ std::vector<System::Module> m_modules;
17+ System::Module m_CurrentConnectModule;
18+
19+ public:
20+ bool Load(std::string name);
21+ bool Connect(std::string name);
22+ bool Run(std::string name, BasicTypes::Int* paramInt, BasicTypes::String paramString);
23+ bool DisConnect(std::string name);
24+ };
25+ }
26+}
\ No newline at end of file
--- a/nullptr/ModuleLoader.cpp
+++ b/nullptr/ModuleLoader.cpp
@@ -4,37 +4,78 @@ nullptr interpreter
44 */
55
66 #include"nullptr.h"
7-#include"nullptrInterpreter.h"
7+#include"Interpreter.h"
8+#include"Module.h"
9+#include<regex>
810
911 using namespace std;
10-using namespace VOSystemsNullptr;
12+using namespace VOSystemsNullptr::Core;
1113
12-bool Nullptr::ModuleInfoLoader(std::string name)
14+bool Module::Load(std::string name)
1315 {
1416 string src=m_src;
1517 string work=m_workline;
16-
18+
19+ System::Module module;
20+ module.name=name;
21+ string ident[3]={"Int","String","bool"};
1722 m_src=name+".nullptrmodule";
1823 do{
1924 LineLoad();
25+ if(regex_match(m_workline,regex(".+ .+(.+)"))){
26+ System::ModuleFunction mf;
27+ string::iterator namestart,nameend;
28+
29+ m_workline=Replace(m_workline," ","");
30+
31+ if(regex_match(m_workline,regex("bool .+(.+)"))){
32+ mf.mode=System::ReturnBool;
33+ namestart=m_workline.begin()+5;
34+
35+ }else if(regex_match(m_workline,regex("Int .+(.+)"))){
36+ mf.mode=System::ReturnInt;
37+ namestart=m_workline.begin()+4;
2038
39+ }else if(regex_match(m_workline,regex("String .+(.+)"))){
40+ mf.mode=System::ReturnString;
41+ namestart=m_workline.begin()+7;
42+
43+ }
44+ nameend=m_workline.begin()+m_workline.find_first_of('(');
45+ mf.name=string(namestart,nameend);
46+
47+ size_t offset=0;
48+ unsigned char count[3]={0};
49+ for(size_t C=0; C<3; C++){
50+ do{
51+ offset=m_workline.find(ident[C],offset+1);
52+ count[C]++;
53+ }while(offset==string::npos);
54+ }
55+ mf.ArguInt=count[0];
56+ mf.ArguString=count[1];
57+ mf.ArguBool=count[2];
58+
59+ module.modules.push_back(mf);
60+ }
2161 }while(!m_workline.empty());
62+ m_modules.push_back(module);
2263
2364 m_src=src;
2465 m_workline=work;
2566 }
2667
27-bool Nullptr::ModuleConnect(std::string name)
68+bool Module::Connect(std::string name)
2869 {
29-
70+
3071 }
3172
32-bool Nullptr::ModuleRun(std::string name)
73+bool Module::Run(std::string name, BasicTypes::Int* paramInt, BasicTypes::String paramString)
3374 {
3475
3576 }
3677
37-bool Nullptr::ModuleDisConnect(std::string name)
78+bool Module::DisConnect(std::string name)
3879 {
3980
4081 }
--- /dev/null
+++ b/nullptr/Preprocessor.h
@@ -0,0 +1,18 @@
1+#pragma once
2+
3+#include"nullptr.h"
4+#include"Interpreter.h"
5+
6+namespace VOSystemsNullptr
7+{
8+ namespace Core
9+ {
10+ class Preprocessor
11+ {
12+ private:
13+
14+ public:
15+
16+ };
17+ }
18+}
\ No newline at end of file
--- a/nullptr/nullptr.cpp
+++ b/nullptr/nullptr.cpp
@@ -4,7 +4,7 @@
44 */
55
66 #include"nullptr.h"
7-#include"nullptrInterpreter.h"
7+#include"Interpreter.h"
88 #include<iostream>
99 #include<fstream>
1010 #include<direct.h>
--- a/nullptr/nullptr.h
+++ b/nullptr/nullptr.h
@@ -12,6 +12,14 @@
1212
1313 namespace VOSystemsNullptr
1414 {
15+ class Nullptr
16+ {
17+ private:
18+
19+ public:
20+
21+ };
22+
1523 namespace BasicTypes
1624 {
1725
@@ -92,5 +100,17 @@ namespace VOSystemsNullptr
92100 std::string name;
93101 std::vector<struct ModuleFunction> modules;
94102 }Module;
103+
104+ class FileComponent
105+ {
106+ private:
107+ size_t m_p_loaded;
108+ protected:
109+ std::string m_src;
110+ public:
111+ virtual std::string Load(void);
112+
113+ };
95114 }
115+#define loop(count) for(size_t LoopCounter=0; LoopCounter<count; LoopCounter++)
96116 }
\ No newline at end of file
--- a/nullptr/nullptr.vcxproj
+++ b/nullptr/nullptr.vcxproj
@@ -118,8 +118,10 @@
118118 </Link>
119119 </ItemDefinitionGroup>
120120 <ItemGroup>
121+ <ClInclude Include="Module.h" />
121122 <ClInclude Include="nullptr.h" />
122- <ClInclude Include="nullptrInterpreter.h" />
123+ <ClInclude Include="Interpreter.h" />
124+ <ClInclude Include="Preprocessor.h" />
123125 </ItemGroup>
124126 <ItemGroup>
125127 <ClCompile Include="BasicModule.cpp" />
--- a/nullptr/nullptr.vcxproj.filters
+++ b/nullptr/nullptr.vcxproj.filters
@@ -18,7 +18,13 @@
1818 <ClInclude Include="nullptr.h">
1919 <Filter>ヘッダー ファイル</Filter>
2020 </ClInclude>
21- <ClInclude Include="nullptrInterpreter.h">
21+ <ClInclude Include="Preprocessor.h">
22+ <Filter>ヘッダー ファイル</Filter>
23+ </ClInclude>
24+ <ClInclude Include="Interpreter.h">
25+ <Filter>ヘッダー ファイル</Filter>
26+ </ClInclude>
27+ <ClInclude Include="Module.h">
2228 <Filter>ヘッダー ファイル</Filter>
2329 </ClInclude>
2430 </ItemGroup>
--- a/nullptr/nullptrInterpreter.h
+++ /dev/null
@@ -1,88 +0,0 @@
1-/*
2-nullptr Interpreter.
3-(C) 2015 VOSystems.
4-*/
5-
6-#pragma once
7-
8-#include<vector>
9-#include<string>
10-#include<regex>
11-#include<fstream>
12-#include"nullptr.h"
13-
14-namespace VOSystemsNullptr
15-{
16- class Nullptr
17- {
18- private:
19- std::vector<BasicTypes::IntManager> m_int;//Int変数リスト
20- std::vector<BasicTypes::String> m_string;//String変数リスト
21- std::vector<BasicTypes::Bool> m_bool;//bool変数リスト
22- System::IdentifierList m_list;//識別子リスト
23-
24- std::string m_workline;//行の内容(セミコロンの次からセミコロンまで)
25-
26- std::streamoff m_eip;//x86のEIPと同じ、命令ポインタ
27- std::string m_src;//ソースファイル名
28-
29- void LineLoad(void);//行読み込み
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;
40-
41- std::string m_stdout,m_stdin,m_stderr;//標準入出力系の名前
42-
43- std::vector<std::string> Split(const std::string &str, const std::string &delim);//文字列分割
44- std::string Replace(std::string src, std::string before, std::string after);//文字列置き換え
45- bool Find(const std::string& str, const std::string& find);//文字列検索
46-
47- void Screen(std::string line);//ベーシックモジュール->標準出力
48- void Keyboard(std::string line);//ベーシックモジュール->標準入力
49- void EScreen(std::string line);//ベーシックモジュール標準エラー出力
50-
51- bool NewInt(std::string name, BasicTypes::Int value);//Int変数作成
52- bool AssignInt(std::string name, BasicTypes::Int value);//Int変数代入
53- bool GetInt(std::string name, BasicTypes::Int& target);//Int変数、値取得
54-
55- bool NewStr(std::string name, std::string value);//String変数作成
56- bool AssignStr(std::string name, std::string value);//String変数代入
57- bool GetStr(std::string name, std::string& target);//String変数、値取得
58-
59- bool NewVar(std::string line);//変数作成
60-
61- bool If(std::string line);
62- bool For(std::string line);
63- bool While(std::string line);
64- bool Loop(std::string line);
65- bool Switch(std::string line);
66- bool Goto(std::string line);
67- bool GetBool(std::string judge);
68-
69- std::vector<std::string> Lex(std::string formula);
70- std::vector<std::string> ReplaceVar2Num(std::vector<std::string> formula);
71- BasicTypes::Int Calc(std::vector<std::string> lex);
72- std::vector<std::string> ProcBrackets(std::vector<std::string> lex);
73- std::string CalcBracket(std::string inBracket);
74- /*バージョン*/
75- unsigned int
76- m_major=0,
77- m_minor=0,
78- m_build=12,
79- m_revision=30;
80-
81-
82- public:
83- Nullptr(std::string file);
84- ~Nullptr(void);
85-
86- void Work(void);
87- };
88-}
\ No newline at end of file
--- a/nullptr/open.cpp
+++ b/nullptr/open.cpp
@@ -1,5 +1,5 @@
11 #include"nullptr.h"
2-#include"nullptrInterpreter.h"
2+#include"Interpreter.h"
33 int main(void)
44 {
55 VOSystemsNullptr::Nullptr npr("test.nullptr");