From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- 21sh/ll-expr/src/parser/parser.h | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 21sh/ll-expr/src/parser/parser.h (limited to '21sh/ll-expr/src/parser/parser.h') diff --git a/21sh/ll-expr/src/parser/parser.h b/21sh/ll-expr/src/parser/parser.h new file mode 100644 index 0000000..057c6bc --- /dev/null +++ b/21sh/ll-expr/src/parser/parser.h @@ -0,0 +1,46 @@ +#ifndef PARSER_H +#define PARSER_H + +#include "ast.h" +#include "lexer.h" + +enum parser_status +{ + PARSER_OK, + PARSER_UNEXPECTED_TOKEN, +}; + +/** + * \brief Parses an expression or nothing. + * + * input = EOF + * | exp EOF ; + */ +struct ast *parse(enum parser_status *status, struct lexer *lexer); + +/** + * \brief Parses sexp expressions separated by + and -. + * + * exp = sexp { ( '+' | '-' ) sexp } ; + */ +struct ast *parse_exp(enum parser_status *status, struct lexer *lexer); + +/** + * \brief Parses texp expressions separated by * and /. + * + * sexp = texp { ('*' | '/' ) texp } ; + */ +struct ast *parse_sexp(enum parser_status *status, struct lexer *lexer); + +/** + * \brief Parses a number, a - a number, or a parenthesized expression. + * + * texp = NUMBER + * | '-' NUMBER + * | '-' '(' exp ')' + * | '(' exp ')' + * ; + */ +struct ast *parse_texp(enum parser_status *status, struct lexer *lexer); + +#endif /* !PARSER_H */ -- cgit v1.2.3