Mercurial > projects > dang
diff basic/Message.d @ 106:89db676fbacb
Now able of understanding strings.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 22 May 2008 12:09:11 +0200 |
parents | 5f258eaf9517 |
children | 6c5a3c0bb4fb |
line wrap: on
line diff
--- a/basic/Message.d Wed May 21 21:11:55 2008 +0200 +++ b/basic/Message.d Thu May 22 12:09:11 2008 +0200 @@ -42,6 +42,13 @@ return m; } + Message report(uint opcode, SLoc location1, SLoc location2) + { + Message m = new Message(opcode, location1, location2, src_mgr, this); + messages ~= m; + return m; + } + void checkErrors(ExitLevel exitlevel = ExitLevel.Normal) { if(messages.length == 0) @@ -90,14 +97,32 @@ this.msg_handler = msg_handler; } + this(int opcode, SLoc location, SLoc end, SourceManager src_mgr, MessageHandler msg_handler) + { + this.src_mgr = src_mgr; + this.location = location; + this.end = end; + args ~= Messages[opcode].message; + this.type = Messages[opcode].type; + this.msg_handler = msg_handler; + haveEnd = true; + } + char[] toString() { char[256] tmp = void; char[] msg = layout(tmp, args); - Lexer l = new Lexer(location, src_mgr, new MessageHandler(src_mgr)); + int len = 0; + if(!haveEnd) + { + Lexer l = new Lexer(location, src_mgr, new MessageHandler(src_mgr)); - Token t = l.next; + Token t = l.next; + len = t.length; + } + else + len = end - location; if (src_mgr.getRawData(location).length > 0) msg = src_mgr.getLocationAsString(location) ~ ": " ~ msg; @@ -109,7 +134,7 @@ char[] marks = line.dup; marks[] = ' '; size_t p = src_mgr.getColumn(location); - marks[p .. p + t.length] = '^'; + marks[p .. p + len] = '^'; msg ~= "\n "; msg ~= line; @@ -166,7 +191,9 @@ MessageType type; private: char[][] args; - SLoc location; + SLoc location, end; + bool haveEnd; SourceManager src_mgr; MessageHandler msg_handler; + Token t; }