aboutsummaryrefslogtreecommitdiff
path: root/src/MoonP/moon_compiler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/MoonP/moon_compiler.h')
-rw-r--r--src/MoonP/moon_compiler.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/MoonP/moon_compiler.h b/src/MoonP/moon_compiler.h
index cb57d57..a1a5ce5 100644
--- a/src/MoonP/moon_compiler.h
+++ b/src/MoonP/moon_compiler.h
@@ -13,6 +13,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
13#include <tuple> 13#include <tuple>
14#include <list> 14#include <list>
15#include <memory> 15#include <memory>
16#include <unordered_map>
16#include <functional> 17#include <functional>
17 18
18namespace MoonP { 19namespace MoonP {
@@ -20,12 +21,15 @@ namespace MoonP {
20extern const std::string_view version; 21extern const std::string_view version;
21extern const std::string_view extension; 22extern const std::string_view extension;
22 23
24using Options = std::unordered_map<std::string,std::string>;
25
23struct MoonConfig { 26struct MoonConfig {
24 bool lintGlobalVariable = false; 27 bool lintGlobalVariable = false;
25 bool implicitReturnRoot = true; 28 bool implicitReturnRoot = true;
26 bool reserveLineNumber = true; 29 bool reserveLineNumber = true;
27 bool useSpaceOverTab = false; 30 bool useSpaceOverTab = false;
28 int lineOffset = 0; 31 int lineOffset = 0;
32 Options options;
29}; 33};
30 34
31struct GlobalVar { 35struct GlobalVar {
@@ -34,7 +38,14 @@ struct GlobalVar {
34 int col; 38 int col;
35}; 39};
36 40
37using GlobalVars = std::unique_ptr<std::list<GlobalVar>>; 41using GlobalVars = std::list<GlobalVar>;
42
43struct CompileInfo {
44 std::string codes;
45 std::string error;
46 std::unique_ptr<GlobalVars> globals;
47 std::unique_ptr<Options> options;
48};
38 49
39class MoonCompilerImpl; 50class MoonCompilerImpl;
40 51
@@ -44,7 +55,7 @@ public:
44 const std::function<void(void*)>& luaOpen = nullptr, 55 const std::function<void(void*)>& luaOpen = nullptr,
45 bool sameModule = false); 56 bool sameModule = false);
46 virtual ~MoonCompiler(); 57 virtual ~MoonCompiler();
47 std::tuple<std::string,std::string,GlobalVars> compile(std::string_view codes, const MoonConfig& config = {}); 58 CompileInfo compile(std::string_view codes, const MoonConfig& config = {});
48private: 59private:
49 std::unique_ptr<MoonCompilerImpl> _compiler; 60 std::unique_ptr<MoonCompilerImpl> _compiler;
50}; 61};