all repos — hex @ 0583e82b1c18ea14591fd37443b0754bf6cebfa3

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

Implemented repl and stdin piping support.
h3rald h3rald@h3rald.com
Sat, 16 Nov 2024 21:33:35 +0000
commit

0583e82b1c18ea14591fd37443b0754bf6cebfa3

parent

6c4e98878aa3b2185731abccfad56ecccc19fdf6

1 files changed, 5 insertions(+), 4 deletions(-)

jump to
M hex.chex.c

@@ -698,6 +698,8 @@ fclose(file);

return buffer; } +volatile sig_atomic_t keep_running = 1; + void repl() { char line[1024]; printf("hex Interactive REPL. Type 'exit' to quit or press Ctrl+C.\n");

@@ -718,11 +720,10 @@ break;

} // Tokenize and process the input - tokenize_and_process(line); + process(line); } } -volatile sig_atomic_t keep_running = 1; void handle_sigint(int sig) { (void)sig; // Suppress unused warning

@@ -739,7 +740,7 @@ return;

} buffer[bytesRead] = '\0'; // Null-terminate the input - tokenize_and_process(buffer); + process(buffer); } int main(int argc, char *argv[]) {

@@ -754,7 +755,7 @@ if (!fileContent) {

return EXIT_FAILURE; } - tokenize_and_process(fileContent); + process(fileContent); free(fileContent); // Free the allocated memory } else if (!isatty(fileno(stdin))) { // Process piped input from stdin