Mercurial > projects > dang
comparison basic/SourceManager.d @ 92:771ac63898e2 new_gen
A few better parser errors plus renaming most of the sema classes to match that they do now. Some have changes a lot.
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Mon, 05 May 2008 18:44:20 +0200 |
parents | 1a24e61eb104 |
children | 48bb2287c035 |
comparison
equal
deleted
inserted
replaced
91:1a24e61eb104 | 92:771ac63898e2 |
---|---|
92 ++ptr; | 92 ++ptr; |
93 return ptr_lo[1 .. ptr - ptr_lo]; | 93 return ptr_lo[1 .. ptr - ptr_lo]; |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 Extracts a string containing the entire line loc appears in. | 97 Gets the column of where the loc appears. |
98 **/ | 98 **/ |
99 int getOffsetToLine(SourceLocation loc) | 99 int getColumn(SourceLocation loc) |
100 { | 100 { |
101 // The line is extracted by getting two pointers to the exact location | 101 // Use same approach as getLine |
102 // and decreasing one until the nearest newline while the other ptr is | 102 |
103 // increased to the nearest newline. | |
104 CP* cp = &checkpoints[loc.fileID]; | 103 CP* cp = &checkpoints[loc.fileID]; |
105 char* ptr = cp.data.ptr + loc.fileOffset; | 104 char* ptr = cp.data.ptr + loc.fileOffset; |
106 char* ptr_lo = ptr; | 105 char* ptr_lo = ptr; |
107 while (cp.inRange(ptr_lo) && *ptr_lo != '\n' && *ptr_lo != '\r') | 106 while (cp.inRange(ptr_lo) && *ptr_lo != '\n' && *ptr_lo != '\r') |
108 --ptr_lo; | 107 --ptr_lo; |