From aae84024034c65b5a37183a4240be148c2d350cd Mon Sep 17 00:00:00 2001 From: Jacob Date: Wed, 2 Oct 2024 21:04:54 -0400 Subject: [PATCH] Added .clang-format. --- .clang-format | 12 ++++++++++++ src/lexer.c | 26 ++++++++------------------ 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..fbd9e79 --- /dev/null +++ b/.clang-format @@ -0,0 +1,12 @@ +--- +BasedOnStyle: LLVM +AlignConsecutiveShortCaseStatements: + Enabled: true + AcrossEmptyLines: true + AcrossComments: true +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLoopsOnASingleLine: true +IndentWidth: 4 +PointerAlignment: Left diff --git a/src/lexer.c b/src/lexer.c index 6e8eb5b..d5b6946 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -6,7 +6,7 @@ Lexer* lexer_init(char* src) { lexer->src = src; lexer->srcl = strlen(src); lexer->cchar = lexer->src; - + lexer->tokens = NULL; lexer->ntokens = 0; lexer->state = LEXER_STATE_CONFUSED; @@ -14,31 +14,21 @@ Lexer* lexer_init(char* src) { return lexer; } -void lexer_destroy(Lexer *lexer) { +void lexer_destroy(Lexer* lexer) { free(lexer->src); - for ( - int i = 0; - i < lexer->ntokens; - token_destroy(lexer->tokens[i++]) - ); + for (int i = 0; i < lexer->ntokens; token_destroy(lexer->tokens[i++])); } -void lexer_do_confused(Lexer *lexer) { - -} +void lexer_do_confused(Lexer* lexer) {} void lexer_lex(Lexer* lexer) { while (*lexer->cchar) { switch (lexer->state) { - case LEXER_STATE_CONFUSED: - lexer_do_confused(lexer); - break; case LEXER_STATE_NUM: - lexer_do_number(lexer); - break; case LEXER_STATE_CALL: - lexer_do_call(lexer); - break; - default: break; + case LEXER_STATE_CONFUSED: lexer_do_confused(lexer); break; + case LEXER_STATE_NUM: lexer_do_number(lexer); break; + case LEXER_STATE_CALL: lexer_do_call(lexer); break; + default: break; } } }