From 01a9392ad6051878e217bffeffd6261ccf994c42 Mon Sep 17 00:00:00 2001 From: Anton Kling Date: Fri, 17 Nov 2023 23:58:14 +0100 Subject: Minibox: Add a somewhat improved shell This shell actually lexes and produces a AST which makes it easier to add features and will makes it more difficult to introduce bugs. So basically it is just better code. --- userland/minibox/utilities/sh/ast.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 userland/minibox/utilities/sh/ast.h (limited to 'userland/minibox/utilities/sh/ast.h') diff --git a/userland/minibox/utilities/sh/ast.h b/userland/minibox/utilities/sh/ast.h new file mode 100644 index 0000000..7e7aaff --- /dev/null +++ b/userland/minibox/utilities/sh/ast.h @@ -0,0 +1,36 @@ +#ifndef AST_H +#define AST_H +#include "lexer.h" + +typedef enum { + AST_VALUE_STRING, +} ast_value_type_t; + +struct AST_VALUE { + ast_value_type_t type; + union { + char *string; + }; +}; + +typedef enum { + AST_COMMAND, + AST_EXPRESSION, + AST_CONDITIONAL_AND, + AST_CONDITIONAL_NOT, +} ast_type_t; + +struct AST { + ast_type_t type; + struct AST_VALUE val; + struct AST *children; + struct AST *pipe_rhs; // in "func1 | func2" func2 is the piped rhs + int file_out_fd_to_use; + int file_out_append; + const char *file_out; // in "func1 > file.txt" file.txt is the file_out + struct AST *next; +}; + +void free_ast(struct AST *ast); +struct AST *generate_ast(struct TOKEN *token); +#endif // AST_H -- cgit v1.2.3