Added .clang-format.

This commit is contained in:
Jacob Signorovitch 2024-10-02 21:04:54 -04:00
parent 53c303095d
commit aae8402403
2 changed files with 20 additions and 18 deletions

12
.clang-format Normal file
View File

@ -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

View File

@ -14,30 +14,20 @@ Lexer* lexer_init(char* src) {
return lexer; return lexer;
} }
void lexer_destroy(Lexer *lexer) { void lexer_destroy(Lexer* lexer) {
free(lexer->src); free(lexer->src);
for ( for (int i = 0; i < lexer->ntokens; token_destroy(lexer->tokens[i++]));
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) { void lexer_lex(Lexer* lexer) {
while (*lexer->cchar) { while (*lexer->cchar) {
switch (lexer->state) { switch (lexer->state) {
case LEXER_STATE_CONFUSED: case LEXER_STATE_CONFUSED: lexer_do_confused(lexer); break;
lexer_do_confused(lexer); case LEXER_STATE_NUM: lexer_do_number(lexer); break;
break; case LEXER_STATE_NUM: case LEXER_STATE_CALL: lexer_do_call(lexer); break;
lexer_do_number(lexer);
break; case LEXER_STATE_CALL:
lexer_do_call(lexer);
break;
default: break; default: break;
} }
} }