From 6a391a1180766ac5717c40efa70d46cacca83f91 Mon Sep 17 00:00:00 2001 From: Ákos Kőrösi Date: Tue, 19 May 2026 21:03:12 +0200 Subject: sketch new setup --- syntax.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) (limited to 'syntax.h') diff --git a/syntax.h b/syntax.h index b395705..8404d15 100644 --- a/syntax.h +++ b/syntax.h @@ -3,11 +3,13 @@ #include "utils.h" +// Stage 1 + typedef enum { PLUS, MINUS, MULT, - DIV, +DIV, } BinOp; typedef enum { @@ -20,6 +22,7 @@ struct ArithmNode { ArithmNodeKind kind; union { int lit_val; + IntVec open_fds; struct { BinOp op; ArithmNode* left; @@ -96,3 +99,69 @@ typedef struct { TokenVec token_pool; TokenPtrVec top_tokens; } Ast; + + + +// Stage 2 + + +typedef enum { + REDIR_FILE_IN, + REDIR_FILE_OUT, + REDIR_FDS, +} RedirectKind; + +typedef struct { + RedirectKind kind; + union { + char* filename; + struct{int from; int to;} fds; + } as; +} Redirect; + +DECLARE_VEC(Redirect, RedirectVec) + +typedef struct { + char** args; + RedirectVec redirects; +} SimpleCommand; + +DECLARE_VEC(SimpleCommand, SimpleCommandVec) +DECLARE_VEC(SimpleCommand*, SimpleCommandPtrVec) + + +typedef enum { + CONN_PIPE, + CONN_EOL, +} Connector; + +typedef struct { + SimpleCommand* cmd; + SimpleCommandPtrVec deps; + Connector conn; +} PlCommand; + +DECLARE_VEC(PlCommand, PlCommandVec) + +typedef struct { + SimpleCommandVec commands; + PlCommandVec pipeline; +} ExecTree; + + + +// Stage 3 + +typedef struct { + int redirected; + int to; +} FdRedirect; + +DECLARE_VEC(FdRedirect, FdRedirectVec) + +typedef struct { + char** args; + FdRedirectVec redirects; + int stdin_fd, stdout_fd; + IntVec open_fds; +} ExecutableCommand; -- cgit v1.2.3