#include #include #include #include #include "lex.h" #include "parse.h" #include "exec.h" void uglyprint_pl(Pipeline pl) { for (int i = 0; i < pl.count; i++) { printf("%d\n", i); TokenVec toks = (*get_from_Pipeline(&pl, i)).cmd.args; for (int j = 0; j < toks.count; j++) { Token tok = *get_from_TokenVec(&toks, j); if (tok.kind != TOK_WORD) { printf(" [NON-WORD] "); continue; } Word word = tok.as.word; for (int k = 0; k < word.count; k++) { Chunk chunk = *get_from_Word(&word, k); if (chunk.kind == LITERAL) { printf("%s", chunk.as.literal_str); } } } } } int main() { char* line; ShellState shstate = {.shell_vars = make_KeyValMap(1), .aliases = make_KeyValMap(1)}; while (1) { line = readline("$ "); if (line[0] == '\0') continue; if (strcmp(line, "exit") == 0) exit(0); LexResult res = lex(line); Pipeline pl = parse_tokstream(res.top_tokens); run_pipeline(pl, &shstate); } free(line); }