replace start and end with padding and size
This commit is contained in:
parent
a85b7fe3c4
commit
b0f6bac3ab
12 changed files with 119 additions and 65 deletions
|
|
@ -26,6 +26,32 @@ static inline TSLength ts_length_sub(TSLength len1, TSLength len2) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static inline TSPoint ts_point_add(TSPoint point1, TSPoint point2) {
|
||||
size_t line = point1.line + point2.line;
|
||||
|
||||
size_t column;
|
||||
if (point2.line == 0) {
|
||||
column = point1.column + point2.column;
|
||||
} else {
|
||||
column = point2.column;
|
||||
}
|
||||
|
||||
return (TSPoint){ .line = line, .column = column };
|
||||
}
|
||||
|
||||
static inline TSPoint ts_point_sub(TSPoint point1, TSPoint point2) {
|
||||
size_t line, column;
|
||||
if (point1.line == point2.line) {
|
||||
line = 0;
|
||||
column = point1.column - point2.column;
|
||||
} else {
|
||||
line = point1.line - point2.line;
|
||||
column = point1.column;
|
||||
}
|
||||
|
||||
return (TSPoint){ .line = line, .column = column };
|
||||
}
|
||||
|
||||
static inline TSLength ts_length_zero() {
|
||||
TSLength result;
|
||||
result.bytes = result.chars = 0;
|
||||
|
|
@ -36,12 +62,12 @@ static inline bool ts_length_eq(TSLength len1, TSLength len2) {
|
|||
return len1.bytes == len2.bytes && len1.chars == len2.chars;
|
||||
}
|
||||
|
||||
static inline TSSourceInfo ts_source_info_zero() {
|
||||
return (TSSourceInfo){ .line = 1, .column = 1 };
|
||||
static inline TSPoint ts_point_zero() {
|
||||
return (TSPoint){ .line = 1, .column = 1 };
|
||||
}
|
||||
|
||||
static inline TSSourceInfo ts_source_info_make(size_t line, size_t column) {
|
||||
return (TSSourceInfo){ .line = line, .column = column };
|
||||
static inline TSPoint ts_point_make(size_t line, size_t column) {
|
||||
return (TSPoint){ .line = line, .column = column };
|
||||
}
|
||||
|
||||
static inline TSLength ts_length_make(size_t bytes, size_t chars) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue