diff options
| author | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-22 11:06:44 +0200 |
|---|---|---|
| committer | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-22 11:06:44 +0200 |
| commit | 77dfc38c19b9602c08777686f626975c54cb9183 (patch) | |
| tree | daaa12516b13724a2e2ce2768249781a6e9328db | |
| parent | 52f8b31f8a06a39b223780d2df304b06d0d43daa (diff) | |
split out front-to-back running logic
| -rw-r--r-- | docs/DEVNOTES.md | 2 | ||||
| -rw-r--r-- | src/config.h | 3 | ||||
| -rw-r--r-- | src/main.c | 11 | ||||
| -rw-r--r-- | src/stages.h | 2 |
4 files changed, 15 insertions, 3 deletions
diff --git a/docs/DEVNOTES.md b/docs/DEVNOTES.md index 8093efc..02ba0cc 100644 --- a/docs/DEVNOTES.md +++ b/docs/DEVNOTES.md @@ -11,5 +11,7 @@ ## LATER - proper error handling - marked todos in code +- extensibility hooks and exposed constant +- freeing allocs ## BUGS 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"; @@ -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); |
