summaryrefslogtreecommitdiff
path: root/syntax.h
diff options
context:
space:
mode:
authorÁkos Kőrösi <korakos99@gmail.com>2026-05-19 21:03:12 +0200
committerÁkos Kőrösi <korakos99@gmail.com>2026-05-19 21:03:12 +0200
commit6a391a1180766ac5717c40efa70d46cacca83f91 (patch)
treedae1c0d5987e4ef54e12e2562b842deb0792eeeb /syntax.h
parent32773451f89612dcd863fbb8c9bfd552ef83a913 (diff)
sketch new setup
Diffstat (limited to 'syntax.h')
-rw-r--r--syntax.h71
1 files changed, 70 insertions, 1 deletions
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;