Mercurial > projects > dil
diff 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 |
line wrap: on
line diff
--- a/trunk/src/dil/Token.d Wed Dec 12 02:41:30 2007 +0100 +++ b/trunk/src/dil/Token.d Wed Dec 12 03:25:07 2007 +0100 @@ -130,6 +130,12 @@ return KeywordsBegin <= type && type <= KeywordsEnd; } + /// Returns true if this is an integral type token. + bool isIntegralType() + { + return IntegralTypeBegin <= type && type <= IntegralTypeEnd; + } + /// Returns true if this is a whitespace token. bool isWhitespace() { @@ -311,15 +317,11 @@ T.Auto, T.Scope, T.Alias, T.Typedef, T.Import, T.Enum, T.Class, T.Interface, T.Struct, T.Union, T.This, T.Tilde, T.Unittest, T.Debug, T.Version, T.Template, T.New, T.Delete, T.Mixin, T.Semicolon, - T.Identifier, T.Dot, T.Typeof, - T.Char, T.Wchar, T.Dchar, T.Bool, - T.Byte, T.Ubyte, T.Short, T.Ushort, - T.Int, T.Uint, T.Long, T.Ulong, - T.Float, T.Double, T.Real, - T.Ifloat, T.Idouble, T.Ireal, - T.Cfloat, T.Cdouble, T.Creal, T.Void: + T.Identifier, T.Dot, T.Typeof: return true; default: + if (IntegralTypeBegin <= tok && tok <= IntegralTypeEnd) + return true; } return false; } @@ -342,15 +344,10 @@ T.Function, T.Delegate, T.Assert, T.Import, T.Typeid, T.Is, T.LParen, T.Traits/*D2.0*/, T.AndBinary, T.PlusPlus, T.MinusMinus, T.Mul, T.Minus, T.Plus, T.Not, T.Tilde, T.New, T.Delete, T.Cast: - case T.Char, T.Wchar, T.Dchar, T.Bool, - T.Byte, T.Ubyte, T.Short, T.Ushort, - T.Int, T.Uint, T.Long, T.Ulong, - T.Float, T.Double, T.Real, - T.Ifloat, T.Idouble, T.Ireal, - T.Cfloat, T.Cdouble, T.Creal, T.Void: return true; default: - if (SpecialTokensBegin <= tok && tok <= SpecialTokensEnd) + if (IntegralTypeBegin <= tok && tok <= IntegralTypeEnd || + SpecialTokensBegin <= tok && tok <= SpecialTokensEnd) return true; } return false;