]> git.lizzy.rs Git - nothing.git/blob - src/script/parser.h
(#408) use stdbool in camera unit
[nothing.git] / src / script / parser.h
1 #ifndef PARSER_H_
2 #define PARSER_H_
3
4 #include <stdio.h>
5 #include <stdbool.h>
6 #include "script/expr.h"
7 #include "script/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 struct ParseResult read_expr_from_string(Gc *gc, const char *str);
25 struct ParseResult read_expr_from_file(Gc *gc, const char *filename);
26
27 void print_parse_error(FILE *stream,
28                        const char *str,
29                        struct ParseResult result);
30
31 #endif  // PARSER_H_