-
Notifications
You must be signed in to change notification settings - Fork 2
/
lex.h
45 lines (37 loc) · 879 Bytes
/
lex.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
#pragma once
#include <stdbool.h>
#include "atom.h"
#include "str.h"
#include "parse.h"
#define TOK_NOTHING 0
struct location {
int line_num;
};
struct token {
int type;
union {
char char_value;
int64_t int64_value;
double float_value;
struct str *string_value;
atom atom_value;
};
struct location location;
};
struct lexer { /* private */
int cs, act;
char *p, *pe, *eof;
char *ts, *te;
struct location location;
int radix;
struct {
bool negate_p;
int64_t value;
} i;
};
#include <stdbool.h>
extern void lex_init(struct lexer *);
extern void lex_setup_next_line(struct lexer *, char *, size_t, bool);
extern bool lex(struct lexer *, struct token *);
extern void destroy_token(struct token *);
extern bool pretty_print_token(void *, struct token *);