ArkScript
A small, fast, functional and scripting language for video games
JsonCompiler.hpp
Go to the documentation of this file.
1#ifndef ARK_COMPILER_JSONCOMPILER_HPP
2#define ARK_COMPILER_JSONCOMPILER_HPP
3
4#include <vector>
5#include <string>
6
7#include <Ark/Constants.hpp>
8#include <Ark/Platform.hpp>
12
13namespace Ark
14{
16 {
17 public:
18 /**
19 * @brief Construct a new JsonCompiler object
20 *
21 * @param debug the debug level
22 * @param options the compilers options
23 */
24 JsonCompiler(unsigned debug, const std::vector<std::string>& libenv, uint16_t options = DefaultFeatures);
25
26 /**
27 * @brief Feed the differents variables with information taken from the given source code file
28 *
29 * @param code the code of the file
30 * @param filename the name of the file
31 */
32 void feed(const std::string& code, const std::string& filename = ARK_NO_NAME_FILE);
33
34 /**
35 * @brief Start the compilation
36 *
37 * @return
38 */
39 std::string compile();
40
41 private:
44 uint16_t m_options;
45 unsigned m_debug; ///< the debug level of the compiler
46
47 /**
48 * @brief Compile a single node and return its representation
49 *
50 * @param node
51 * @return const std::string&
52 */
53 std::string _compile(const internal::Node& node);
54
55 /**
56 * @brief Convert a NodeType::List to a JSON list
57 *
58 * @param node
59 * @param start
60 * @return std::string
61 */
62 std::string toJsonList(const internal::Node& node, std::size_t start);
63 };
64}
65
66#endif
Constants used by ArkScript.
#define ARK_NO_NAME_FILE
Definition: Constants.hpp:26
#define ARK_API
Definition: Module.hpp:29
AST node used by the parser, optimizer and compiler.
Optimizes a given ArkScript AST.
Parses a token stream into an AST by using the Ark::Node.
ArkScript configuration macros.
unsigned m_debug
the debug level of the compiler
internal::Parser m_parser
internal::Optimizer m_optimizer
A node of an Abstract Syntax Tree for ArkScript.
Definition: Node.hpp:29
The ArkScript AST optimizer.
Definition: Optimizer.hpp:32
The parser is responsible of constructing the Abstract Syntax Tree from a token list.
Definition: Parser.hpp:44
Definition: Builtins.hpp:21
constexpr uint16_t DefaultFeatures
Definition: Constants.hpp:52