format using clang-format to formate code

This commit is contained in:
zzy
2025-11-20 17:55:08 +08:00
parent 9762cf8a2b
commit d1fafa830d
27 changed files with 1047 additions and 766 deletions

View File

@@ -1,7 +1,7 @@
#include <lexer.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
/// gcc -g ../lexer.c ../token.c test_lexer.c -o test_lexer
/*
@@ -20,19 +20,17 @@ tok_tConstant {
int g_num;
int g_num_arr[3];
int main(int argc, char* argv[]) {
int main(int argc, char *argv[]) {
// int num = 0;
if (argc == 3 && strcmp(argv[2], "-nodebug") == 0) {
log_set_level(NULL, LOG_LEVEL_INFO
| LOG_LEVEL_WARN
| LOG_LEVEL_ERROR);
log_set_level(NULL, LOG_LEVEL_INFO | LOG_LEVEL_WARN | LOG_LEVEL_ERROR);
}
const char* file_name = __FILE__;
const char *file_name = __FILE__;
if (argc == 2) {
file_name = argv[1];
}
FILE* fp = fopen(file_name, "rb");
FILE *fp = fopen(file_name, "rb");
if (fp == NULL) {
perror("open file failed");
return 1;
@@ -50,7 +48,7 @@ int main(int argc, char* argv[]) {
return 1;
}
char* buffer = (char*) malloc(fsize);
char *buffer = (char *)malloc(fsize);
usize read_ret = fread(buffer, 1, fsize, fp);
fclose(fp);
@@ -62,7 +60,8 @@ int main(int argc, char* argv[]) {
smcc_lexer_t lexer;
core_mem_stream_t mem_stream = {0};
core_stream_t* stream = core_mem_stream_init(&mem_stream, buffer, fsize, false);
core_stream_t *stream =
core_mem_stream_init(&mem_stream, buffer, fsize, false);
Assert(stream != null);
cstring_clear(&stream->name);
cstring_push_cstr(&stream->name, file_name, strlen(file_name));
@@ -74,7 +73,8 @@ int main(int argc, char* argv[]) {
if (tok.type == TOKEN_EOF) {
break;
}
LOG_DEBUG("token `%s` at %s:%u:%u", get_tok_name(tok.type), tok.loc.name, tok.loc.line, tok.loc.column);
LOG_DEBUG("token `%s` at %s:%u:%u", get_tok_name(tok.type),
tok.loc.name, tok.loc.line, tok.loc.column);
Assert(tok.loc.offset <= fsize);
// LOG_DEBUG("%s", tok.val.str);
// printf("line: %d, column: %d, type: %3d, typename: %s\n",