-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.h
62 lines (50 loc) · 963 Bytes
/
token.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
58
59
60
61
62
#pragma once
enum token_type
{
token_number = 1,
token_symbol = 2,
token_group = 3,
token_string = 4,
token_quote = 5,
token_rparen = 6
};
struct token
{
enum token_type type;
struct token* next;
};
struct token__number
{
struct token _base;
number_t value;
};
struct token__symbol
{
struct token _base;
char* name;
};
struct token__string
{
struct token _base;
char* str;
};
struct token__group
{
struct token _base;
struct token** items;
int length;
};
struct token__quote
{
struct token _base;
struct token* token;
};
struct linked_list;
struct token* token_create_number (number_t value);
struct token* token_create_symbol (const char* name);
struct token* token_create_group (struct linked_list* items);
struct token* token_create_string (const char* s);
struct token* token_create_quote (struct token* t);
//void token_destroy (struct token* t);
#define token_destroy w_free
void token_display (struct token* t, int indent);