clang-format
This commit is contained in:
parent
1fa3bf0f07
commit
78c5fe8e02
6 changed files with 39 additions and 42 deletions
|
|
@ -43,8 +43,10 @@ static int advance(TSLexer *lexer) {
|
|||
}
|
||||
|
||||
static TSTree *accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
|
||||
TSLength size = ts_length_sub(lexer->current_position, lexer->token_start_position);
|
||||
TSLength padding = ts_length_sub(lexer->token_start_position, lexer->token_end_position);
|
||||
TSLength size =
|
||||
ts_length_sub(lexer->current_position, lexer->token_start_position);
|
||||
TSLength padding =
|
||||
ts_length_sub(lexer->token_start_position, lexer->token_end_position);
|
||||
lexer->token_end_position = lexer->current_position;
|
||||
return (symbol == ts_builtin_sym_error)
|
||||
? ts_tree_make_error(size, padding, ts_lexer_lookahead_char(lexer))
|
||||
|
|
@ -57,9 +59,8 @@ static TSTree *accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
|
|||
* this library.
|
||||
*/
|
||||
TSLexer ts_lexer_make() {
|
||||
TSLexer result = (TSLexer) { .debug = 0,
|
||||
.advance_fn = advance,
|
||||
.accept_fn = accept, };
|
||||
TSLexer result =
|
||||
(TSLexer) { .debug = 0, .advance_fn = advance, .accept_fn = accept, };
|
||||
ts_lexer_reset(&result);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -68,9 +69,9 @@ void ts_lexer_reset(TSLexer *lexer) {
|
|||
lexer->chunk = NULL;
|
||||
lexer->chunk_start = 0;
|
||||
lexer->chunk_size = 0;
|
||||
lexer->current_position = ts_length_zero(),
|
||||
lexer->token_start_position = ts_length_zero(),
|
||||
lexer->token_end_position = ts_length_zero(),
|
||||
lexer->current_position = ts_length_zero();
|
||||
lexer->token_start_position = ts_length_zero();
|
||||
lexer->token_end_position = ts_length_zero();
|
||||
lexer->lookahead = 0;
|
||||
lexer->lookahead_size = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,9 +153,8 @@ static int handle_error(TSParser *parser) {
|
|||
ts_stack_shrink(&parser->stack, entry - parser->stack.entries + 1);
|
||||
parser->lookahead->padding = ts_length_zero();
|
||||
error->size = ts_length_sub(
|
||||
ts_length_sub(
|
||||
parser->lexer.token_start_position,
|
||||
ts_stack_right_position(&parser->stack)),
|
||||
ts_length_sub(parser->lexer.token_start_position,
|
||||
ts_stack_right_position(&parser->stack)),
|
||||
error->padding);
|
||||
ts_stack_push(&parser->stack, state_after_error, error);
|
||||
ts_tree_release(error);
|
||||
|
|
@ -189,7 +188,8 @@ static int handle_error(TSParser *parser) {
|
|||
|
||||
static TSTree *get_root(TSParser *parser) {
|
||||
if (parser->stack.size == 0)
|
||||
ts_stack_push(&parser->stack, 0, ts_tree_make_error(ts_length_zero(), ts_length_zero(), 0));
|
||||
ts_stack_push(&parser->stack, 0,
|
||||
ts_tree_make_error(ts_length_zero(), ts_length_zero(), 0));
|
||||
|
||||
reduce(parser, ts_builtin_sym_document, parser->stack.size);
|
||||
parser->lookahead->options = 0;
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ TSLength ts_stack_right_position(const TSStack *stack);
|
|||
|
||||
#define TS_STACK_FROM_TOP(stack, entry) \
|
||||
for (TSStackEntry *entry = stack.entries + stack.size - 1; \
|
||||
entry >= stack.entries; \
|
||||
entry--)
|
||||
entry >= stack.entries; entry--)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ TSTree *ts_tree_make_node(TSSymbol symbol, size_t child_count,
|
|||
TSTreeChild *grandchildren = ts_tree_visible_children(child, &n);
|
||||
for (size_t j = 0; j < n; j++) {
|
||||
visible_children[vis_i].tree = grandchildren[j].tree;
|
||||
visible_children[vis_i].offset = ts_length_add(offset, grandchildren[j].offset);
|
||||
visible_children[vis_i].offset =
|
||||
ts_length_add(offset, grandchildren[j].offset);
|
||||
vis_i++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue