| 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
|
2573
|
|
|
|
|
|
tokens_grow(token_pos_t **token_ptr, int *token_lim_ptr, bool tokens_on_heap) |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
2573
|
|
|
|
|
|
int new_lim = *token_lim_ptr; |
|
33
|
2573
|
50
|
|
|
|
|
if (new_lim < 4) |
|
34
|
0
|
|
|
|
|
|
new_lim = 4; |
|
35
|
2573
|
|
|
|
|
|
new_lim *= 2; |
|
36
|
|
|
|
|
|
|
|
|
37
|
2573
|
100
|
|
|
|
|
if (tokens_on_heap) { |
|
38
|
1176
|
50
|
|
|
|
|
Renew(*token_ptr, new_lim, token_pos_t); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
|
|
|
|
|
|
token_pos_t *new_tokens; |
|
42
|
|
|
|
|
|
|
int i; |
|
43
|
1397
|
50
|
|
|
|
|
New(57, new_tokens, new_lim, token_pos_t); |
|
44
|
22517
|
100
|
|
|
|
|
for (i = 0; i < *token_lim_ptr; i++) |
|
45
|
21120
|
|
|
|
|
|
new_tokens[i] = (*token_ptr)[i]; |
|
46
|
1397
|
|
|
|
|
|
*token_ptr = new_tokens; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
2573
|
|
|
|
|
|
*token_lim_ptr = new_lim; |
|
49
|
2573
|
|
|
|
|
|
} |