#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 #include // 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