1 #ifndef re2c_token_h
2 #define re2c_token_h
3
4 #include "substr.h"
5
6 typedef struct Token {
7 Str text;
8 unsigned int line;
9 } Token;
10
11 static void Token_init(Token *, SubStr, unsigned int);
12 static Token *Token_new(SubStr, unsigned int);
13
14 static void
Token_init(Token * r,SubStr t,unsigned int l)15 Token_init(Token *r, SubStr t, unsigned int l)
16 {
17 Str_copy(&r->text, &t);
18 r->line = l;
19 }
20
21 static Token *
Token_new(SubStr t,unsigned int l)22 Token_new(SubStr t, unsigned int l)
23 {
24 Token *r = malloc(sizeof(Token));
25 Str_init(&r->text, &t);
26 r->line = l;
27 return r;
28 }
29
30 #endif
31