-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtokenizer.h
More file actions
33 lines (27 loc) · 717 Bytes
/
tokenizer.h
File metadata and controls
33 lines (27 loc) · 717 Bytes
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
#ifndef LIZARD_TOKENIZER_H
#define LIZARD_TOKENIZER_H
#include "lizard.h"
typedef enum {
TOKEN_LEFT_PAREN,
TOKEN_RIGHT_PAREN,
TOKEN_SYMBOL,
TOKEN_NUMBER,
TOKEN_STRING
} lizard_token_type_t;
typedef struct lizard_token {
lizard_token_type_t type;
union {
char *string;
char *symbol;
mpz_t number;
} data;
} lizard_token_t;
typedef struct lizard_token_list_node {
list_node_t node;
lizard_token_t token;
} lizard_token_list_node_t;
bool lizard_is_digit(const char *input, int i);
void lizard_add_token(list_t *list, lizard_token_type_t token_type, char *data);
list_t *lizard_tokenize(const char *input);
void lizard_free_tokens(list_t *token_list);
#endif /* LIZARD_TOKENIZER_H */