]> git.lizzy.rs Git - nothing.git/blob - src/ebisp/parser.h
ebisp/std: Validate arglist to defun in the same way as for lambda
[nothing.git] / src / ebisp / parser.h
1 #ifndef PARSER_H_
2 #define PARSER_H_
3
4 #include <stdio.h>
5 #include <stdbool.h>
6 #include "ebisp/expr.h"
7 #include "ebisp/tokenizer.h"
8
9 struct ParseResult
10 {
11     bool is_error;
12     const char *end;
13     union {
14         struct Expr expr;
15         const char *error_message;
16     };
17 };
18
19 struct ParseResult parse_success(struct Expr expr,
20                                  const char *end);
21 struct ParseResult parse_failure(const char *error,
22                                  const char *end);
23
24
25 struct ParseResult read_expr_from_string(Gc *gc, const char *str);
26 struct ParseResult read_all_exprs_from_string(Gc *gc, const char *str);
27
28 struct ParseResult read_expr_from_file(Gc *gc, const char *filename);
29 struct ParseResult read_all_exprs_from_file(Gc *gc, const char *filename);
30
31 void print_parse_error(FILE *stream,
32                        const char *str,
33                        struct ParseResult result);
34
35 #endif  // PARSER_H_