aboutsummaryrefslogtreecommitdiff
path: root/src/parse.h
blob: 7c13dd73757c13244887fc7a3e44a56216e8d019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef _PARSE_H_
#define _PARSE_H_

#include <stddef.h>
#include <stdbool.h>
#include "api/vm.h"

typedef struct ParseExpression
{
	UwUVMExpressionType type;
	union
	{
		long  int_value;
		char *str_value;
	} value;
	size_t num_children;
	struct ParseExpression **children;
	struct ParseExpression *parent;
} ParseExpression;

typedef struct
{
	char *name;
	ParseExpression *expression;
} ParseFunction;

typedef struct
{
	size_t num_functions;
	ParseFunction **functions;
} AbstractSyntaxTree;

typedef struct
{
	AbstractSyntaxTree tree;

	size_t buffer_size;
	char *buffer;

	ParseExpression *expression;

	int lines;
	bool success;
} ParseState;

AbstractSyntaxTree parse_file(const char *filename);

#endif