ArkScript
A small, fast, functional and scripting language for video games
JsonCompiler.hpp
Go to the documentation of this file.
1#ifndef CLI_JSONCOMPILER_HPP
2#define CLI_JSONCOMPILER_HPP
3
4#include <vector>
5#include <string>
6#include <filesystem>
7
10
11class JsonCompiler final
12{
13public:
14 /**
15 * @brief Construct a new JsonCompiler object
16 *
17 * @param debug the debug level
18 * @param lib_env list of path to the directories of the std lib
19 * @param features compiler features to enable. By default, none are active to be able to dump a file AST without any processing
20 */
21 JsonCompiler(unsigned debug, const std::vector<std::filesystem::path>& lib_env, uint16_t features = 0);
22
23 /**
24 * @brief Feed the different variables with information taken from the given source code file
25 *
26 * @param filename the name of the file
27 */
28 void feed(const std::string& filename);
29
30 /**
31 * @brief Start the compilation
32 *
33 * @return
34 */
35 std::string compile();
36
37private:
39
40 /**
41 * @brief Compile a single node and return its representation
42 *
43 * @param node
44 * @return const std::string&
45 */
46 std::string _compile(const Ark::internal::Node& node);
47
48 /**
49 * @brief Convert a NodeType::List to a JSON list
50 *
51 * @param node
52 * @param start
53 * @return std::string
54 */
55 std::string toJsonList(const Ark::internal::Node& node, std::size_t start);
56};
57
58#endif
AST node used by the parser, optimizer and compiler.
In charge of welding everything needed to compile code.
The welder joins all the compiler passes.
Definition Welder.hpp:38
A node of an Abstract Syntax Tree for ArkScript.
Definition Node.hpp:31
void feed(const std::string &filename)
Feed the different variables with information taken from the given source code file.
JsonCompiler(unsigned debug, const std::vector< std::filesystem::path > &lib_env, uint16_t features=0)
Construct a new JsonCompiler object.
std::string compile()
Start the compilation.
std::string toJsonList(const Ark::internal::Node &node, std::size_t start)
Convert a NodeType::List to a JSON list.
std::string _compile(const Ark::internal::Node &node)
Compile a single node and return its representation.
Ark::Welder m_welder