# HG changeset patch # User Aziz K?ksal # Date 1204886816 -3600 # Node ID cb804053877249289e6bb7d902b57322a6ab9a89 # Parent f51305056196ee12af2daf4293d6bec7fad427de Reporting error for invalid octal escape sequences. diff -r f51305056196 -r cb8040538772 trunk/src/dil/Messages.d --- a/trunk/src/dil/Messages.d Wed Mar 05 15:45:54 2008 +0100 +++ b/trunk/src/dil/Messages.d Fri Mar 07 11:46:56 2008 +0100 @@ -113,6 +113,8 @@ // DDoc macros: auto UndefinedDDocMacro = "DDoc macro '{}' is undefined"; auto UnterminatedDDocMacro = "DDoc macro '{}' has no closing ')'"; + // Lexer messages: + auto InvalidOctalEscapeSequence = "value of octal escape sequence is greater than 0xFF: '{}'"; // Parser messages: auto InvalidUTF8SequenceInString = "invalid UTF-8 sequence in string literal: '{0}'"; auto ModuleDeclarationNotFirst = "a module declaration is only allowed as the first declaration in a file"; diff -r f51305056196 -r cb8040538772 trunk/src/dil/lexer/Lexer.d --- a/trunk/src/dil/lexer/Lexer.d Wed Mar 05 15:45:54 2008 +0100 +++ b/trunk/src/dil/lexer/Lexer.d Fri Mar 07 11:46:56 2008 +0100 @@ -1849,7 +1849,10 @@ c *= 8; c += *p - '0'; ++p; - return c & 0xFF; // Return valid escape value. + if (c > 0xFF) + error(sequenceStart, MSG.InvalidOctalEscapeSequence, + sequenceStart[0..p-sequenceStart]); + return c; // Return valid escape value. } else if(*p == '&') { @@ -2475,15 +2478,21 @@ } /// Forwards error parameters. + void error(char* columnPos, char[] msg, ...) + { + error_(this.lineNum, this.lineBegin, columnPos, msg, _arguments, _argptr); + } + + /// ditto void error(char* columnPos, MID mid, ...) { - error_(this.lineNum, this.lineBegin, columnPos, mid, _arguments, _argptr); + error_(this.lineNum, this.lineBegin, columnPos, GetMsg(mid), _arguments, _argptr); } /// ditto void error(uint lineNum, char* lineBegin, char* columnPos, MID mid, ...) { - error_(lineNum, lineBegin, columnPos, mid, _arguments, _argptr); + error_(lineNum, lineBegin, columnPos, GetMsg(mid), _arguments, _argptr); } /// Creates an error report and appends it to a list. @@ -2491,14 +2500,14 @@ /// lineNum = the line number. /// lineBegin = points to the first character of the current line. /// columnPos = points to the character where the error is located. - /// mid = the message ID. - void error_(uint lineNum, char* lineBegin, char* columnPos, MID mid, + /// msg = the message. + void error_(uint lineNum, char* lineBegin, char* columnPos, char[] msg, TypeInfo[] _arguments, Arg _argptr) { lineNum = this.errorLineNumber(lineNum); auto errorPath = this.filePaths.setPath; auto location = new Location(errorPath, lineNum, lineBegin, columnPos); - auto msg = Format(_arguments, _argptr, GetMsg(mid)); + msg = Format(_arguments, _argptr, msg); auto error = new LexerError(location, msg); errors ~= error; if (infoMan !is null) diff -r f51305056196 -r cb8040538772 trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Wed Mar 05 15:45:54 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Fri Mar 07 11:46:56 2008 +0100 @@ -3434,11 +3434,7 @@ if (consumed(T.Dot)) type = set(new ModuleScopeType(parseIdentifierType()), begin); else if (token.kind == T.Typeof) - { type = parseTypeofType(); - if (token.kind != T.Dot) - return type; - } else type = parseIdentifierType();