Line |
Branch |
Exec |
Source |
1 |
|
|
#ifndef COMPILER_H |
2 |
|
|
#define COMPILER_H |
3 |
|
|
|
4 |
|
|
#include <regex.h> |
5 |
|
|
#include <stdbool.h> |
6 |
|
|
#include <stdint.h> |
7 |
|
|
#include <sys/types.h> |
8 |
|
|
#include "util/hashmap.h" |
9 |
|
|
#include "util/macros.h" |
10 |
|
|
#include "util/ptr-array.h" |
11 |
|
|
#include "util/string.h" |
12 |
|
|
|
13 |
|
|
enum { |
14 |
|
|
ERRORFMT_CAPTURE_MAX = 16 |
15 |
|
|
}; |
16 |
|
|
|
17 |
|
|
enum { |
18 |
|
|
ERRFMT_FILE, |
19 |
|
|
ERRFMT_LINE, |
20 |
|
|
ERRFMT_COLUMN, |
21 |
|
|
ERRFMT_MESSAGE, |
22 |
|
|
NR_ERRFMT_INDICES |
23 |
|
|
}; |
24 |
|
|
|
25 |
|
|
typedef struct { |
26 |
|
|
int8_t capture_index[NR_ERRFMT_INDICES]; |
27 |
|
|
bool ignore; |
28 |
|
|
const char *pattern; // Original pattern string (interned) |
29 |
|
|
regex_t re; // Compiled pattern |
30 |
|
|
} ErrorFormat; |
31 |
|
|
|
32 |
|
|
typedef struct { |
33 |
|
|
PointerArray error_formats; |
34 |
|
|
} Compiler; |
35 |
|
|
|
36 |
|
163 |
static inline Compiler *find_compiler(const HashMap *compilers, const char *name) |
37 |
|
|
{ |
38 |
|
163 |
return hashmap_get(compilers, name); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
void remove_compiler(HashMap *compilers, const char *name) NONNULL_ARGS; |
42 |
|
|
void free_compiler(Compiler *c) NONNULL_ARGS; |
43 |
|
|
ssize_t errorfmt_capture_name_to_index(const char *name) NONNULL_ARGS WARN_UNUSED_RESULT; |
44 |
|
|
void collect_errorfmt_capture_names(PointerArray *a, const char *prefix) NONNULL_ARGS; |
45 |
|
|
void dump_compiler(const Compiler *c, const char *name, String *s) NONNULL_ARGS; |
46 |
|
|
|
47 |
|
|
NONNULL_ARGS |
48 |
|
|
void add_error_fmt ( |
49 |
|
|
HashMap *compilers, |
50 |
|
|
const char *name, |
51 |
|
|
const char *pattern, |
52 |
|
|
regex_t *re, // Takes ownership |
53 |
|
|
int8_t idx[NR_ERRFMT_INDICES], |
54 |
|
|
bool ignore |
55 |
|
|
); |
56 |
|
|
|
57 |
|
|
#endif |
58 |
|
|
|