clang format
This commit is contained in:
parent
0d6d09cbd9
commit
412cc93812
4 changed files with 50 additions and 49 deletions
|
|
@ -27,7 +27,8 @@ void ts_document_free(TSDocument *document) {
|
|||
free(document);
|
||||
}
|
||||
|
||||
void ts_document_set_language(TSDocument *document, const TSLanguage *language) {
|
||||
void ts_document_set_language(TSDocument *document,
|
||||
const TSLanguage *language) {
|
||||
ts_parser_destroy(&document->parser);
|
||||
document->parser = ts_parser_make(language);
|
||||
}
|
||||
|
|
@ -37,7 +38,8 @@ const TSTree *ts_document_tree(const TSDocument *document) {
|
|||
}
|
||||
|
||||
const char *ts_document_string(const TSDocument *document) {
|
||||
return ts_tree_string(document->tree, document->parser.language->symbol_names);
|
||||
return ts_tree_string(document->tree,
|
||||
document->parser.language->symbol_names);
|
||||
}
|
||||
|
||||
void ts_document_set_input(TSDocument *document, TSInput input) {
|
||||
|
|
@ -94,7 +96,8 @@ void ts_document_set_input_string(TSDocument *document, const char *text) {
|
|||
}
|
||||
|
||||
TSNode *ts_document_root_node(const TSDocument *document) {
|
||||
return ts_node_make_root(document->tree, document->parser.language->symbol_names);
|
||||
return ts_node_make_root(document->tree,
|
||||
document->parser.language->symbol_names);
|
||||
}
|
||||
|
||||
TSNode *ts_document_get_node(const TSDocument *document, size_t pos) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ static int advance(TSLexer *lexer) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
static TSTree * accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
|
||||
static TSTree *accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
|
||||
size_t current_position = ts_lexer_position(lexer);
|
||||
size_t size = current_position - lexer->token_start_position;
|
||||
size_t offset = lexer->token_start_position - lexer->token_end_position;
|
||||
|
|
@ -38,6 +38,5 @@ TSLexer ts_lexer_make() {
|
|||
.token_end_position = 0,
|
||||
.reached_end = 0,
|
||||
.advance_fn = advance,
|
||||
.accept_fn = accept,
|
||||
};
|
||||
.accept_fn = accept, };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ static size_t breakdown_stack(TSParser *parser, TSInputEdit *edit) {
|
|||
for (size_t i = 0; i < child_count && position < edit->position; i++) {
|
||||
TSTree *child = children[i];
|
||||
TSStateId state = ts_stack_top_state(stack);
|
||||
TSStateId next_state =
|
||||
actions_for_state(parser->language, state)[child->symbol].data.to_state;
|
||||
TSStateId next_state = actions_for_state(
|
||||
parser->language, state)[child->symbol].data.to_state;
|
||||
ts_stack_push(stack, next_state, child);
|
||||
ts_tree_retain(child);
|
||||
position += ts_tree_total_size(child);
|
||||
|
|
@ -141,7 +141,8 @@ int ts_parser_handle_error(TSParser *parser) {
|
|||
for (;;) {
|
||||
ts_tree_release(parser->lookahead);
|
||||
size_t position = ts_lexer_position(&parser->lexer);
|
||||
parser->lookahead = parser->language->lex_fn(&parser->lexer, ts_lex_state_error);
|
||||
parser->lookahead =
|
||||
parser->language->lex_fn(&parser->lexer, ts_lex_state_error);
|
||||
|
||||
int at_end = 0;
|
||||
if (ts_lexer_position(&parser->lexer) == position)
|
||||
|
|
@ -159,8 +160,8 @@ int ts_parser_handle_error(TSParser *parser) {
|
|||
for (size_t j = 0; j < parser->stack.size; j++) {
|
||||
size_t i = parser->stack.size - 1 - j;
|
||||
TSStateId stack_state = parser->stack.entries[i].state;
|
||||
TSParseAction action_on_error =
|
||||
actions_for_state(parser->language, stack_state)[ts_builtin_sym_error];
|
||||
TSParseAction action_on_error = actions_for_state(
|
||||
parser->language, stack_state)[ts_builtin_sym_error];
|
||||
if (action_on_error.type == TSParseActionTypeShift) {
|
||||
TSStateId state_after_error = action_on_error.data.to_state;
|
||||
if (actions_for_state(parser->language,
|
||||
|
|
@ -194,8 +195,8 @@ TSTree *ts_parser_tree_root(TSParser *parser) {
|
|||
TSParseAction ts_parser_next_action(TSParser *parser) {
|
||||
TSStateId state = ts_stack_top_state(&parser->stack);
|
||||
if (!parser->lookahead)
|
||||
parser->lookahead =
|
||||
parser->language->lex_fn(&parser->lexer, parser->language->lex_states[state]);
|
||||
parser->lookahead = parser->language->lex_fn(
|
||||
&parser->lexer, parser->language->lex_states[state]);
|
||||
return actions_for_state(parser->language, state)[parser->lookahead->symbol];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue