diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/config.h | 3 | ||||
| -rw-r--r-- | src/main.c | 11 | ||||
| -rw-r--r-- | src/stages.h | 2 |
3 files changed, 13 insertions, 3 deletions
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); |
