-
Notifications
You must be signed in to change notification settings - Fork 0
/
token.h
54 lines (47 loc) · 1.17 KB
/
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
#ifndef CIAPOS_TOKEN_H
#define CIAPOS_TOKEN_H
#include <stdint.h>
#include "unicode.h"
#include "lexutil.h"
typedef struct ciapos_token {
enum {
CIAPOS_TOKSYM, // ex: foo
CIAPOS_TOKINT, // ex: 54
CIAPOS_TOKREAL, // ex: 3.14
CIAPOS_TOKSTR, // ex: "foo bar"
CIAPOS_TOKBEG, // ex: (
CIAPOS_TOKEND, // ex: )
CIAPOS_TOKDOT, // .
CIAPOS_TOKQUOT, // '
CIAPOS_TOKQQUOT, // `
CIAPOS_TOKUQUOT, // ,
CIAPOS_TOKSQUOT // ,@
} tag;
int line;
int col;
int fileid;
union {
char *symbol;
int64_t integer;
double real;
char *string;
ciapos_codepoint *bracket;
};
} ciapos_token;
typedef struct ciapos_tokengen {
int state;
int fileid;
int line;
int col;
int readerid;
ciapos_codepoint *probe;
ciapos_graphemerewinder src;
} ciapos_tokengen;
void ciapos_tokengen_init(
ciapos_tokengen *lexer,
ciapos_graphemegen *src,
int fileid);
void ciapos_tokengen_deinit(ciapos_tokengen *lexer);
int ciapos_tokengen_next(ciapos_tokengen *lexer, ciapos_token *token);
void ciapos_token_deinit(ciapos_token *token);
#endif