# HG changeset patch # User Aziz K?ksal # Date 1212840328 -7200 # Node ID d659f7aa055c77b6d1056b3ab327f09ecf3618af # Parent 51edcd435b3057b823af09b71637f904c634fbe0 Fixed Lexer unittest. diff -r 51edcd435b30 -r d659f7aa055c src/dil/lexer/Lexer.d --- a/src/dil/lexer/Lexer.d Thu Mar 27 16:56:55 2008 +0200 +++ b/src/dil/lexer/Lexer.d Sat Jun 07 14:05:28 2008 +0200 @@ -2851,20 +2851,17 @@ else src ~= pair.tokenText ~ " "; + // Lex the constructed source text. auto lx = new Lexer(new SourceText("", src)); - auto token = lx.getTokens(); + lx.scanAll(); + + auto token = lx.firstToken(); - uint i; - assert(token == lx.head); - assert(token.next.kind == TOK.Newline); - token = token.next.next; - do - { - assert(i < pairs.length); - assert(token.srcText == pairs[i].tokenText, Format("Scanned '{0}' but expected '{1}'", token.srcText, pairs[i].tokenText)); - ++i; - token = token.next; - } while (token.kind != TOK.EOF) + for (uint i; i < pairs.length && token.kind != TOK.EOF; + ++i, (token = token.next)) + if (token.srcText != pairs[i].tokenText) + assert(0, Format("Scanned '{0}' but expected '{1}'", + token.srcText, pairs[i].tokenText)); } /// Tests the Lexer's peek() method. diff -r 51edcd435b30 -r d659f7aa055c src/main.d --- a/src/main.d Thu Mar 27 16:56:55 2008 +0200 +++ b/src/main.d Sat Jun 07 14:05:28 2008 +0200 @@ -345,7 +345,7 @@ cc.addVersionId("D_Version2"); foreach (versionId; GlobalSettings.versionIds) if (Lexer.isValidUnreservedIdentifier(versionId)) - cc.versionIds[versionId] = true; + cc.addVersionId(versionId); return cc; } @@ -398,7 +398,7 @@ } } -/// Prints a help message for command. +/// Prints the help message of a command. void printHelp(char[] command) { char[] msg;