comparison lexer/Token.d @ 126:c3b24e7e8cf8

Carius changes to the parser. Parsing attributes, lexing many keywords(not all yet).
author Anders Johnsen <skabet@gmail.com>
date Tue, 27 May 2008 10:32:31 +0200
parents 6a5f745d351c
children 2be29b296081
comparison
equal deleted inserted replaced
125:d604152de1eb 126:c3b24e7e8cf8
62 /** 62 /**
63 Returns true for all the various assignments (=, +=, *= ...) 63 Returns true for all the various assignments (=, +=, *= ...)
64 */ 64 */
65 bool isAssignment() 65 bool isAssignment()
66 { 66 {
67 return type == Tok.Assign; 67 return type >= Tok.Assign && type <= Tok.PercentAssign;
68 }
69
70 /**
71 Returns true for all attributes( public, static, private...)
72 */
73 bool isAttribute()
74 {
75 return type >= Tok.Public && type <= Tok.Auto;
76 }
77
78 /**
79 just a shortcut to avoid `token.type == tok.Switch`.
80 */
81 bool isSwitch()
82 {
83 return type == Tok.Switch;
84 }
85
86 /**
87 just a shortcut to avoid `token.type == tok.While`.
88 */
89 bool isWhile()
90 {
91 return type == Tok.While;
92 }
93
94 /**
95 just a shortcut to avoid `token.type == tok.If`.
96 */
97 bool isIf()
98 {
99 return type == Tok.If;
100 }
101
102 /**
103 just a shortcut to avoid `token.type == tok.Return`.
104 */
105 bool isReturn()
106 {
107 return type == Tok.Return;
68 } 108 }
69 109
70 /** 110 /**
71 Just a shortcut to avoid `token.type == Tok.Identifier`. 111 Just a shortcut to avoid `token.type == Tok.Identifier`.
72 */ 112 */
88 EOF, 128 EOF,
89 129
90 /* Basic types */ 130 /* Basic types */
91 Identifier, 131 Identifier,
92 Integer, 132 Integer,
133 String,
93 134
94 /* Basic operators */ 135 /* Basic operators */
95 Assign, 136 Assign,
96 Plus, Minus, 137 PlusAssign,
97 Star, Slash, Percent, 138 MinusAssign,
139 StarAssign,
140 SlashAssign,
141 PercentAssign,
142 Plus,
143 Minus,
144 Star,
145 Slash,
146 Percent,
98 LeftShift, RightShift, UnsignedRightShift, 147 LeftShift, RightShift, UnsignedRightShift,
99 Comma, 148 Comma,
100 149
101 /* Symbols */ 150 /* Symbols */
102 OpenParentheses, 151 OpenParentheses,
128 177
129 Bool, 178 Bool,
130 179
131 Void, 180 Void,
132 181
133 Struct, 182 Struct, Function, Delegate, Class,
183 Interface, Union, Typedef, Typeid,
184 Typeof, Sizeof, Alias,
134 185
135 If, Else, 186 If, Else,
136 While, 187 While,
137 Switch, Case, Default, 188 Switch, Case, Default, Break,
138 Return, Cast, 189 Return, Cast,
139
140 String,
141 190
142 Module, Import, 191 Module, Import,
192
193 /* Attributes */
194 Public, Private, Package, Protected, Export,
195 Static,
196 Final,
197 Const,
198 Abstract,
199 Override,
200 Depracted,
201 Auto,
202
203 Align,
204
205 Asm,
206
207 In, Out, Body,
208
209 Assert, Throw, Try, Catch, Finally,
210
211
212
143 213
144 } 214 }
145 215
146 /** 216 /**
147 An associative array to supply a Tok to String function. 217 An associative array to supply a Tok to String function.
178 Tok.OpenBracket:"OpenBracket", 248 Tok.OpenBracket:"OpenBracket",
179 Tok.CloseBracket:"CloseBracket", 249 Tok.CloseBracket:"CloseBracket",
180 Tok.Dot:"Dot", 250 Tok.Dot:"Dot",
181 Tok.Assign:"Assign", 251 Tok.Assign:"Assign",
182 Tok.Plus:"Plus", 252 Tok.Plus:"Plus",
253 Tok.PlusAssign:"PlusAssign",
183 Tok.Minus:"Minus", 254 Tok.Minus:"Minus",
255 Tok.MinusAssign:"MinusAssign",
184 Tok.Star:"Star", 256 Tok.Star:"Star",
257 Tok.StarAssign:"StarAssign",
185 Tok.Slash:"Slash", 258 Tok.Slash:"Slash",
259 Tok.SlashAssign:"SlashAssign",
186 Tok.Percent:"Percent", 260 Tok.Percent:"Percent",
261 Tok.PercentAssign:"PercentAssign",
187 Tok.LeftShift:"LeftShift", 262 Tok.LeftShift:"LeftShift",
188 Tok.RightShift:"RightShift", 263 Tok.RightShift:"RightShift",
189 Tok.UnsignedRightShift:"UnsignedRightShift", 264 Tok.UnsignedRightShift:"UnsignedRightShift",
190 Tok.Integer:"Integer", 265 Tok.Integer:"Integer",
191 Tok.If:"If", 266 Tok.If:"If",
199 Tok.Colon:"Colon", 274 Tok.Colon:"Colon",
200 Tok.Seperator:"Seperator", 275 Tok.Seperator:"Seperator",
201 Tok.Cast:"Cast", 276 Tok.Cast:"Cast",
202 Tok.Module:"Module", 277 Tok.Module:"Module",
203 Tok.Import:"Import", 278 Tok.Import:"Import",
204 Tok.String:"String" 279 Tok.String:"String",
280 Tok.Public:"Public",
281 Tok.Private:"Private",
282 Tok.Protected:"Protected",
283 Tok.Package:"Package",
284 Tok.Export:"Export",
285 Tok.Static:"Static",
286 Tok.Final:"Finale",
287 Tok.Public:"Public",
288 Tok.Const:"Const",
289 Tok.Abstract:"Abstract",
290 Tok.Override:"Override",
291 Tok.Depracted:"Depracted",
292 Tok.Auto:"Auto"
205 ]; 293 ];
206 } 294 }