From af3fa90e8bb41c306c5fe2d2cf105db6bbabd1d9 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 19 Oct 2021 10:53:45 -0700 Subject: Feat: word operators and more robust crashing Added the length and concatenate operators. Slightly improved the robustness on syntax errors. --- sys/cmd/rc/code.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sys/cmd/rc/code.c') diff --git a/sys/cmd/rc/code.c b/sys/cmd/rc/code.c index d4dd6e1..c98cde2 100644 --- a/sys/cmd/rc/code.c +++ b/sys/cmd/rc/code.c @@ -51,6 +51,7 @@ walk(Tree *node) switch(node->type){ default: print(shell.err, "bad type %d in interpreter walk\n", node->type); + fatal("crashing\n"); break; case '$': @@ -59,6 +60,20 @@ walk(Tree *node) emitf(Xdollar); break; + case Tcount: + emitf(Xmark); + walk(node->child[0]); + emitf(Xcount); + break; + + case Tflat: + emitf(Xmark); + walk(node->child[0]); + emitf(Xflat); + break; + + case Tindex: + #if 0 case '&': emitf(Xasync); @@ -103,6 +118,11 @@ walk(Tree *node) emits(strdup(node->str)); break; + case Twords: + walk(node->child[1]); + walk(node->child[0]); + break; + case '=': for(n=node; node && node->type == '='; node = node->child[2]) ; -- cgit v1.2.1