feat: enhance compiler

- Add comments and test for it
- Add semicolon as required end of some expressions
- Add new arguments parser
- Add multi-file compilation
- Add colors in output
This commit is contained in:
samsonium
2026-10-15 17:20:43 +03:00
parent 1035b9193c
commit 69b2253c34
22 changed files with 739 additions and 327 deletions
+49
View File
@@ -0,0 +1,49 @@
#ifndef FZL_LINKED_H
#define FZL_LINKED_H
#include <stdbool.h>
#include <stddef.h>
// Linked file descriptor
typedef struct
{
char *name;
size_t start;
size_t end;
} fzl_linked_entry_t;
// Linked descriptor
typedef struct
{
fzl_linked_entry_t *entries;
size_t entries_count;
char *source;
size_t total_sz;
} fzl_linked_t;
// Position in file
typedef struct
{
size_t line;
size_t col;
char *filename;
} fzl_file_loc;
// Allocated new linked
fzl_linked_t *fzl_mklinked();
// Read specified files
bool fzl_linked_add_files(fzl_linked_t *l, char **files, size_t files_count);
// Get last error from linked
char *fzl_linked_geterror();
// Get filename and position in it by reader cursor
bool fzl_linked_getpos(fzl_linked_t *l, size_t pos, fzl_file_loc *res);
// Free linked obj
void fzl_freelinked(fzl_linked_t *linked);
#endif // FZL_LINKED_H
+25
View File
@@ -0,0 +1,25 @@
#ifndef FZL_OPTIONS_H
#define FZL_OPTIONS_H
#include <stdbool.h>
#include <stddef.h>
// Compiler options
typedef struct
{
char **files;
size_t files_count;
char *outname;
bool should_continue;
bool verbose;
} fzl_options_t;
// Parse command line arguments
fzl_options_t *fzl_mkoptions(int argc, char **argv);
// Free options
void fzl_freeoptions(fzl_options_t *options);
#endif // FZL_OPTIONS_H