summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/main.c b/main.c
index 690b6d9..70382c4 100644
--- a/main.c
+++ b/main.c
@@ -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);
-
}