Mercurial > projects > dang
changeset 4:c09464468e1d
Updated lexer with comment handling to run Comments test at succes rate
author | johnsen@johnsen-desktop |
---|---|
date | Fri, 18 Apr 2008 11:07:46 +0200 |
parents | c893a4f0954d |
children | 2c5a8f4c254a |
files | lexer/Lexer.d |
diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lexer/Lexer.d Fri Apr 18 11:03:17 2008 +0200 +++ b/lexer/Lexer.d Fri Apr 18 11:07:46 2008 +0200 @@ -103,6 +103,7 @@ return Token(Tok.EOF, Location(position, this.source), 0); case '*': + position += 2; while(getNextChar != CharType.EOF) { ++position; @@ -113,12 +114,27 @@ return Token(Tok.EOF, Location(position, this.source), 0); case '+': + position += 2; + int nesting = 1; while(getNextChar != CharType.EOF) { ++position; if(source.data[position-2] == '+') if(source.data[position-1] == '/') - return this.next; + { + position++; + nesting--; + } + + if(source.data[position-2] == '/') + if(source.data[position-1] == '+') + { + nesting++; + position++; + } + + if(nesting == 0) + return this.next; } return Token(Tok.EOF, Location(position, this.source), 0);