the hito embeddable programming language
1#ifndef source_h
2#define source_h
3#include <stddef.h>
4
5typedef struct source source_t;
6typedef struct {
7 int line; int col; size_t idx;
8} pos_t;
9
10source_t *source_alloc_from_file(char* file_name);
11
12// takes ownership of the file contents string.
13source_t *source_alloc(const char* file_name, char* contents);
14
15pos_t source_next_pos(source_t *source, pos_t pos);
16
17void source_print_pos(source_t *source, pos_t pos);
18
19void source_print_line(source_t *source, pos_t pos, int highlight_len);
20
21const char* source_contents_from(source_t* source, pos_t pos);
22
23void source_dealloc(source_t* source);
24#endif