# HG changeset patch # User aziz # Date 1182544864 0 # Node ID d4ba94a5a2824d09bf629f5e9b8ff4f9239c31b9 # Parent 07e45c06a0244fb62cb3683e43b563bdde1fad8e - Parsing /* */ comments now. diff -r 07e45c06a024 -r d4ba94a5a282 trunk/src/Lexer.d --- 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;