ArkScript
A small, fast, functional and scripting language for video games
ConsoleStyle.hpp
Go to the documentation of this file.
1/**
2 * @file ConsoleStyle.hpp
3 * @author Alexandre Plateau ([email protected])
4 * @brief Colors per token used by replxx
5 * @version 0.2
6 * @date 2020-10-27
7 *
8 * @copyright Copyright (c) 2020-2022
9 *
10 */
11
12#ifndef ARK_REPL_CONSOLESTYLE_HPP
13#define ARK_REPL_CONSOLESTYLE_HPP
14
15#include <replxx.hxx>
16
17using Replxx = replxx::Replxx;
18
19namespace Ark
20{
21 const std::vector<std::string> KeywordsDict {
22 // Keywords
23 "if", "let", "mut", "set",
24 "fun", "while", "begin", "import",
25 "quote", "del",
26 // Operators
27 "len", "empty?", "tail", "head",
28 "nil?", "assert", "toNumber",
29 "toString", "and", "or", "mod",
30 "type", "hasField", "not",
31 // Constants
32 "true", "false", "nil", "math:pi",
33 "math:e", "math:tau", "math:Inf", "math:NaN",
34 // Functions
35 // List
36 "append", "concat", "list", "list:reverse",
37 "list:find", "list:slice", "list:sort",
38 "list:fill", "list:setAt",
39 // IO
40 "print", "puts", "input", "io:writeFile",
41 "io:readFile", "io:fileExists?", "io:listFiles", "io:dir?",
42 "io:makeDir", "io:removeFiles",
43 // Times
44 "time",
45 // System
46 "sys:exec", "sys:sleep",
47 // String
48 "str:format", "str:find", "str:removeAt",
49 // Mathematics
50 "math:exp", "math:ln", "math:ceil", "math:floor",
51 "math:round", "math:NaN?", "Inf?", "math:cos",
52 "math:sin", "math:tan", "math:arccos", "math:arcsin",
53 "math:arctan",
54 // Commands
55 "quit"
56 };
57
58 const std::vector<std::pair<std::string, Replxx::Color>> ColorsRegexDict {
59 // Keywords
60 { "if", Replxx::Color::BRIGHTRED },
61 { "let", Replxx::Color::BRIGHTRED },
62 { "mut", Replxx::Color::BRIGHTRED },
63 { "set", Replxx::Color::BRIGHTRED },
64 { "fun", Replxx::Color::BRIGHTRED },
65 { "while", Replxx::Color::BRIGHTRED },
66 { "begin", Replxx::Color::BRIGHTRED },
67 { "import", Replxx::Color::BRIGHTRED },
68 { "quote", Replxx::Color::BRIGHTRED },
69 { "del", Replxx::Color::BRIGHTRED },
70 // Operators
71 { "\\\"", Replxx::Color::BRIGHTBLUE },
72 { "\\-", Replxx::Color::BRIGHTBLUE },
73 { "\\+", Replxx::Color::BRIGHTBLUE },
74 { "\\=", Replxx::Color::BRIGHTBLUE },
75 { "\\/", Replxx::Color::BRIGHTBLUE },
76 { "\\*", Replxx::Color::BRIGHTBLUE },
77 { "\\<", Replxx::Color::BRIGHTBLUE },
78 { "\\>", Replxx::Color::BRIGHTBLUE },
79 { "\\!", Replxx::Color::BRIGHTBLUE },
80 { "\\[", Replxx::Color::BRIGHTBLUE },
81 { "\\]", Replxx::Color::BRIGHTBLUE },
82 { "@", Replxx::Color::BRIGHTBLUE },
83 { "len", Replxx::Color::BRIGHTBLUE },
84 { "empty?", Replxx::Color::BRIGHTBLUE },
85 { "tail", Replxx::Color::BRIGHTBLUE },
86 { "head", Replxx::Color::BRIGHTBLUE },
87 { "nil?", Replxx::Color::BRIGHTBLUE },
88 { "assert", Replxx::Color::BRIGHTBLUE },
89 { "toNumber", Replxx::Color::BRIGHTBLUE },
90 { "toString", Replxx::Color::BRIGHTBLUE },
91 { "and", Replxx::Color::BRIGHTBLUE },
92 { "or ", Replxx::Color::BRIGHTBLUE },
93 { "mod", Replxx::Color::BRIGHTBLUE },
94 { "type", Replxx::Color::BRIGHTBLUE },
95 { "hasField", Replxx::Color::BRIGHTBLUE },
96 { "not", Replxx::Color::BRIGHTBLUE },
97 // Constants
98 { "true", Replxx::Color::RED },
99 { "false", Replxx::Color::RED },
100 { "nil", Replxx::Color::RED },
101 { "math:pi", Replxx::Color::BLUE },
102 { "math:e", Replxx::Color::BLUE },
103 { "math:tau", Replxx::Color::BLUE },
104 { "math:Inf", Replxx::Color::BLUE },
105 { "math:NaN", Replxx::Color::BLUE },
106 // Functions
107 // List
108 { "append", Replxx::Color::BRIGHTGREEN },
109 { "concat", Replxx::Color::BRIGHTGREEN },
110 { "pop", Replxx::Color::BRIGHTGREEN },
111 { "append!", Replxx::Color::BRIGHTGREEN },
112 { "concat!", Replxx::Color::BRIGHTGREEN },
113 { "pop!", Replxx::Color::BRIGHTGREEN },
114 { "list", Replxx::Color::BRIGHTGREEN },
115 { "list:reverse", Replxx::Color::BRIGHTGREEN },
116 { "list:find", Replxx::Color::BRIGHTGREEN },
117 { "list:slice", Replxx::Color::BRIGHTGREEN },
118 { "list:sort", Replxx::Color::BRIGHTGREEN },
119 { "list:fill", Replxx::Color::BRIGHTGREEN },
120 { "list:setAt", Replxx::Color::BRIGHTGREEN },
121 // IO
122 { "print", Replxx::Color::GREEN },
123 { "puts", Replxx::Color::GREEN },
124 { "input", Replxx::Color::GREEN },
125 { "io:writeFile", Replxx::Color::GREEN },
126 { "io:readFile", Replxx::Color::GREEN },
127 { "io:fileExists?", Replxx::Color::GREEN },
128 { "io:listFiles", Replxx::Color::GREEN },
129 { "io:dir?", Replxx::Color::GREEN },
130 { "io:makeDir", Replxx::Color::GREEN },
131 { "io:removeFiles", Replxx::Color::GREEN },
132 // Times
133 { "time", Replxx::Color::GREEN },
134 // System
135 { "sys:exec", Replxx::Color::GREEN },
136 { "sys:sleep", Replxx::Color::GREEN },
137 { "sys:exit", Replxx::Color::GREEN },
138 // String
139 { "str:format", Replxx::Color::BRIGHTGREEN },
140 { "str:find", Replxx::Color::BRIGHTGREEN },
141 { "str:removeAt", Replxx::Color::BRIGHTGREEN },
142 { "str:ord", Replxx::Color::BRIGHTGREEN },
143 { "str:chr", Replxx::Color::BRIGHTGREEN },
144 // Mathematics
145 { "math:exp", Replxx::Color::BRIGHTCYAN },
146 { "math:ln", Replxx::Color::BRIGHTCYAN },
147 { "math:ceil", Replxx::Color::BRIGHTCYAN },
148 { "math:floor", Replxx::Color::BRIGHTCYAN },
149 { "math:round", Replxx::Color::BRIGHTCYAN },
150 { "math:NaN?", Replxx::Color::BRIGHTCYAN },
151 { "math:Inf?", Replxx::Color::BRIGHTCYAN },
152 { "math:cos", Replxx::Color::BRIGHTCYAN },
153 { "math:sin", Replxx::Color::BRIGHTCYAN },
154 { "math:tan", Replxx::Color::BRIGHTCYAN },
155 { "math:arccos", Replxx::Color::BRIGHTCYAN },
156 { "math:arcsin", Replxx::Color::BRIGHTCYAN },
157 { "math:arctan", Replxx::Color::BRIGHTCYAN },
158 { "math:cosh", Replxx::Color::BRIGHTCYAN },
159 { "math:sinh", Replxx::Color::BRIGHTCYAN },
160 { "math:tanh", Replxx::Color::BRIGHTCYAN },
161 { "math:acosh", Replxx::Color::BRIGHTCYAN },
162 { "math:asinh", Replxx::Color::BRIGHTCYAN },
163 { "math:atanh", Replxx::Color::BRIGHTCYAN },
164 // Numbers
165 { "[\\-|+]{0,1}[0-9]+(\\.[0-9]+)?", Replxx::Color::YELLOW },
166 // Strings
167 { "\".*?\"", Replxx::Color::BRIGHTGREEN },
168 // Commands
169 { "quit", Replxx::Color::BRIGHTMAGENTA }
170 };
171}
172
173#endif
replxx::Replxx Replxx
Definition: Builtins.hpp:21
const std::vector< std::pair< std::string, Replxx::Color > > ColorsRegexDict
const std::vector< std::string > KeywordsDict