From 77dfc38c19b9602c08777686f626975c54cb9183 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Fri, 22 May 2026 11:06:44 +0200 Subject: split out front-to-back running logic --- src/config.h | 3 +++ src/main.c | 11 ++++++++--- src/stages.h | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/config.h (limited to 'src') diff --git a/src/config.h b/src/config.h new file mode 100644 index 0000000..31e8fa1 --- /dev/null +++ b/src/config.h @@ -0,0 +1,3 @@ +#pragma once + +static const char* rcfile = "scratch/.yrc"; diff --git a/src/main.c b/src/main.c index 6653fdd..f595c4a 100644 --- a/src/main.c +++ b/src/main.c @@ -9,6 +9,13 @@ #include "utils.h" +void execute_line(char *line, ShellState *shstate) { + Ast ast = lex(line); + PipelineTree pltree = process_ast(ast, shstate); + execute_pipeline_tree(pltree, shstate); +} + + int main() { ShellState shstate = {.shell_vars = make_KeyValMap(256), .aliases = make_KeyValMap(256)}; char* line; @@ -16,9 +23,7 @@ int main() { line = readline("$ "); if (line[0] == '\0') continue; add_history(line); - Ast ast = lex(line); - PipelineTree pltree = process_ast(ast, &shstate); - execute_pipeline_tree(pltree, &shstate); + execute_line(line, &shstate); } free(line); } diff --git a/src/stages.h b/src/stages.h index 8c7ed0b..2f90a26 100644 --- a/src/stages.h +++ b/src/stages.h @@ -6,3 +6,5 @@ Ast lex(char* input); PipelineTree process_ast(Ast ast, ShellState* shstate); void execute_pipeline_tree(PipelineTree pltree, ShellState* shstate); +//void source_script(char* fname, ShellState* shstate); +void execute_line(char* line, ShellState* shstate); -- cgit v1.2.3