aboutsummaryrefslogtreecommitdiffstats
path: root/src/parser.h
blob: 21a2711c30085c33088a705f45c17861ef2e8756 (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 BDL_PARSER_H
#define BDL_PARSER_H

#include "lexer.h"

typedef struct Parser {
    Token *tokens;
    size_t current;
} Parser;

typedef enum NodeType {
    NODE_ERR,
    // NODE_FUNCALL,
    // NODE_U64,
    // NODE_U32,
    // NODE_U16,
    // NODE_U8,
    // NODE_S64,
    // NODE_S32,
    // NODE_S16,
    // NODE_S8,
    NODE_NUMBER,
    NODE_STRING,
} NodeType;

typedef struct Node {
    NodeType type;

    union {
        // Numbers.
        struct {
            bool negative;
            u64 integral;
            u64 fractional;
        } number;

        // String.
        StringView string;
        // struct {
        //     u8 *str;
        //     u64 n;
        // } as_str;
    };
} Node;

void parse(Token *tokens);

#endif // BDL_PARSER_H