summaryrefslogtreecommitdiff
path: root/21sh/ll-expr/src/parser/parser.h
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:07:58 +0200
commit967be9e750221ab2ab783f95df79bb26d290a45e (patch)
tree6802900a5e975f9f68b169f0f503f040056d6952 /21sh/ll-expr/src/parser/parser.h
add: added projectsHEADmain
Diffstat (limited to '21sh/ll-expr/src/parser/parser.h')
-rw-r--r--21sh/ll-expr/src/parser/parser.h46
1 files changed, 46 insertions, 0 deletions
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 */