Mercurial > projects > dil
changeset 344:757c86e2c3cc
- Added member tail and destructor method to Lexer.
author | aziz |
---|---|
date | Thu, 23 Aug 2007 15:26:04 +0000 |
parents | 95f1b6e43214 |
children | 10719a796554 |
files | trunk/src/dil/Lexer.d |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/dil/Lexer.d Thu Aug 23 14:10:04 2007 +0000 +++ b/trunk/src/dil/Lexer.d Thu Aug 23 15:26:04 2007 +0000 @@ -29,6 +29,7 @@ class Lexer { Token* head; /// The head of the doubly linked token list. + Token* tail; /// The tail of the linked list. Set in scan(). Token* token; /// Points to the current token in the token list. string text; char* p; /// Points to the current character in the source text. @@ -66,6 +67,18 @@ scanShebang(); } + ~this() + { + auto token = head.next; + do + { + assert(token.type == TOK.EOF ? token == tail && token.next is null : 1); + delete token.prev; + token = token.next; + } while (token !is null) + delete tail; + } + void scanShebang() { if (*p == '#' && p[1] == '!') @@ -173,6 +186,7 @@ assert(*p == 0 || *p == _Z_); t.type = TOK.EOF; t.end = p; + tail = &t; assert(t.start == t.end); return; } @@ -1593,7 +1607,7 @@ assert(t !is null); if (t.next) t = t.next; - else if (t.type != TOK.EOF) + else if (t != this.tail) { Token* new_t = new Token; scan(*new_t);