Mercurial > projects > dil
changeset 8:d4ba94a5a282
- Parsing /* */ comments now.
author | aziz |
---|---|
date | Fri, 22 Jun 2007 20:41:04 +0000 |
parents | 07e45c06a024 |
children | 5d6968cc751e |
files | trunk/src/Lexer.d |
diffstat | 1 files changed, 37 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Lexer.d Fri Jun 22 20:25:02 2007 +0000 +++ b/trunk/src/Lexer.d Fri Jun 22 20:41:04 2007 +0000 @@ -108,31 +108,47 @@ return; } - if (c == '/' && p[1] == '+') + if (c == '/') { - uint level = 1; - ++p; - do + c = *++p; + if (c == '+') { - c = *++p; - if (c == 0) - throw new Error("unterminated /+/+ +/+/ comment."); - else if (c == '/' && p[1] == '+') + uint level = 1; + do { - ++p; - ++level; - } - else if (c == '+' && p[1] == '/') + c = *++p; + if (c == 0) + throw new Error("unterminated /+ +/ comment."); + else if (c == '/' && p[1] == '+') + { + ++p; + ++level; + } + else if (c == '+' && p[1] == '/') + { + ++p; + if (--level == 0) + break; + } + } while (1) + p += 2; + t.type = TOK.Comment; + t.end = p; + return; + } + else if (c == '*') + { + do { - ++p; - if (--level == 0) - break; - } - } while (1) - p += 2; - t.type = TOK.Comment; - t.end = p; - return; + c = *++p; + if (c == 0) + throw new Error("unterminated /* */ comment."); + } while (c != '*' || p[1] != '/') + p += 2; + t.type = TOK.Comment; + t.end = p; + return; + } } c = *++p;