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/lexer.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 userland/minibox/utilities/sh/lexer.h (limited to 'userland/minibox/utilities/sh/lexer.h') diff --git a/userland/minibox/utilities/sh/lexer.h b/userland/minibox/utilities/sh/lexer.h new file mode 100644 index 0000000..57fb30b --- /dev/null +++ b/userland/minibox/utilities/sh/lexer.h @@ -0,0 +1,24 @@ +#ifndef LEXER_H +#define LEXER_H +#include + +typedef enum { + TOKEN_CHARS, + TOKEN_AND, + TOKEN_NOT, + TOKEN_NOOP, + TOKEN_PIPE, + TOKEN_STREAM, + TOKEN_STREAM_APPEND, +} token_type_t; + +struct TOKEN { + token_type_t type; + char string_rep[256]; + struct TOKEN *next; +}; + +struct TOKEN *lex(const char *code); +struct AST *generate_ast(struct TOKEN *token); +void free_tokens(struct TOKEN *token); +#endif // LEXER_H -- cgit v1.2.3