Fixes.
h3rald h3rald@h3rald.com
Wed, 27 Nov 2024 11:13:06 +0100
1 files changed,
15 insertions(+),
15 deletions(-)
jump to
M
hex.h
→
hex.h
@@ -119,26 +119,27 @@ int argc;
char **argv; } hex_context_t; -// Functions - -hex_context_t hex_init(); +// Free data void hex_free_element(hex_context_t *ctx, hex_item_t element); void hex_free_token(hex_token_t *token); void hex_free_list(hex_context_t *ctx, hex_item_t **quotation, int size); +// Symbol management int hex_valid_user_symbol(hex_context_t *ctx, const char *symbol); int hex_valid_native_symbol(const char *symbol); int hex_set_symbol(hex_context_t *ctx, const char *key, hex_item_t value, int native); void hex_set_native_symbol(hex_context_t *ctx, const char *name, int (*func)()); int hex_get_symbol(hex_context_t *ctx, const char *key, hex_item_t *result); +// Errors and debugging void hex_error(hex_context_t *ctx, const char *format, ...); void hex_debug(hex_context_t *ctx, char *format, ...); void hex_debug_element(hex_context_t *ctx, const char *message, hex_item_t element); void hex_print_element(FILE *stream, hex_item_t element); void add_to_stack_trace(hex_context_t *ctx, hex_token_t *token); -char *hex_type(hex_item_type_t type); +void print_stack_trace(hex_context_t *ctx); +// Stack management int hex_push(hex_context_t *ctx, hex_item_t element); int hex_push_int(hex_context_t *ctx, int value); int hex_push_string(hex_context_t *ctx, const char *value);@@ -146,20 +147,22 @@ int hex_push_quotation(hex_context_t *ctx, hex_item_t **quotation, int size);
int hex_push_symbol(hex_context_t *ctx, hex_token_t *token); hex_item_t hex_pop(hex_context_t *ctx); +// Parser and interpreter char *hex_process_string(hex_context_t *ctx, const char *value); - hex_token_t *hex_next_token(hex_context_t *ctx, const char **input, hex_file_position_t *position); - -void print_stack_trace(hex_context_t *ctx); +int32_t hex_parse_integer(const char *hex_str); +int hex_parse_quotation(hex_context_t *ctx, const char **input, hex_item_t *result, hex_file_position_t *position); +int hex_interpret(hex_context_t *ctx, char *code, char *filename, int line, int column); +// Helpers char *hex_itoa(int num, int base); char *hex_itoa_dec(int num); char *hex_itoa_hex(int num); - void hex_raw_print_element(FILE *stream, hex_item_t element); - int hex_is_symbol(hex_token_t *token, char *value); +char *hex_type(hex_item_type_t type); +// Native symbols int hex_symbol_store(hex_context_t *ctx); int hex_symbol_free(hex_context_t *ctx); int hex_symbol_type(hex_context_t *ctx);@@ -225,15 +228,12 @@ int hex_symbol_stack(hex_context_t *ctx);
int hex_symbol_clear(hex_context_t *ctx); int hex_symbol_pop(hex_context_t *ctx); -void hex_register_symbols(); - +// REPL and initialization +void hex_register_symbols(hex_context_t *ctx); +hex_context_t hex_init(); void hex_repl(hex_context_t *ctx); void hex_process_stdin(hex_context_t *ctx); void hex_handle_sigint(int sig); char *hex_read_file(hex_context_t *ctx, const char *filename); - -int32_t hex_parse_integer(const char *hex_str); -int hex_parse_quotation(hex_context_t *ctx, const char **input, hex_item_t *result, hex_file_position_t *position); -int hex_interpret(hex_context_t *ctx, char *code, char *filename, int line, int column); #endif // HEX_H