Mercurial > projects > dil
diff trunk/src/dil/Token.d @ 552:3bc7801c207e
Refactored the way how tokens are flagged as whitespace.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Thu, 20 Dec 2007 23:26:43 +0100 |
parents | 943ecc9c133a |
children | 9e811db780a6 |
line wrap: on
line diff
--- a/trunk/src/dil/Token.d Thu Dec 20 20:00:48 2007 +0100 +++ b/trunk/src/dil/Token.d Thu Dec 20 23:26:43 2007 +0100 @@ -16,7 +16,14 @@ +/ struct Token { + enum Flags : ushort + { + None, + Whitespace = 1, /// Tokens with this flag are ignored by the Parser. + } + TOK type; /// The type of the token. + Flags flags; /// The flags of the token. /// Pointers to the next and previous tokens (doubly-linked list.) Token* next, prev; @@ -113,6 +120,12 @@ return tokToString[tok]; } + /// Adds Flags.Whitespace to this token's flags. + void setWhitespaceFlag() + { + this.flags |= Flags.Whitespace; + } + /++ Returns true if this is a token that can have newlines in it. These can be block and nested comments and any string literal @@ -139,7 +152,7 @@ /// Returns true if this is a whitespace token. bool isWhitespace() { - return !!(type & TOK.Whitespace); + return !!(flags & Flags.Whitespace); } /// Returns true if this is a special token.