51 #include "events.h" |
51 #include "events.h" |
52 #include "commands.h" |
52 #include "commands.h" |
53 #include "stringtable.h" |
53 #include "stringtable.h" |
54 #include "variables.h" |
54 #include "variables.h" |
55 #include "array.h" |
55 #include "array.h" |
|
56 #include "databuffer.h" |
56 |
57 |
57 #include "bots.h" |
58 #include "bots.h" |
58 #include "botcommands.h" |
59 #include "botcommands.h" |
59 |
60 |
60 // List of keywords |
61 // List of keywords |
61 const char* g_Keywords[] = { |
62 const char* g_Keywords[] = { |
|
63 "bool", |
62 "break", |
64 "break", |
63 "case", |
65 "case", |
64 "continue", |
66 "continue", |
|
67 "const", |
65 "default", |
68 "default", |
66 "do", |
69 "do", |
67 "else", |
70 "else", |
68 "event", |
71 "event", |
|
72 "float", |
69 "for", |
73 "for", |
70 "goto", |
74 "goto", |
71 "if", |
75 "if", |
|
76 "int", |
72 "mainloop", |
77 "mainloop", |
73 "onenter", |
78 "onenter", |
74 "onexit", |
79 "onexit", |
75 "state", |
80 "state", |
76 "switch", |
81 "switch", |
77 "var" |
82 "str" |
|
83 "void", |
78 "while", |
84 "while", |
79 |
85 |
80 // These ones aren't implemented yet but I plan to do so, thus they are |
86 // These ones aren't implemented yet but I plan to do so, thus they are |
81 // reserved. Also serves as a to-do list of sorts for me. >:F |
87 // reserved. Also serves as a to-do list of sorts for me. >:F |
82 "enum", // Would enum actually be useful? I think so. |
88 "enum", // Would enum actually be useful? I think so. |
243 } |
249 } |
244 |
250 |
245 unsigned int NumKeywords () { |
251 unsigned int NumKeywords () { |
246 return sizeof (g_Keywords) / sizeof (const char*); |
252 return sizeof (g_Keywords) / sizeof (const char*); |
247 } |
253 } |
|
254 |
|
255 |
|
256 // ============================================================================ |
|
257 type_e GetTypeByName (str t) { |
|
258 t = t.tolower(); |
|
259 return (t == "int") ? TYPE_INT : |
|
260 (t == "float") ? TYPE_FLOAT : |
|
261 (t == "str") ? TYPE_STRING : |
|
262 (t == "void") ? TYPE_VOID : |
|
263 (t == "bool") ? TYPE_BOOL : |
|
264 TYPE_UNKNOWN; |
|
265 } |
|
266 |
|
267 |
|
268 // ============================================================================ |
|
269 // Inverse operation - type name by value |
|
270 str GetTypeName (type_e type) { |
|
271 switch (type) { |
|
272 case TYPE_INT: return "int"; break; |
|
273 case TYPE_STRING: return "str"; break; |
|
274 case TYPE_VOID: return "void"; break; |
|
275 case TYPE_FLOAT: return "float"; break; |
|
276 case TYPE_BOOL: return "bool"; break; |
|
277 case TYPE_UNKNOWN: return "???"; break; |
|
278 } |
|
279 |
|
280 return ""; |
|
281 } |