diff options
| author | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-12 16:28:30 +0200 |
|---|---|---|
| committer | Ákos Kőrösi <korakos99@gmail.com> | 2026-05-12 16:28:30 +0200 |
| commit | 89625d33abbdb99659ad6d8fa3df0de0b7a72f10 (patch) | |
| tree | d26a70c2f342f1f2dcaf3c9847723cbbfba7be51 /main.c | |
| parent | 32babee5145bb0248566960a69b674484deb3f94 (diff) | |
fix bugs in lex/parse, add ugly print util
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 26 |
1 files changed, 23 insertions, 3 deletions
@@ -6,6 +6,28 @@ #include "lex.h" #include "parse.h" +void uglyprint_pl(Pipeline pl) { + for (int i = 0; i < pl.count; i++) { + printf("%d\n"); + 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; while (1) { @@ -14,11 +36,9 @@ int main() { if (strcmp(line, "exit") == 0) exit(0); LexResult res = lex(line); Pipeline pl = parse_tokstream(res.top_tokens); - printf("%s \n", line); + uglyprint_pl(pl); } - free(line); - } |
