line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
struct token_pos |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
char *beg; |
4
|
|
|
|
|
|
|
char *end; |
5
|
|
|
|
|
|
|
}; |
6
|
|
|
|
|
|
|
typedef struct token_pos token_pos_t; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#define dTOKENS(init_lim) \ |
9
|
|
|
|
|
|
|
token_pos_t token_buf[init_lim]; \ |
10
|
|
|
|
|
|
|
int token_lim = init_lim; \ |
11
|
|
|
|
|
|
|
token_pos_t *tokens = token_buf; \ |
12
|
|
|
|
|
|
|
int num_tokens = 0 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#define PUSH_TOKEN(p_beg, p_end) \ |
15
|
|
|
|
|
|
|
STMT_START { \ |
16
|
|
|
|
|
|
|
++num_tokens; \ |
17
|
|
|
|
|
|
|
if (num_tokens == token_lim) \ |
18
|
|
|
|
|
|
|
tokens_grow(&tokens, &token_lim, (bool)(tokens != token_buf)); \ |
19
|
|
|
|
|
|
|
tokens[num_tokens-1].beg = p_beg; \ |
20
|
|
|
|
|
|
|
tokens[num_tokens-1].end = p_end; \ |
21
|
|
|
|
|
|
|
} STMT_END |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#define FREE_TOKENS \ |
24
|
|
|
|
|
|
|
STMT_START { \ |
25
|
|
|
|
|
|
|
if (tokens != token_buf) \ |
26
|
|
|
|
|
|
|
Safefree(tokens); \ |
27
|
|
|
|
|
|
|
} STMT_END |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
static void |
30
|
2462
|
|
|
|
|
|
tokens_grow(token_pos_t **token_ptr, int *token_lim_ptr, bool tokens_on_heap) |
31
|
|
|
|
|
|
|
{ |
32
|
2462
|
|
|
|
|
|
int new_lim = *token_lim_ptr; |
33
|
2462
|
50
|
|
|
|
|
if (new_lim < 4) |
34
|
0
|
|
|
|
|
|
new_lim = 4; |
35
|
2462
|
|
|
|
|
|
new_lim *= 2; |
36
|
|
|
|
|
|
|
|
37
|
2462
|
100
|
|
|
|
|
if (tokens_on_heap) { |
38
|
1166
|
50
|
|
|
|
|
Renew(*token_ptr, new_lim, token_pos_t); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { |
41
|
|
|
|
|
|
|
token_pos_t *new_tokens; |
42
|
|
|
|
|
|
|
int i; |
43
|
1296
|
50
|
|
|
|
|
New(57, new_tokens, new_lim, token_pos_t); |
44
|
20800
|
100
|
|
|
|
|
for (i = 0; i < *token_lim_ptr; i++) |
45
|
19504
|
|
|
|
|
|
new_tokens[i] = (*token_ptr)[i]; |
46
|
1296
|
|
|
|
|
|
*token_ptr = new_tokens; |
47
|
|
|
|
|
|
|
} |
48
|
2462
|
|
|
|
|
|
*token_lim_ptr = new_lim; |
49
|
2462
|
|
|
|
|
|
} |