Return a character count from the lexer's get_column method
This commit is contained in:
parent
fcff16cb86
commit
0e69da37a5
20 changed files with 143 additions and 233 deletions
|
|
@ -8,16 +8,13 @@
|
|||
|
||||
typedef struct {
|
||||
uint32_t bytes;
|
||||
uint32_t chars;
|
||||
TSPoint extent;
|
||||
} Length;
|
||||
|
||||
static inline bool length_has_unknown_chars(Length self) {
|
||||
return self.bytes > 0 && self.chars == 0;
|
||||
}
|
||||
static const Length LENGTH_UNDEFINED = {0, {0, 1}};
|
||||
|
||||
static inline void length_set_unknown_chars(Length *self) {
|
||||
self->chars = 0;
|
||||
static inline bool length_is_undefined(Length length) {
|
||||
return length.bytes == 0 && length.extent.column != 0;
|
||||
}
|
||||
|
||||
static inline Length length_min(Length len1, Length len2) {
|
||||
|
|
@ -28,13 +25,6 @@ static inline Length length_add(Length len1, Length len2) {
|
|||
Length result;
|
||||
result.bytes = len1.bytes + len2.bytes;
|
||||
result.extent = point_add(len1.extent, len2.extent);
|
||||
|
||||
if (length_has_unknown_chars(len1) || length_has_unknown_chars(len2)) {
|
||||
result.chars = 0;
|
||||
} else {
|
||||
result.chars = len1.chars + len2.chars;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -42,18 +32,11 @@ static inline Length length_sub(Length len1, Length len2) {
|
|||
Length result;
|
||||
result.bytes = len1.bytes - len2.bytes;
|
||||
result.extent = point_sub(len1.extent, len2.extent);
|
||||
|
||||
if (length_has_unknown_chars(len1) || length_has_unknown_chars(len2)) {
|
||||
result.chars = 0;
|
||||
} else {
|
||||
result.chars = len1.chars - len2.chars;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline Length length_zero() {
|
||||
Length result = {0, 0, {0, 0}};
|
||||
Length result = {0, {0, 0}};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue