|
Luma 0.1.0
A low-level compiled alternative to C, C++, and more!
|
Declarations for command-line parsing, file reading, and build configuration. More...
#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#include "../ast/ast.h"#include "../c_libs/memory/memory.h"#include "../lexer/lexer.h"#include "../llvm/llvm.h"

Go to the source code of this file.
Classes | |
| struct | BuildConfig |
| Configuration structure to hold build options parsed from CLI. More... | |
| struct | CompileTimer |
Macros | |
| #define | TOKEN_AT(i) (((Token *)tokens.data)[(i)]) |
| #define | MAX_TOKENS 300 |
| #define | BAR_WIDTH 40 |
| #define | DEBUG_ARENA_ALLOC 1 |
| #define | Luma_Compiler_version "v0.2.6" |
Enumerations | |
| enum | ErrorCode { ARGC_ERROR = 1 , FILE_ERROR = 2 , MEMORY_ERROR = 3 , LEXER_ERROR = 4 , PARSER_ERROR = 5 , RUNTIME_ERROR = 6 , UNKNOWN_ERROR = 99 } |
Functions | |
| bool | check_argc (int argc, int expected) |
| Checks if the number of command-line arguments is at least expected. | |
| const char * | read_file (const char *filename) |
| Reads entire file content into a newly allocated buffer. | |
| int | print_help () |
| Prints help message describing usage and options. | |
| int | print_version () |
| Prints version information. | |
| int | print_license () |
| Prints license information. | |
| const char * | detect_target_os (void) |
| AstNode * | lex_and_parse_file (const char *path, ArenaAllocator *allocator, BuildConfig *config) |
| bool | PathExist (const char *p) |
| bool | PathIsDir (const char *p) |
| bool | parse_args (int argc, char *argv[], BuildConfig *config, ArenaAllocator *arena) |
| Parses command-line arguments and configures the build. | |
| bool | run_build (BuildConfig config, ArenaAllocator *allocator) |
| bool | run_formatter (BuildConfig config, ArenaAllocator *allocator) |
| void | print_token (const Token *t) |
| Prints a token's text and its token type with color formatting. | |
| void | print_progress (int step, int total, const char *stage) |
| void | ensure_clean_line () |
| void | timer_start (CompileTimer *timer) |
| void | timer_stop (CompileTimer *timer) |
| double | timer_get_elapsed_ms (CompileTimer *timer) |
| void | print_progress_with_time (int step, int total, const char *stage, CompileTimer *timer) |
| bool | link_with_ld (const char *obj_filename, const char *exe_filename) |
| Links object file using ld to create an executable (Unix/Linux) | |
| bool | get_gcc_file_path (const char *filename, char *buffer, size_t buffer_size) |
| Get a file path from gcc. | |
| bool | get_lib_paths (char *buffer, size_t buffer_size) |
| Get the system's library search paths. | |
| bool | link_with_ld_simple (const char *obj_filename, const char *exe_filename) |
| Alternative simpler linking approach using system() | |
| bool | link_object_files (const char *output_dir, const char *executable_name, int opt_level, bool is_debug, CodeGenContext *ctx) |
| bool | validate_module_system (CodeGenContext *ctx) |
| void | save_module_output_files (CodeGenContext *ctx, const char *output_dir) |
Declarations for command-line parsing, file reading, and build configuration.
Provides functions to parse arguments, read files, print help/version/license, and print token debug info.
| #define BAR_WIDTH 40 |
| #define DEBUG_ARENA_ALLOC 1 |
Enable debug logs for arena allocator (comment to disable)
| #define Luma_Compiler_version "v0.2.6" |
| #define MAX_TOKENS 300 |
| #define TOKEN_AT | ( | i | ) | (((Token *)tokens.data)[(i)]) |
Macro to access token at index in a token growable array
| enum ErrorCode |
| bool check_argc | ( | int | argc, |
| int | expected | ||
| ) |
Checks if the number of command-line arguments is at least expected.
Prints usage info if not enough arguments.
| argc | Actual argument count. |
| expected | Minimum expected argument count. |
| const char * detect_target_os | ( | void | ) |
| void ensure_clean_line | ( | ) |
| bool get_gcc_file_path | ( | const char * | filename, |
| char * | buffer, | ||
| size_t | buffer_size | ||
| ) |
Get a file path from gcc.
| filename | The filename to search for |
| buffer | Buffer to store the result |
| buffer_size | Size of the buffer |
| bool get_lib_paths | ( | char * | buffer, |
| size_t | buffer_size | ||
| ) |
Get the system's library search paths.
| buffer | Buffer to store library paths |
| buffer_size | Size of the buffer |
| AstNode * lex_and_parse_file | ( | const char * | path, |
| ArenaAllocator * | allocator, | ||
| BuildConfig * | config | ||
| ) |
| bool link_object_files | ( | const char * | output_dir, |
| const char * | executable_name, | ||
| int | opt_level, | ||
| bool | is_debug, | ||
| CodeGenContext * | ctx | ||
| ) |
| bool link_with_ld | ( | const char * | obj_filename, |
| const char * | exe_filename | ||
| ) |
Links object file using ld to create an executable (Unix/Linux)
| obj_filename | Path to the object file |
| exe_filename | Path for the output executable |
| bool link_with_ld_simple | ( | const char * | obj_filename, |
| const char * | exe_filename | ||
| ) |
Alternative simpler linking approach using system()
| obj_filename | Path to the object file |
| exe_filename | Path for the output executable |
| bool parse_args | ( | int | argc, |
| char * | argv[], | ||
| BuildConfig * | config, | ||
| ArenaAllocator * | arena | ||
| ) |
Parses command-line arguments and configures the build.
Supports options for version, help, license, build, save, clean, and debug.
| argc | Argument count. |
| argv | Argument vector. |
| config | Pointer to BuildConfig struct to fill. |
| bool PathExist | ( | const char * | p | ) |
| bool PathIsDir | ( | const char * | p | ) |
| int print_help | ( | ) |
Prints help message describing usage and options.
| int print_license | ( | ) |
Prints license information.
| void print_progress | ( | int | step, |
| int | total, | ||
| const char * | stage | ||
| ) |
| void print_progress_with_time | ( | int | step, |
| int | total, | ||
| const char * | stage, | ||
| CompileTimer * | timer | ||
| ) |
| void print_token | ( | const Token * | t | ) |
Prints a token's text and its token type with color formatting.
| t | Pointer to the Token to print. |
| int print_version | ( | ) |
Prints version information.
| const char * read_file | ( | const char * | filename | ) |
Reads entire file content into a newly allocated buffer.
The caller must free the returned buffer.
| filename | Path to the file to read. |
| bool run_build | ( | BuildConfig | config, |
| ArenaAllocator * | allocator | ||
| ) |
| bool run_formatter | ( | BuildConfig | config, |
| ArenaAllocator * | allocator | ||
| ) |
| void save_module_output_files | ( | CodeGenContext * | ctx, |
| const char * | output_dir | ||
| ) |
| double timer_get_elapsed_ms | ( | CompileTimer * | timer | ) |
| void timer_start | ( | CompileTimer * | timer | ) |
| void timer_stop | ( | CompileTimer * | timer | ) |
| bool validate_module_system | ( | CodeGenContext * | ctx | ) |