diff options
Diffstat (limited to 'syntax.h')
| -rw-r--r-- | syntax.h | 71 |
1 files changed, 70 insertions, 1 deletions
@@ -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; |
