switched to GPLv3 ONLY, because i don't trust FSF anymore
[gaemu.git] / gaem / parser / tokens.d
blob602d08219f0cfe7a16fa1001a2ebdbe17e382774
1 /* GML parser
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module gaem.parser.tokens;
20 enum Keyword {
21 NoKW,
22 All,
23 And,
24 Break,
25 Case,
26 Continue,
27 Default,
28 Div,
29 Do,
30 Else,
31 Exit,
32 False,
33 For,
34 Function,
35 Global,
36 Globalvar,
37 If,
38 Mod,
39 Noone,
40 Not,
41 Or,
42 Other,
43 Pi,
44 Repeat,
45 Return,
46 Self,
47 Switch,
48 True,
49 Until,
50 Var,
51 While,
52 With,
53 Xor,
54 Add,
55 Sub,
56 Mul,
57 RDiv,
58 BitAnd,
59 BitOr,
60 BitXor,
61 BitNeg,
62 LogAnd,
63 LogOr,
64 LogXor,
65 LogNot,
66 Less,
67 Great,
68 LessEqu,
69 GreatEqu,
70 Equ,
71 NotEqu,
72 Ass,
73 AssAdd,
74 AssSub,
75 AssMul,
76 AssDiv,
77 AssBitAnd,
78 AssBitOr,
79 AssBitXor,
80 AssLShift,
81 AssRShift,
82 Semi,
83 Colon,
84 Comma,
85 Dot,
86 LCurly,
87 RCurly,
88 LParen,
89 RParen,
90 LBracket,
91 RBracket,
92 LShift,
93 RShift,
94 PlusPlus,
95 MinusMinus,
99 __gshared immutable Keyword[string] keywords;
100 __gshared immutable string[int] keywordstx;
103 shared static this () {
104 keywords = [
105 "all": Keyword.All,
106 "and": Keyword.And,
107 "break": Keyword.Break,
108 "case": Keyword.Case,
109 "continue": Keyword.Continue,
110 "default": Keyword.Default,
111 "div": Keyword.Div,
112 "do": Keyword.Do,
113 "else": Keyword.Else,
114 "exit": Keyword.Exit,
115 "false": Keyword.False,
116 "for": Keyword.For,
117 "function": Keyword.Function,
118 "global": Keyword.Global,
119 "globalvar": Keyword.Globalvar,
120 "if": Keyword.If,
121 "mod": Keyword.Mod,
122 "noone": Keyword.Noone,
123 "not": Keyword.Not,
124 "or": Keyword.Or,
125 "other": Keyword.Other,
126 "pi": Keyword.Pi,
127 "repeat": Keyword.Repeat,
128 "return": Keyword.Return,
129 "self": Keyword.Self,
130 "switch": Keyword.Switch,
131 "true": Keyword.True,
132 "until": Keyword.Until,
133 "var": Keyword.Var,
134 "while": Keyword.While,
135 "with": Keyword.With,
136 "xor": Keyword.Xor,
137 "+": Keyword.Add,
138 "-": Keyword.Sub,
139 "*": Keyword.Mul,
140 "/": Keyword.RDiv,
141 "&": Keyword.BitAnd,
142 "|": Keyword.BitOr,
143 "^": Keyword.BitXor,
144 "~": Keyword.BitNeg,
145 "&&": Keyword.LogAnd,
146 "||": Keyword.LogOr,
147 "^^": Keyword.LogXor,
148 "!": Keyword.LogNot,
149 "<": Keyword.Less,
150 ">": Keyword.Great,
151 "<=": Keyword.LessEqu,
152 ">=": Keyword.GreatEqu,
153 "==": Keyword.Equ,
154 "!=": Keyword.NotEqu,
155 "=": Keyword.Ass,
156 "+=": Keyword.AssAdd,
157 "-=": Keyword.AssSub,
158 "*=": Keyword.AssMul,
159 "/=": Keyword.AssDiv,
160 "&=": Keyword.AssBitAnd,
161 "|=": Keyword.AssBitOr,
162 "^=": Keyword.AssBitXor,
163 "<<=": Keyword.AssLShift,
164 ">>=": Keyword.AssRShift,
165 ";": Keyword.Semi,
166 ":": Keyword.Colon,
167 ",": Keyword.Comma,
168 ".": Keyword.Dot,
169 "{": Keyword.LCurly,
170 "}": Keyword.RCurly,
171 "(": Keyword.LParen,
172 ")": Keyword.RParen,
173 "[": Keyword.LBracket,
174 "]": Keyword.RBracket,
175 "<<": Keyword.LShift,
176 ">>": Keyword.RShift,
177 "++": Keyword.PlusPlus,
178 "--": Keyword.MinusMinus,
180 keywordstx = [
181 Keyword.All: "all",
182 Keyword.And: "and",
183 Keyword.Break: "break",
184 Keyword.Case: "case",
185 Keyword.Continue: "continue",
186 Keyword.Default: "default",
187 Keyword.Div: "div",
188 Keyword.Do: "do",
189 Keyword.Else: "else",
190 Keyword.Exit: "exit",
191 Keyword.False: "false",
192 Keyword.For: "for",
193 Keyword.Function: "function",
194 Keyword.Global: "global",
195 Keyword.Globalvar: "globalvar",
196 Keyword.If: "if",
197 Keyword.Mod: "mod",
198 Keyword.Noone: "noone",
199 Keyword.Not: "not",
200 Keyword.Or: "or",
201 Keyword.Other: "other",
202 Keyword.Pi: "pi",
203 Keyword.Repeat: "repeat",
204 Keyword.Return: "return",
205 Keyword.Self: "self",
206 Keyword.Switch: "switch",
207 Keyword.True: "true",
208 Keyword.Until: "until",
209 Keyword.Var: "var",
210 Keyword.While: "while",
211 Keyword.With: "with",
212 Keyword.Xor: "xor",
213 Keyword.Add: "+",
214 Keyword.Sub: "-",
215 Keyword.Mul: "*",
216 Keyword.RDiv: "/",
217 Keyword.BitAnd: "&",
218 Keyword.BitOr: "|",
219 Keyword.BitXor: "^",
220 Keyword.BitNeg: "~",
221 Keyword.LogAnd: "&&",
222 Keyword.LogOr: "||",
223 Keyword.LogXor: "^^",
224 Keyword.LogNot: "!",
225 Keyword.Less: "<",
226 Keyword.Great: ">",
227 Keyword.LessEqu: "<=",
228 Keyword.GreatEqu: ">=",
229 Keyword.Equ: "==",
230 Keyword.NotEqu: "!=",
231 Keyword.Ass: "=",
232 Keyword.AssAdd: "+=",
233 Keyword.AssSub: "-=",
234 Keyword.AssMul: "*=",
235 Keyword.AssDiv: "/=",
236 Keyword.AssBitAnd: "&=",
237 Keyword.AssBitOr: "|=",
238 Keyword.AssBitXor: "^=",
239 Keyword.AssLShift: "<<=",
240 Keyword.AssRShift: ">>=",
241 Keyword.Semi: ";",
242 Keyword.Colon: ":",
243 Keyword.Comma: ",",
244 Keyword.Dot: ".",
245 Keyword.LCurly: "{",
246 Keyword.RCurly: "}",
247 Keyword.LParen: "(",
248 Keyword.RParen: ")",
249 Keyword.LBracket: "[",
250 Keyword.RBracket: "]",
251 Keyword.LShift: "<<",
252 Keyword.RShift: ">>",
253 Keyword.PlusPlus: "++",
254 Keyword.MinusMinus: "--",
259 static string keywordtext (uint id) {
260 if (auto kw = id in keywordstx) return *kw;
261 return "<unknown>";