From 7633cbb836a42d7d8c77dc7a8373dfb6590a1313 Mon Sep 17 00:00:00 2001 From: joshvera Date: Mon, 30 Nov 2015 12:56:10 -0500 Subject: [PATCH] indentation --- include/tree_sitter/runtime.h | 4 ++-- src/runtime/length.h | 34 +++++++++++++++++----------------- src/runtime/lexer.c | 20 ++++++++++---------- src/runtime/tree.c | 32 ++++++++++++++++---------------- src/runtime/tree.h | 10 +++++----- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/include/tree_sitter/runtime.h b/include/tree_sitter/runtime.h index 0eb769bf..86678caf 100644 --- a/include/tree_sitter/runtime.h +++ b/include/tree_sitter/runtime.h @@ -36,8 +36,8 @@ typedef struct { } TSInputEdit; typedef struct { - size_t row; - size_t column; + size_t row; + size_t column; } TSPoint; typedef struct { diff --git a/src/runtime/length.h b/src/runtime/length.h index a3a574e6..5171b0b9 100644 --- a/src/runtime/length.h +++ b/src/runtime/length.h @@ -27,27 +27,27 @@ static inline TSLength ts_length_sub(TSLength len1, TSLength len2) { } static inline TSPoint ts_point_add(TSPoint point1, TSPoint point2) { - size_t row = point1.row + point2.row; + size_t row = point1.row + point2.row; - size_t column; - if (point2.row == 0) { - column = point1.column + point2.column; - } else { - column = point2.column; - } + size_t column; + if (point2.row == 0) { + column = point1.column + point2.column; + } else { + column = point2.column; + } return (TSPoint){ .row = row, .column = column }; } static inline TSPoint ts_point_sub(TSPoint point1, TSPoint point2) { - size_t row, column; - if (point1.row == point2.row) { - row = 0; - column = point1.column - point2.column; - } else { - row = point1.row - point2.row; - column = point1.column; - } + size_t row, column; + if (point1.row == point2.row) { + row = 0; + column = point1.column - point2.column; + } else { + row = point1.row - point2.row; + column = point1.column; + } return (TSPoint){ .row = row, .column = column }; } @@ -63,11 +63,11 @@ static inline bool ts_length_eq(TSLength len1, TSLength len2) { } static inline TSPoint ts_point_zero() { - return (TSPoint){ .row = 0, .column = 0 }; + return (TSPoint){ .row = 1, .column = 1 }; } static inline TSPoint ts_point_make(size_t row, size_t column) { - return (TSPoint){ .row = row, .column = column }; + return (TSPoint){ .row = row, .column = column }; } static inline TSLength ts_length_make(size_t bytes, size_t chars) { diff --git a/src/runtime/lexer.c b/src/runtime/lexer.c index 5a6fcf1d..f53120bc 100644 --- a/src/runtime/lexer.c +++ b/src/runtime/lexer.c @@ -69,12 +69,12 @@ static bool ts_lexer__advance(TSLexer *self, TSStateId state) { self->current_position.bytes += self->lookahead_size; self->current_position.chars += 1; - if (self->lookahead == '\n') { - self->current_point.row += 1; - self->current_point.column = 0; - } else { - self->current_point.column += 1; - } + if (self->lookahead == '\n') { + self->current_point.row += 1; + self->current_point.column = 1; + } else { + self->current_point.column += 1; + } } if (self->current_position.bytes >= self->chunk_start + self->chunk_size) @@ -94,17 +94,17 @@ static TSTree *ts_lexer__accept(TSLexer *self, TSSymbol symbol, TSPoint size_point = ts_point_sub(self->current_point, self ->token_start_point); TSPoint padding_point = ts_point_sub(self->token_start_point, self->token_end_point); - self->token_end_point = self->current_point; + self->token_end_point = self->current_point; if (symbol == ts_builtin_sym_error) { DEBUG("error_char"); return ts_tree_make_error(size, padding, size_point, - padding_point, self->lookahead); + padding_point, self->lookahead); } else { DEBUG("accept_token sym:%s", symbol_name); return ts_tree_make_leaf(symbol, padding, size, - padding_point, - size_point, node_type); + padding_point, + size_point, node_type); } } diff --git a/src/runtime/tree.c b/src/runtime/tree.c index 32547532..a6b57f4d 100644 --- a/src/runtime/tree.c +++ b/src/runtime/tree.c @@ -7,8 +7,8 @@ #include "runtime/length.h" TSTree *ts_tree_make_leaf(TSSymbol sym, TSLength padding, TSLength size, - TSPoint padding_point, - TSPoint size_point, + TSPoint padding_point, + TSPoint size_point, TSNodeType node_type) { TSTree *result = malloc(sizeof(TSTree)); *result = (TSTree){ @@ -20,8 +20,8 @@ TSTree *ts_tree_make_leaf(TSSymbol sym, TSLength padding, TSLength size, .named_child_count = 0, .children = NULL, .padding = padding, - .padding_point = padding_point, - .size_point = size_point, + .padding_point = padding_point, + .size_point = size_point, .options = {.type = node_type }, }; @@ -34,12 +34,12 @@ TSTree *ts_tree_make_leaf(TSSymbol sym, TSLength padding, TSLength size, } TSTree *ts_tree_make_error(TSLength size, TSLength padding, - TSPoint size_point, - TSPoint padding_point, - char lookahead_char) { + TSPoint size_point, + TSPoint padding_point, + char lookahead_char) { TSTree *result = ts_tree_make_leaf(ts_builtin_sym_error, padding, size, padding_point, - size_point, TSNodeTypeNamed); + size_point, TSNodeTypeNamed); result->lookahead_char = lookahead_char; return result; } @@ -55,7 +55,7 @@ static void ts_tree__set_children(TSTree *self, TSTree **children, child->context.parent = self; child->context.index = i; child->context.offset = ts_tree_total_size(self); - child->context.offset_point = ts_tree_offset_point(self); + child->context.offset_point = ts_tree_offset_point(self); if (i == 0) { self->padding = child->padding; @@ -117,21 +117,21 @@ void ts_tree_release(TSTree *self) { } size_t ts_tree_offset_column(const TSTree *self) { - const TSTree *parent = self; - size_t column = self->padding_point.column; + const TSTree *parent = self; + size_t column = self->padding_point.column; if (self->padding_point.row > 0) { return column; } - do { - parent = parent->context.parent; + do { + parent = parent->context.parent; if (!parent) break; - column += parent->context.offset_point.column; - } while (parent->context.offset_point.row == 0); + column += parent->context.offset_point.column; + } while (parent->context.offset_point.row == 0); - return column; + return column; } TSLength ts_tree_total_size(const TSTree *self) { diff --git a/src/runtime/tree.h b/src/runtime/tree.h index f373928b..9b3a31cc 100644 --- a/src/runtime/tree.h +++ b/src/runtime/tree.h @@ -25,8 +25,8 @@ struct TSTree { TSLength padding; TSLength size; - TSPoint padding_point; - TSPoint size_point; + TSPoint padding_point; + TSPoint size_point; TSSymbol symbol; @@ -41,11 +41,11 @@ struct TSTree { }; TSTree *ts_tree_make_leaf(TSSymbol, TSLength, TSLength, TSPoint, - TSPoint, TSNodeType); + TSPoint, TSNodeType); TSTree *ts_tree_make_node(TSSymbol, size_t, TSTree **, TSNodeType); TSTree *ts_tree_make_error(TSLength size, TSLength padding, - TSPoint padding_point, - TSPoint size_point, char lookahead_char); + TSPoint padding_point, + TSPoint size_point, char lookahead_char); void ts_tree_retain(TSTree *tree); void ts_tree_release(TSTree *tree); bool ts_tree_eq(const TSTree *tree1, const TSTree *tree2);