From 387a6fde38cc833fa10d299bc70be76c2126d8e3 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Tue, 20 Jun 2023 19:03:58 -0400 Subject: [PATCH] chore: apply clang-tidy fixes --- src/scanner.c | 60 ++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/src/scanner.c b/src/scanner.c index 277daa4..a98d349 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -2,16 +2,20 @@ #include enum TokenType { - VERBATIM_STRING, + VERBATIM_STRING, }; void *tree_sitter_squirrel_external_scanner_create() { return NULL; } + void tree_sitter_squirrel_external_scanner_destroy(void *payload) {} + void tree_sitter_squirrel_external_scanner_reset(void *payload) {} + unsigned tree_sitter_squirrel_external_scanner_serialize(void *payload, char *buffer) { - return 0; + return 0; } + void tree_sitter_squirrel_external_scanner_deserialize(void *payload, const char *buffer, unsigned length) {} @@ -20,35 +24,37 @@ static void advance(TSLexer *lexer) { lexer->advance(lexer, false); } bool tree_sitter_squirrel_external_scanner_scan(void *payload, TSLexer *lexer, const bool *valid_symbols) { + while (iswspace(lexer->lookahead)) { + lexer->advance(lexer, true); + } - while (iswspace(lexer->lookahead)) - lexer->advance(lexer, true); - - if (valid_symbols[VERBATIM_STRING] && lexer->lookahead == '@') { - lexer->result_symbol = VERBATIM_STRING; - advance(lexer); - - if (lexer->lookahead != '"') - return false; - advance(lexer); - - for (;;) { - if (lexer->lookahead == 0) { - return false; - } else if (lexer->lookahead == '"') { + if (valid_symbols[VERBATIM_STRING] && lexer->lookahead == '@') { + lexer->result_symbol = VERBATIM_STRING; advance(lexer); - // so in Squirrel two quotes is a normal quote - if (lexer->lookahead == '"') { - advance(lexer); - } else { - lexer->mark_end(lexer); - return true; + + if (lexer->lookahead != '"') { + return false; } - } else { advance(lexer); - } + + for (;;) { + if (lexer->lookahead == 0) { + return false; + } + if (lexer->lookahead == '"') { + advance(lexer); + // so in Squirrel two quotes is a normal quote + if (lexer->lookahead == '"') { + advance(lexer); + } else { + lexer->mark_end(lexer); + return true; + } + } else { + advance(lexer); + } + } } - } - return false; + return false; }