Syntax highlighting and comment

This commit is contained in:
Arthur Barraux
2026-01-11 19:41:30 +01:00
parent 815114923d
commit fc93832130
11 changed files with 623 additions and 25 deletions
+1
View File
@@ -67,6 +67,7 @@ struct editorConfig {
struct const_t constantes;
int quit_times_buffer;
char *init_file_path;
FILE *fd_init_file;
Lisp env;
LispContext ctx; /** Lisp context */
+4 -1
View File
@@ -2075,8 +2075,10 @@ static Lisp parse(Lexer* lex, LispError* out_error, LispContext ctx)
result = lisp_cons(get_sym(SYM_BEGIN, ctx), lisp_list_reverse(result), ctx);
}
if (out_error) *out_error = error;
if (out_error)
*out_error = error;
return result;
}
Lisp lisp_read(const char *program, LispError* out_error, LispContext ctx)
@@ -2122,6 +2124,7 @@ void* fread_all_(FILE* file, size_t* out_size) {
return NULL;
}
data = new_data;
memset(data + *out_size, 0, cap - *out_size);
}
size_t read = fread(data + *out_size, 1, BLOCK_SIZE, file);
+20
View File
@@ -0,0 +1,20 @@
#define COLOR_RESET "\033[0m"
#define COLOR_KEYWORD "\033[1;35m" // Bold magenta
#define COLOR_TYPE "\033[1;34m" // Bold blue
#define COLOR_STRING "\033[1;32m" // Bold green
#define COLOR_COMMENT "\033[0;36m" // Cyan
#define COLOR_NUMBER "\033[1;33m" // Bold yellow
#define COLOR_DEFAULT "\033[0;37m" // White
// Token types
typedef enum {
TOKEN_KEYWORD,
TOKEN_TYPE,
TOKEN_STRING,
TOKEN_COMMENT,
TOKEN_NUMBER,
TOKEN_OPERATOR,
TOKEN_DEFAULT
} TokenType;
char *highlight_line(const char * line, int *length);