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.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/MoonP/moon_compiler.h b/src/MoonP/moon_compiler.h
new file mode 100644
index 0000000..cb1990c
--- /dev/null
+++ b/src/MoonP/moon_compiler.h
@@ -0,0 +1,39 @@
1/* Copyright (c) 2020 Jin Li, http://www.luvfight.me
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8
9#pragma once
10
11#include <string>
12#include <tuple>
13#include <list>
14#include <memory>
15
16namespace MoonP {
17
18const char* moonScriptVersion();
19
20struct MoonConfig {
21 bool lintGlobalVariable = false;
22 bool implicitReturnRoot = true;
23 bool reserveLineNumber = false;
24 bool spaceOverTab = false;
25 bool reuseVariable = false;
26 bool allowExprNotInTheEndOfBody = false;
27};
28
29struct GlobalVar {
30 std::string name;
31 int line;
32 int col;
33};
34
35using GlobalVars = std::unique_ptr<std::list<GlobalVar>>;
36
37std::tuple<std::string,std::string,GlobalVars> moonCompile(const std::string& codes, const MoonConfig& config = {});
38
39} // namespace MoonP