Mercurial > projects > dil
changeset 7:07e45c06a024
- Parsing nested comments correctly now.
author | aziz |
---|---|
date | Fri, 22 Jun 2007 20:25:02 +0000 |
parents | 9980a2a34236 |
children | d4ba94a5a282 |
files | trunk/src/Lexer.d |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Lexer.d Fri Jun 22 19:41:02 2007 +0000 +++ b/trunk/src/Lexer.d Fri Jun 22 20:25:02 2007 +0000 @@ -110,13 +110,25 @@ if (c == '/' && p[1] == '+') { + uint level = 1; ++p; do { c = *++p; if (c == 0) - throw new Error("unterminated /+ +/ comment."); - } while (c != '+' || p[1] != '/') + 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;