Used Variables instead of Options, in SConstruct
[mcc.git] / scanner.h
blobdf067e8b3e635cb94af9243ccf44146214e12c41
1 #ifndef MCC_SCANNER_H
2 #define MCC_SCANNER_H
4 #include "cpp.h"
6 typedef int tok_t;
8 #define IDENT_HASH_SIZE 64
10 struct ident {
11 struct ident *hash_prev;
12 tok_t tok;
13 char str[1];
16 struct token {
17 tok_t tok;
18 char *tok_str;
19 int tok_str_len;
20 struct sloc tok_sloc;
23 struct lexer {
24 struct cpp cpp;
25 char *pch;
26 struct token tok;
27 struct token next_tok; // tok pushed with lex_unget_tok
28 int next_ident_tok;
29 struct ident *ident_hashtab[IDENT_HASH_SIZE];
32 void token_dup(struct token *src, struct token *dest);
33 void token_free(struct token *token);
35 void lex_create(struct lexer *lex);
36 void lex_delete(struct lexer *lex);
37 void lex_next(struct lexer *lex);
38 void lex_unget_tok(struct lexer *lex, struct token *token);
39 char *lex_get_tok_str(struct lexer *lex, tok_t tok, char *tok_str);
40 void lex_start(struct lexer *lex);
41 bool lex_is_ident(struct lexer *lex, tok_t tok);
43 // Token numbers
44 #include "tokens.inc"
45 enum {
46 TOK_FIRSTK = 0x200,
47 #define DEF(x) TOK_ ## x,
48 #include "tokens.inc"
49 #undef DEF
50 TOK_LASTK,
52 enum {
53 TOK_FIRST_PUNCT = 0x100,
54 #define PUNCT(x, str) TOK_ ## x,
55 #include "tokens.inc"
56 #undef PUNCT
57 TOK_LAST_PUNCT,
60 #endif