blob: c1ca3b88a781a8a8971de0dcbabda0695dd88432 (
plain)
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
27
28
29
30
31
32
33
|
#ifndef SAND_LOCATION_H
#define SAND_LOCATION_H
// This module defines the location type. It represents a reference to a span of
// source text. They are carried throughout the compiler so error messages can
// make useful references to the user's source code.
#include <stddef.h>
#include <stdio.h>
// Uniquely, the fields of this struct should be considered public, though
// still read-only.
//
// Internally, regardless of presentation, line and column numbers are
// 0-indexed for consistensy.
typedef struct {
const char *filename;
unsigned start_line;
unsigned start_column;
unsigned end_line;
unsigned end_column;
} SandLocation;
// Construct a new location which minimally encompasses both `a` and `b`.
// `a` must start before `b` ends.
// `a` and `b` must have the same `filename` (i.e. they obviously can't cross file boundaries).
SandLocation sand_location_encompassing(const SandLocation *a, const SandLocation *b);
// Print the location to the given stream.
// The output will not contain newlines.
void sand_print_location(FILE *, const SandLocation *);
#endif
|