1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef UTILS_LOC_H
#define UTILS_LOC_H

#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>

struct Pos
{
    size_t line, col;
};

struct Loc
{
    struct Pos begin, end;
    const char *filename;
};

extern struct Loc nullLoc;

struct Loc combineLoc(struct Loc loc0, struct Loc loc1);

void fprintfLoc(FILE *out, const struct Loc *loc, const char *fmt, ...);
void vfprintfLoc(FILE *out, const struct Loc *loc, const char *fmt, va_list ap);

#endif // UTILS_LOC_H