 |
Changeset 3991
- Timestamp:
- 10/08/08 12:07:45
(1 month ago)
- Author:
- Jim Panic
- Message:
Fixed some more bugs and finally added file & line information to error messages.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3990 |
r3991 |
|
| 63 | 63 | } |
|---|
| 64 | 64 | } |
|---|
| | 65 | |
|---|
| | 66 | return cast(TestMethod!(T))null; |
|---|
| 65 | 67 | } |
|---|
| 66 | 68 | } |
|---|
| r3985 |
r3991 |
|
| 107 | 107 | } |
|---|
| 108 | 108 | catch (Exception e) { |
|---|
| 109 | | Stdout.formatln("{}", e); |
|---|
| | 109 | Stdout.formatln("{}", (new UnexpectedCharacter(e.toString)).toString(fileName, linesCountForIndex(currentIndex))); |
|---|
| | 110 | throw new Exception("AbortingâŠ"); |
|---|
| 110 | 111 | } |
|---|
| 111 | 112 | } |
|---|
| r3985 |
r3991 |
|
| 34 | 34 | Indices consumeWord(T) (T[] source, uint startIndex) |
|---|
| 35 | 35 | in { assert(isValidIdentifierStart(source[startIndex]), |
|---|
| 36 | | "Unexpected character \"" ~ source[startIndex..startIndex + 1] ~ "\", expected a ValidIdentifierStart character."); } |
|---|
| | 36 | "Unexpected character '" ~ source[startIndex..startIndex + 1] ~ "'."); } |
|---|
| 37 | 37 | body |
|---|
| 38 | 38 | { |
|---|
| … | … | |
| 82 | 82 | |
|---|
| 83 | 83 | if (indices["endName"] == source.length) |
|---|
| 84 | | throw new UnexpectedCharacter("Unexpected end of file (consumeSecondClassAnnotation)"); |
|---|
| | 84 | Fiber.yieldAndThrow(new UnexpectedCharacter("Unexpected end of file (consumeSecondClassAnnotation)")); |
|---|
| 85 | 85 | |
|---|
| 86 | 86 | /* TODO: validate that there are no whitespace characters between name |
|---|
| … | … | |
| 91 | 91 | |
|---|
| 92 | 92 | if (indices["endArgument"] == source.length) |
|---|
| 93 | | throw new UnexpectedCharacter("Unexpected end of file (consumeSecondClassAnnotation)"); |
|---|
| | 93 | Fiber.yieldAndThrow(new UnexpectedCharacter("Unexpected end of file (consumeSecondClassAnnotation)")); |
|---|
| 94 | 94 | |
|---|
| 95 | 95 | indices["endAnnotation"] = indices["endArgument"] + 1; |
|---|
| … | … | |
| 305 | 305 | |
|---|
| 306 | 306 | if (source[endIndex] == '+' && source[endIndex + 1] == '/') break; |
|---|
| 307 | | if (source[endIndex] != '/') continue; |
|---|
| 308 | | else { |
|---|
| | 307 | if (source[endIndex] == '/') { |
|---|
| 309 | 308 | switch (source[endIndex + 1]) { |
|---|
| 310 | 309 | case '+': endIndex = consumeNestedComment(endIndex); continue; |
|---|
| … | … | |
| 312 | 311 | case '/': endIndex = consumeOneLineComment(endIndex); continue; |
|---|
| 313 | 312 | } |
|---|
| 314 | | } |
|---|
| | 313 | } else continue; |
|---|
| 315 | 314 | } |
|---|
| 316 | 315 | |
|---|
| … | … | |
| 392 | 391 | else throw(new UnexpectedCharacter("Unexpected character ')'")); |
|---|
| 393 | 392 | |
|---|
| 394 | | case '/': if ("+*/".contains(c)) indices["endDCodeBlock"] = consumeComments!(T)(source, indices["endDCodeBlock"])["endComment"]; continue; |
|---|
| | 393 | case '/': |
|---|
| | 394 | if ("+*/".contains(source[indices["endDCodeBlock"] + 1])) { |
|---|
| | 395 | indices["endDCodeBlock"] = consumeComments!(T)(source, indices["endDCodeBlock"])["endComment"]; |
|---|
| | 396 | } |
|---|
| | 397 | continue; |
|---|
| 395 | 398 | |
|---|
| 396 | 399 | case '\'': |
|---|
| r3985 |
r3991 |
|
| 45 | 45 | ***************************************************************************/ |
|---|
| 46 | 46 | |
|---|
| 47 | | class UnexpectedCharacter { |
|---|
| 48 | | char[] message; |
|---|
| 49 | | |
|---|
| 50 | | public this (char[] _message) { |
|---|
| 51 | | message = _message; |
|---|
| | 47 | class UnexpectedCharacter: Exception { |
|---|
| | 48 | public this (char[] msg) { |
|---|
| | 49 | super(msg); |
|---|
| 52 | 50 | } |
|---|
| 53 | 51 | |
|---|
| 54 | 52 | public char[] toString (char[] fileName, uint line) { |
|---|
| 55 | | return Format.convert("{}({}): {}", fileName, line, message); |
|---|
| | 53 | return Format.convert("{}({}): {}", fileName, line, msg); |
|---|
| 56 | 54 | } |
|---|
| 57 | 55 | } |
|---|
Download in other formats:
|
 |
 |
|
 |
Copyright © 2006-2008 Tango. All Rights Reserved. | Page Width:
Static or
Dynamic