]> git.lizzy.rs Git - uwu-lang.git/blob - src/parse.h
Code format
[uwu-lang.git] / src / parse.h
1 #ifndef _PARSE_H_
2 #define _PARSE_H_
3
4 #include <stddef.h>
5 #include <stdbool.h>
6 #include "expression.h"
7
8 typedef struct ParseExpression
9 {
10         ExpressionType type;
11         union
12         {
13                 int   int_value;
14                 char *str_value;
15         } value;
16         size_t num_children;
17         struct ParseExpression **children;
18         struct ParseExpression *parent;
19 } ParseExpression;
20
21 typedef struct
22 {
23         char *name;
24         ParseExpression *expression;
25 } ParseFunction;
26
27 typedef struct
28 {
29         size_t num_functions;
30         ParseFunction **functions;
31 } AbstractSyntaxTree;
32
33 typedef struct
34 {
35         AbstractSyntaxTree tree;
36
37         size_t buffer_size;
38         char *buffer;
39
40         ParseExpression *expression;
41
42         int lines;
43         bool success;
44 } ParseState;
45
46 AbstractSyntaxTree parse_file(const char *filename);
47
48 #endif