ArkScript
A small, fast, functional and scripting language for video games
Common.hpp
Go to the documentation of this file.
1/**
2 * @file Common.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief Common code for the compiler
5 * @version 0.4
6 * @date 2021-10-02
7 *
8 * @copyright Copyright (c) 2021-2024
9 *
10 */
11
12#ifndef ARK_COMPILER_COMMON_HPP
13#define ARK_COMPILER_COMMON_HPP
14
15#include <array>
16#include <string_view>
17#include <vector>
18
19namespace Ark
20{
21 using bytecode_t = std::vector<uint8_t>;
22}
23
24namespace Ark::internal
25{
26 /// The different node types available
27 enum class NodeType
28 {
29 Symbol,
30 Capture,
31 Keyword,
32 String,
33 Number,
34 List,
35 Spread,
36 Field,
37 Macro,
38 Unused
39 };
40
41 constexpr std::array<std::string_view, 10> nodeTypes = {
42 "Symbol",
43 "Capture",
44 "Keyword",
45 "String",
46 "Number",
47 "List",
48 "Spread",
49 "Field",
50 "Macro",
51 "Unused"
52 };
53
54 /// The different keywords available
55 enum class Keyword
56 {
57 Fun,
58 Let,
59 Mut,
60 Set,
61 If,
62 While,
63 Begin,
64 Import,
65 Del
66 };
67
68 /// List of available keywords in ArkScript
69 constexpr std::array<std::string_view, 9> keywords = {
70 "fun",
71 "let",
72 "mut",
73 "set",
74 "if",
75 "while",
76 "begin",
77 "import",
78 "del"
79 };
80
81 // This list is related to include/Ark/Compiler/Instructions.hpp
82 // from FIRST_OPERATOR, to LAST_OPERATOR
83 // The order is very important
84 constexpr std::array<std::string_view, 25> operators = {
85 "+", "-", "*", "/",
86 ">", "<", "<=", ">=", "!=", "=",
87 "len", "empty?", "tail", "head",
88 "nil?", "assert",
89 "toNumber", "toString",
90 "@", "and", "or", "mod",
91 "type", "hasField",
92 "not"
93 };
94}
95
96#endif
NodeType
The different node types available.
Definition: Common.hpp:28
constexpr std::array< std::string_view, 25 > operators
Definition: Common.hpp:84
Keyword
The different keywords available.
Definition: Common.hpp:56
constexpr std::array< std::string_view, 10 > nodeTypes
Definition: Common.hpp:41
constexpr std::array< std::string_view, 9 > keywords
List of available keywords in ArkScript.
Definition: Common.hpp:69
Definition: Builtins.hpp:21
std::vector< uint8_t > bytecode_t
Definition: Common.hpp:21