Mercurial > projects > dil
comparison trunk/src/dil/Location.d @ 798:c24be8d4f6ab
Added documentation comments.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sat, 01 Mar 2008 02:53:06 +0100 |
parents | 7173ece1b696 |
children |
comparison
equal
deleted
inserted
replaced
797:cf2ad5df025c | 798:c24be8d4f6ab |
---|---|
1 /++ | 1 /++ |
2 Author: Aziz Köksal | 2 Author: Aziz Köksal |
3 License: GPL3 | 3 License: GPL3 |
4 +/ | 4 +/ |
5 module dil.Location; | 5 module dil.Location; |
6 | |
6 import dil.lexer.Funcs; | 7 import dil.lexer.Funcs; |
7 import dil.Unicode; | 8 import dil.Unicode; |
8 import common; | |
9 | 9 |
10 /// Represents a location in a source text. | |
10 final class Location | 11 final class Location |
11 { | 12 { |
12 char[] filePath; | 13 char[] filePath; /// The file path. |
13 size_t lineNum; | 14 size_t lineNum; /// The line number. |
14 char* lineBegin, to; /// Used to calculate column. | 15 char* lineBegin, to; /// Used to calculate the column. |
15 | 16 |
17 /// Forwards the parameters to the second constructor. | |
16 this(char[] filePath, size_t lineNum) | 18 this(char[] filePath, size_t lineNum) |
17 { | 19 { |
18 set(filePath, lineNum); | 20 set(filePath, lineNum); |
19 } | 21 } |
20 | 22 |
23 /// Constructs a Location object. | |
21 this(char[] filePath, size_t lineNum, char* lineBegin, char* to) | 24 this(char[] filePath, size_t lineNum, char* lineBegin, char* to) |
22 { | 25 { |
23 set(filePath, lineNum, lineBegin, to); | 26 set(filePath, lineNum, lineBegin, to); |
24 } | |
25 | |
26 Location clone() | |
27 { | |
28 return new Location(filePath, lineNum, lineBegin, to); | |
29 } | 27 } |
30 | 28 |
31 void set(char[] filePath, size_t lineNum) | 29 void set(char[] filePath, size_t lineNum) |
32 { | 30 { |
33 set(filePath, lineNum, null, null); | 31 set(filePath, lineNum, null, null); |
50 void setFilePath(char[] filePath) | 48 void setFilePath(char[] filePath) |
51 { | 49 { |
52 this.filePath = filePath; | 50 this.filePath = filePath; |
53 } | 51 } |
54 | 52 |
55 /++ | 53 /// This is a primitive method to count the number of characters in a string. |
56 This is a primitive method to count the number of characters in a string. | 54 /// Note: Unicode compound characters and other special characters are not |
57 Unicode compound characters and other special characters are not | 55 /// taken into account. The tabulator character is counted as one. |
58 taken into account. | |
59 +/ | |
60 uint calculateColumn() | 56 uint calculateColumn() |
61 { | 57 { |
62 uint col; | 58 uint col; |
63 auto p = lineBegin; | 59 auto p = lineBegin; |
64 if (!p) | 60 if (!p) |