-
Notifications
You must be signed in to change notification settings - Fork 0
/
my_parser.h
57 lines (51 loc) · 1010 Bytes
/
my_parser.h
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
49
50
51
52
53
54
55
56
57
#ifndef MY_PARSER_H
#define MY_PARSER_H
#include "path_variable_scanner.h"
#include "file_reader.h"
#include "tokenizer.h"
typedef enum {
NODE_VAR_DECL,
NODE_FUNC_DECL,
NODE_IF_STMT,
NODE_ELSE_STMT,
NODE_RETURN_STMT,
NODE_FOR_LOOP,
NODE_WHILE_LOOP,
NODE_ASSIGN,
NODE_BIN_EXPR,
NODE_UNARY_EXPR,
NODE_EXPR,
NODE_FUNC_CALL,
NODE_STR_LITERAL,
NODE_INT_LITERAL,
NODE_FLT_LITERAL,
NODE_BOOL_LITERAL,
NODE_OPERATOR,
NODE_COMPARE,
NODE_PAREN_OPEN,
NODE_PAREN_CLOSE,
NODE_END,
NODE_IDENTIFIER,
NODE_ARGS,
NODE_ARG,
NODE_ARRAY,
NODE_ARRAY_CLOSE,
NODE_CONDITION,
NODE_STMT_BODY,
NODE_BRACK_CLOSE,
NODE_BREAK_STMT,
NODE_SKIP_STMT,
NODE_LIST_COMMA,
NODE_SHORT_CALC,
NODE_AST
} NodeType;
typedef struct Node Node;
struct Node {
int start_t;
int end_t;
NodeType type;
int num_childs;
struct Node *childs;
};
Node *parse_tokens(Token *p_tokens, int p_ast);
#endif