comparison trunk/src/dil/Token.d @ 508:943ecc9c133a

Added isIntegralType() to Token and refactored code.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Wed, 12 Dec 2007 03:25:07 +0100
parents 996041463028
children 3bc7801c207e
comparison
equal deleted inserted replaced
507:996041463028 508:943ecc9c133a
126 126
127 /// Returns true if this is a keyword token. 127 /// Returns true if this is a keyword token.
128 bool isKeyword() 128 bool isKeyword()
129 { 129 {
130 return KeywordsBegin <= type && type <= KeywordsEnd; 130 return KeywordsBegin <= type && type <= KeywordsEnd;
131 }
132
133 /// Returns true if this is an integral type token.
134 bool isIntegralType()
135 {
136 return IntegralTypeBegin <= type && type <= IntegralTypeEnd;
131 } 137 }
132 138
133 /// Returns true if this is a whitespace token. 139 /// Returns true if this is a whitespace token.
134 bool isWhitespace() 140 bool isWhitespace()
135 { 141 {
309 T.Public, T.Extern, T.Deprecated, T.Override, T.Abstract, 315 T.Public, T.Extern, T.Deprecated, T.Override, T.Abstract,
310 T.Synchronized, T.Static, T.Final, T.Const, T.Invariant/*D 2.0*/, 316 T.Synchronized, T.Static, T.Final, T.Const, T.Invariant/*D 2.0*/,
311 T.Auto, T.Scope, T.Alias, T.Typedef, T.Import, T.Enum, T.Class, 317 T.Auto, T.Scope, T.Alias, T.Typedef, T.Import, T.Enum, T.Class,
312 T.Interface, T.Struct, T.Union, T.This, T.Tilde, T.Unittest, T.Debug, 318 T.Interface, T.Struct, T.Union, T.This, T.Tilde, T.Unittest, T.Debug,
313 T.Version, T.Template, T.New, T.Delete, T.Mixin, T.Semicolon, 319 T.Version, T.Template, T.New, T.Delete, T.Mixin, T.Semicolon,
314 T.Identifier, T.Dot, T.Typeof, 320 T.Identifier, T.Dot, T.Typeof:
315 T.Char, T.Wchar, T.Dchar, T.Bool,
316 T.Byte, T.Ubyte, T.Short, T.Ushort,
317 T.Int, T.Uint, T.Long, T.Ulong,
318 T.Float, T.Double, T.Real,
319 T.Ifloat, T.Idouble, T.Ireal,
320 T.Cfloat, T.Cdouble, T.Creal, T.Void:
321 return true; 321 return true;
322 default: 322 default:
323 if (IntegralTypeBegin <= tok && tok <= IntegralTypeEnd)
324 return true;
323 } 325 }
324 return false; 326 return false;
325 } 327 }
326 328
327 /// Returns true if this token starts a Statement. 329 /// Returns true if this token starts a Statement.
340 T.Uint64, T.Float32, T.Float64, T.Float80, T.Imaginary32, 342 T.Uint64, T.Float32, T.Float64, T.Float80, T.Imaginary32,
341 T.Imaginary64, T.Imaginary80, T.CharLiteral, T.String, T.LBracket, 343 T.Imaginary64, T.Imaginary80, T.CharLiteral, T.String, T.LBracket,
342 T.Function, T.Delegate, T.Assert, T.Import, T.Typeid, T.Is, T.LParen, 344 T.Function, T.Delegate, T.Assert, T.Import, T.Typeid, T.Is, T.LParen,
343 T.Traits/*D2.0*/, T.AndBinary, T.PlusPlus, T.MinusMinus, T.Mul, 345 T.Traits/*D2.0*/, T.AndBinary, T.PlusPlus, T.MinusMinus, T.Mul,
344 T.Minus, T.Plus, T.Not, T.Tilde, T.New, T.Delete, T.Cast: 346 T.Minus, T.Plus, T.Not, T.Tilde, T.New, T.Delete, T.Cast:
345 case T.Char, T.Wchar, T.Dchar, T.Bool,
346 T.Byte, T.Ubyte, T.Short, T.Ushort,
347 T.Int, T.Uint, T.Long, T.Ulong,
348 T.Float, T.Double, T.Real,
349 T.Ifloat, T.Idouble, T.Ireal,
350 T.Cfloat, T.Cdouble, T.Creal, T.Void:
351 return true; 347 return true;
352 default: 348 default:
353 if (SpecialTokensBegin <= tok && tok <= SpecialTokensEnd) 349 if (IntegralTypeBegin <= tok && tok <= IntegralTypeEnd ||
350 SpecialTokensBegin <= tok && tok <= SpecialTokensEnd)
354 return true; 351 return true;
355 } 352 }
356 return false; 353 return false;
357 } 354 }
358 355