Mercurial > projects > dil
comparison trunk/src/dil/Lexer.d @ 520:f203c5248d0b
Added 'compile' command.
Fixes in config.d: changed 'auto' to 'var'; fixed format argument indices.
dil.Lexer and dil.Parser add their errors to infoMan.
Fix in enum TOK: Cent belongs to sublist of integral types.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 15 Dec 2007 22:25:18 +0100 |
parents | 9ebc799c7dc5 |
children | 50e64bab9c7a |
comparison
equal
deleted
inserted
replaced
519:9ebc799c7dc5 | 520:f203c5248d0b |
---|---|
33 char[] filePath; /// Path to the source text. | 33 char[] filePath; /// Path to the source text. |
34 char* p; /// Points to the current character in the source text. | 34 char* p; /// Points to the current character in the source text. |
35 char* end; /// Points one character past the end of the source text. | 35 char* end; /// Points one character past the end of the source text. |
36 | 36 |
37 // Members used for error messages: | 37 // Members used for error messages: |
38 InformationManager infoMan; | |
38 LexerError[] errors; | 39 LexerError[] errors; |
39 /// Always points to the beginning of the current line. | 40 /// Always points to the beginning of the current line. |
40 char* lineBegin; | 41 char* lineBegin; |
41 // Token* newline; /// Current newline token. | 42 // Token* newline; /// Current newline token. |
42 uint lineNum = 1; /// Current, actual source text line number. | 43 uint lineNum = 1; /// Current, actual source text line number. |
48 Construct a Lexer object. | 49 Construct a Lexer object. |
49 Params: | 50 Params: |
50 text = the UTF-8 source code. | 51 text = the UTF-8 source code. |
51 filePath = the path to the source code; used for error messages. | 52 filePath = the path to the source code; used for error messages. |
52 +/ | 53 +/ |
53 this(string text, string filePath) | 54 this(string text, string filePath, InformationManager infoMan = null) |
54 { | 55 { |
55 this.filePath = this.errorPath = filePath; | 56 this.filePath = this.errorPath = filePath; |
57 this.infoMan = infoMan; | |
56 | 58 |
57 this.text = text; | 59 this.text = text; |
58 if (text.length == 0 || text[$-1] != 0) | 60 if (text.length == 0 || text[$-1] != 0) |
59 { | 61 { |
60 this.text.length = this.text.length + 1; | 62 this.text.length = this.text.length + 1; |
2383 TypeInfo[] _arguments, void* _argptr) | 2385 TypeInfo[] _arguments, void* _argptr) |
2384 { | 2386 { |
2385 lineNum = this.errorLineNumber(lineNum); | 2387 lineNum = this.errorLineNumber(lineNum); |
2386 auto location = new Location(errorPath, lineNum, lineBegin, columnPos); | 2388 auto location = new Location(errorPath, lineNum, lineBegin, columnPos); |
2387 auto msg = Format(_arguments, _argptr, GetMsg(mid)); | 2389 auto msg = Format(_arguments, _argptr, GetMsg(mid)); |
2388 errors ~= new LexerError(location, msg); | 2390 auto error = new LexerError(location, msg); |
2391 errors ~= error; | |
2392 if (infoMan !is null) | |
2393 infoMan ~= error; | |
2389 } | 2394 } |
2390 | 2395 |
2391 Token* getTokens() | 2396 Token* getTokens() |
2392 { | 2397 { |
2393 while (nextToken() != TOK.EOF) | 2398 while (nextToken() != TOK.EOF) |