Use stdbool.h
This commit is contained in:
parent
808b003f1a
commit
e5ea4efb0b
7 changed files with 25 additions and 22 deletions
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
static const char *empty_chunk = "";
|
||||
|
||||
static int advance(TSLexer *lexer) {
|
||||
static bool advance(TSLexer *lexer) {
|
||||
|
||||
/*
|
||||
* Return false if the Lexer has already reached the end of the input.
|
||||
*/
|
||||
if (lexer->chunk == empty_chunk)
|
||||
return 0;
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Increment the Lexer's position.
|
||||
|
|
@ -41,7 +41,7 @@ static int advance(TSLexer *lexer) {
|
|||
(const uint8_t *)lexer->chunk + position_in_chunk,
|
||||
lexer->chunk_size - position_in_chunk + 1, &lexer->lookahead);
|
||||
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static TSTree *accept(TSLexer *lexer, TSSymbol symbol, int is_hidden) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#include <stdbool.h>
|
||||
#include "runtime/node.h"
|
||||
#include "runtime/length.h"
|
||||
#include "runtime/tree.h"
|
||||
|
|
@ -35,8 +36,8 @@ TSLength ts_node_pos(const TSNode *node) { return node->position; }
|
|||
|
||||
TSLength ts_node_size(const TSNode *node) { return node->content->size; }
|
||||
|
||||
int ts_node_eq(const TSNode *left, const TSNode *right) {
|
||||
return ts_tree_equals(left->content, right->content);
|
||||
bool ts_node_eq(const TSNode *left, const TSNode *right) {
|
||||
return ts_tree_eq(left->content, right->content);
|
||||
}
|
||||
|
||||
const char *ts_node_name(const TSNode *node) {
|
||||
|
|
|
|||
|
|
@ -127,19 +127,19 @@ TSLength ts_tree_total_size(const TSTree *tree) {
|
|||
return ts_length_add(tree->padding, tree->size);
|
||||
}
|
||||
|
||||
int ts_tree_equals(const TSTree *node1, const TSTree *node2) {
|
||||
bool ts_tree_eq(const TSTree *node1, const TSTree *node2) {
|
||||
if (node1->symbol != node2->symbol)
|
||||
return 0;
|
||||
return false;
|
||||
if (node1->lookahead_char != node2->lookahead_char)
|
||||
return 0;
|
||||
return false;
|
||||
if (node1->child_count != node2->child_count)
|
||||
return 0;
|
||||
return false;
|
||||
if (node1->visible_child_count != node2->visible_child_count)
|
||||
return 0;
|
||||
return false;
|
||||
for (size_t i = 0; i < node1->child_count; i++)
|
||||
if (!ts_tree_equals(node1->children[i], node2->children[i]))
|
||||
return 0;
|
||||
return 1;
|
||||
if (!ts_tree_eq(node1->children[i], node2->children[i]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
TSTree **ts_tree_children(const TSTree *tree, size_t *count) {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ TSTree *ts_tree_make_node(TSSymbol, size_t, TSTree **, bool);
|
|||
TSTree *ts_tree_make_error(TSLength size, TSLength padding, char lookahead_char);
|
||||
void ts_tree_retain(TSTree *tree);
|
||||
void ts_tree_release(TSTree *tree);
|
||||
int ts_tree_equals(const TSTree *tree1, const TSTree *tree2);
|
||||
bool ts_tree_eq(const TSTree *tree1, const TSTree *tree2);
|
||||
char *ts_tree_string(const TSTree *tree, const char **names);
|
||||
char *ts_tree_error_string(const TSTree *tree, const char **names);
|
||||
TSTree **ts_tree_children(const TSTree *tree, size_t *count);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue