e3f7c5f2d350d9cbbbd439338e744cf267ed2339
[m6w6/ext-psi] / idl / lexer.h
1 #define BSIZE 256
2
3 typedef int token_t;
4 typedef unsigned char text;
5
6 typedef struct PSI_Token {
7 token_t type;
8 unsigned line;
9 text text[1];
10 } PSI_Token;
11
12 typedef struct impl impl;
13 typedef struct decl decl;
14
15 typedef struct PSI_Lexer {
16 FILE *fp;
17 char *fn;
18 struct {
19 size_t count;
20 decl **list;
21 } decl;
22 struct {
23 size_t count;
24 impl **list;
25 } impl;
26 size_t line;
27 text *cur, *tok, *lim, *eof, *ctx, *mrk, buf[BSIZE];
28 } PSI_Lexer;
29
30 PSI_Lexer *PSI_LexerInit(PSI_Lexer *L, const char *filename);
31 size_t PSI_LexerFill(PSI_Lexer *L, size_t n);
32 token_t PSI_LexerScan(PSI_Lexer *L);
33 void PSI_LexerDtor(PSI_Lexer *L);
34 void PSI_LexerFree(PSI_Lexer **L);
35
36 PSI_Token *PSI_TokenAlloc(PSI_Lexer *L, token_t t);