This repository has been archived by the owner on Jun 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flacat
269 lines (203 loc) · 11 KB
/
flacat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/usr/bin/env fla
/> MIT License
#
# Copyright (c) 2020 Ferhat Geçdoğan All Rights Reserved.
# Distributed under the terms of the MIT License.
#
</
/> Check version of FlaScript (Required latest version) </
except(version) : 0.3 -> { error("Huh. Install new version of FlaScript") print(newline) } version;
/> TODO: Add statements for language parser </
main() -> main {
var(string) -> sample_ -> input_file <-
var(string) -> sample_2 -> data_ <-
print(string) -> "File: "
@input(string) -> input_file <
@readfile -> data_ -> var(input_file) <
statement[#flascript_syntax]
/> Parse escape sequences </
@escape_seq -> data_ <
@echo -> data_ <-
} main;
#bash_syntax ->
if[find(var(input_file), ".bash")] -> {
func -> Shell_Script()
} else -> { func -> Regular() } <-
#bash_syntax <-
#shell_script_syntax ->
if[find(var(input_file), ".sh")] -> {
func -> Shell_Script()
} else -> {
statement[#bash_syntax]
} <-
#shell_script_syntax <-
#python_syntax ->
if[find(var(input_file), ".py")] -> {
func -> Python()
} else -> {
statement[#shell_script_syntax]
} <-
#python_syntax <-
#cplusplus_syntax ->
if[find(var(input_file), ".cpp")] -> {
func -> CPlusPlus()
} else -> {
statement[#python_syntax]
} <-
#cplusplus_syntax <-
#flascript_syntax ->
if[find(var(input_file), ".fls")] -> {
func -> FlaScript()
} else -> { statement[#cplusplus_syntax] } <-
#flascript_syntax <-
func -> Regular() {
@replace_all -> data_ : "int" -> "\033[1;34mint\033[0m" <
@replace_all -> data_ : "bool" -> "\033[1;34mbool\033[0m" <
@replace_all -> data_ : "char" -> "\033[1;34mchar\033[0m" <
@replace_all -> data_ : "void" -> "\033[1;31mvoid\033[0m" <
@replace_all -> data_ : "const" -> "\033[1;94mconst\033[0m" <
} Regular;
func -> CPlusPlus() {
@replace_all -> data_ : "int" -> "\033[1;34mint\033[0m" <
@replace_all -> data_ : "long" -> "\033[1;34mlong\033[0m" <
@replace_all -> data_ : "bool" -> "\033[1;34mbool\033[0m" <
@replace_all -> data_ : "char" -> "\033[1;34mchar\033[0m" <
@replace_all -> data_ : "auto" -> "\033[1;34mauto\033[0m" <
@replace_all -> data_ : "if " -> "\033[1;91mif\033[0m" <
@replace_all -> data_ : "else" -> "\033[1;91melse\033[0m" <
@replace_all -> data_ : "for" -> "\033[1;35mfor\033[0m" <
@replace_all -> data_ : "do " -> "\033[1;35mdo\033[0m" <
@replace_all -> data_ : "while" -> "\033[1;35mwhile\033[0m" <
@replace_all -> data_ : "void" -> "\033[1;31mvoid\033[0m" <
@replace_all -> data_ : "main" -> "\033[1;91mmain\033[0m" <
@replace_all -> data_ : "asm" -> "\033[1;91masm\033[0m" <
@replace_all -> data_ : "const" -> "\033[1;94mconst\033[0m" <
@replace_all -> data_ : "static" -> "\033[1;94mstatic\033[0m" <
@replace_all -> data_ : "extern" -> "\033[1;94mextern\033[0m" <
@replace_all -> data_ : "inline" -> "\033[1;94minline\033[0m" <
@replace_all -> data_ : "virtual" -> "\033[1;94mvirtual\033[0m" <
@replace_all -> data_ : "friend" -> "\033[1;94mfriend\033[0m" <
@replace_all -> data_ : "public" -> "\033[1;94mpublic\033[0m" <
@replace_all -> data_ : "private" -> "\033[1;94mprivate\033[0m" <
@replace_all -> data_ : "protected" -> "\033[1;94mprotected\033[0m" <
@replace_all -> data_ : "@append" -> "\033[1;96m@append\033[0m" <
@replace_all -> data_ : "@pop_back" -> "\033[1;96m@pop_back\033[0m" <
@replace_all -> data_ : "@between" -> "\033[1;96m@between\033[0m" <
@replace_all -> data_ : "@readfile" -> "\033[1;96m@readfile\033[0m" <
@replace_all -> data_ : "@replace_all" -> "\033[1;96m@replace_all\033[0m" <
@replace_all -> data_ : "#include" -> "\033[1;33m#include\033[0m" <
@replace_all -> data_ : "typedef" -> "\033[1;35mtypedef\033[0m" <
@replace_all -> data_ : "#define" -> "\033[1;35m#define\033[0m" <
@replace_all -> data_ : "#ifndef" -> "\033[1;35m#ifndef\033[0m" <
@replace_all -> data_ : "#Ifdef" -> "\033[1;35m#ifdef\033[0m" <
@replace_all -> data_ : "return" -> "\033[1;95mreturn\033[0m" <
@replace_all -> data_ : "nodiscard" -> "\033[1;90mnodiscard\033[0m" <
@replace_all -> data_ : "class" -> "\033[1;93mclass\033[0m" <
@replace_all -> data_ : "struct" -> "\033[1;93mstruct\033[0m" <
@replace_all -> data_ : "namespace" -> "\033[1;93mnamespace\033[0m" <
@replace_all -> data_ : "class" -> "\033[1;92musing\033[0m" <
@replace_all -> data_ : "std" -> "\033[1;93mstd\033[0m" <
@replace_all -> data_ : "iostream" -> "\033[1;95miostream\033[0m" <
@replace_all -> data_ : "cstring" -> "\033[1;95mcstring\033[0m" <
@replace_all -> data_ : "sstream" -> "\033[1;95msstream\033[0m" <
@replace_all -> data_ : "fstream" -> "\033[1;95mfstream\033[0m" <
@replace_all -> data_ : "memory" -> "\033[1;95mmemory\033[0m" <
@replace_all -> data_ : "cstdlib" -> "\033[1;95mcstdlib\033[0m" <
@replace_all -> data_ : "cstdio" -> "\033[1;95mcstdio\033[0m" <
@replace_all -> data_ : "vector" -> "\033[1;95mvector\033[0m" <
@replace_all -> data_ : "algoritm" -> "\033[1;95malgorithm\033[0m" <
@replace_all -> data_ : "thread" -> "\033[1;95mthread\033[0m" <
@replace_all -> data_ : "array" -> "\033[1;95marray\033[0m" <
@replace_all -> data_ : "bitset" -> "\033[1;95mbitset\033[0m" <
@replace_all -> data_ : "deque" -> "\033[1;95mdeque\033[0m" <
@replace_all -> data_ : "map" -> "\033[1;95mmap\033[0m" <
@replace_all -> data_ : "stack" -> "\033[1;95mstack\033[0m" <
@replace_all -> data_ : "set" -> "\033[1;95mset\033[0m" <
@replace_all -> data_ : "iterator" -> "\033[1;95miterator\033[0m" <
@replace_all -> data_ : "tuple" -> "\033[1;95mtuple\033[0m" <
@replace_all -> data_ : "locale" -> "\033[1;95mlocale\033[0m" <
@replace_all -> data_ : "regex" -> "\033[1;95mregex\033[0m" <
@replace_all -> data_ : "istream" -> "\033[1;95mistream\033[0m" <
@replace_all -> data_ : "ostream" -> "\033[1;95mostream\033[0m" <
@replace_all -> data_ : "cout" -> "\033[1;36mcout\033[0m" <
@replace_all -> data_ : "getline" -> "\033[1;36mgetline\033[0m" <
@replace_all -> data_ : "printf" -> "\033[1;36mprintf\033[0m" <
@replace_all -> data_ : "cin" -> "\033[1;36mcin\033[0m" <
@replace_all -> data_ : "newline" -> "\033[1;95mnewline\033[0m" <
} CPlusPlus;
func -> FlaScript() {
@replace_all -> data_ : "var" -> "\033[1;34mvar\033[0m" <
@replace_all -> data_ : "bool" -> "\033[1;94mbool\033[0m" <
@replace_all -> data_ : "(int)" -> "\033[1;94m(int)\033[0m" <
@replace_all -> data_ : "string" -> "\033[1;94mstring\033[0m" <
@replace_all -> data_ : "if " -> "\033[1;91mif\033[0m" <
@replace_all -> data_ : "else" -> "\033[1;91melse\033[0m" <
@replace_all -> data_ : "for" -> "\033[1;35mfor\033[0m" <
@replace_all -> data_: "do " -> "\033[1;35mdo\033[0m" <
@replace_all -> data_ : "while" -> "\033[1;35mwhile\033[0m" <
@replace_all -> data_ : "func" -> "\033[1;31mfunc\033[0m" <
@replace_all -> data_ : "main" -> "\033[1;91m main\033[0m" <
@replace_all -> data_ : "@append" -> "\033[1;96m@append\033[0m" <
@replace_all -> data_ : "@pop_back" -> "\033[1;96m@pop_back\033[0m" <
@replace_all -> data_ : "@between" -> "\033[1;96m@between\033[0m" <
@replace_all -> data_ : "@readfile" -> "\033[1;96m@readfile\033[0m" <
@replace_all -> data_ : "@replace_all" -> "\033[1;96m@replace_all\033[0m" <
@replace_all -> data_ : "import" -> "\033[1;33mimport\033[0m" <
@replace_all -> data_ : "defin" -> "\033[1;35mdefin\033[0m" <
@replace_all -> data_ : "return" -> "\033[1;95mreturn\033[0m" <
@replace_all -> data_ : "#ifdef" -> "\033[1;35m#ifdef\033[0m" <
@replace_all -> data_ : "#endif" -> "\033[1;35m#endif\033[0m" <
@replace_all -> data_ : "SystemInfo" -> "\033[1;95mSystemInfo\033[0m" <
@replace_all -> data_ : "Colorized" -> "\033[1;95mColorized\033[0m" <
@replace_all -> data_ : "newline" -> "\033[1;95mnewline\033[0m" <
@replace_all -> data_ : "print" -> "\033[1;36mprint\033[0m" <
@replace_all -> data_ : "fprintf" -> "\033[1;36mfprintf\033[0m" <
@replace_all -> data_ : "fprintln" -> "\033[1;36mfprintln\033[0m" <
} FlaScript;
func -> Python() {
@replace_all -> data_ : "str" -> "\033[1;34mstr\033[0m" <
@replace_all -> data_ : "bool" -> "\033[1;34mbool\033[0m" <
@replace_all -> data_ : "auto" -> "\033[1;34mauto\033[0m" <
@replace_all -> data_ : "float" -> "\033[1;34mfloat\033[0m" <
@replace_all -> data_ : "if " -> "\033[1;91mif\033[0m" <
@replace_all -> data_ : "else" -> "\033[1;91melse\033[0m" <
@replace_all -> data_ : "elif " -> "\033[1;91melif\033[0m" <
@replace_all -> data_ : "for" -> "\033[1;35mfor\033[0m" <
@replace_all -> data_ : "while" -> "\033[1;35mwhile\033[0m" <
@replace_all -> data_ : "def" -> "\033[1;31mdef\033[0m" <
@replace_all -> data_ : "lambda" -> "\033[1;91mlambda\033[0m" <
@replace_all -> data_ : "global" -> "\033[1;94mpublic\033[0m" <
@replace_all -> data_ : "import" -> "\033[1;33mimport\033[0m" <
@replace_all -> data_ : "from" -> "\033[1;93mfrom\033[0m" <
@replace_all -> data_ : "return" -> "\033[1;95mreturn\033[0m" <
@replace_all -> data_ : "print" -> "\033[1;36mprint\033[0m" <
} Python;
// Shell Script & Bash
func -> Shell_Script() {
@replace_all -> data_ : "gcc" -> "\033[1;96mgcc\033[0m" <
@replace_all -> data_ : "fla" -> "\033[1;96mfla\033[0m" <
@replace_all -> data_ : "clang" -> "\033[1;96mclang\033[0m" <
@replace_all -> data_ : "g++" -> "\033[1;96mg++\033[0m" <
@replace_all -> data_ : "c++" -> "\033[1;96mc++\033[0m" <
@replace_all -> data_ : "sudo" -> "\033[1;96msudo\033[0m" <
@replace_all -> data_ : "valgrind" -> "\033[1;96mvalgrind\033[0m" <
@replace_all -> data_ : "freebrain" -> "\033[1;96mfreebrain\033[0m" <
@replace_all -> data_ : "if " -> "\033[1;91mif\033[0m" <
@replace_all -> data_ : "fi " -> "\033[1;91mfi\033[0m" <
@replace_all -> data_ : "else" -> "\033[1;91melse\033[0m" <
@replace_all -> data_ : "elif" -> "\033[1;91melif\033[0m" <
@replace_all -> data_ : "do" -> "\033[1;91mdo\033[0m" <
@replace_all -> data_ : "then" -> "\033[1;92mthen\033[0m" <
@replace_all -> data_ : "case" -> "\033[1;92mcase\033[0m" <
@replace_all -> data_ : "done" -> "\033[1;92mdone\033[0m" <
@replace_all -> data_ : "for" -> "\033[1;35mfor\033[0m" <
@replace_all -> data_ : "while" -> "\033[1;35mwhile\033[0m" <
@replace_all -> data_ : "function" -> "\033[1;31mfunction\033[0m" <
@replace_all -> data_ : "return" -> "\033[1;95mreturn\033[0m" <
@replace_all -> data_ : "shopt" -> "\033[1;36mshopt\033[0m" <
@replace_all -> data_ : "set" -> "\033[1;36mset\033[0m" <
@replace_all -> data_ : "exit" -> "\033[1;36mexit\033[0m" <
@replace_all -> data_ : "cd" -> "\033[1;36mcd\033[0m" <
@replace_all -> data_ : "cat" -> "\033[1;36mcat\033[0m" <
@replace_all -> data_ : "printf" -> "\033[1;36mprintf\033[0m" <
} Shell_Script;