Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
lime_location.h
1#ifndef LIME_LOCATION_H
2#define LIME_LOCATION_H
3
4#include <stdint.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
16typedef struct LimeLocation {
17 uint32_t first_line;
18 uint32_t first_column;
19 uint32_t last_line;
20 uint32_t last_column;
21 const char *filename;
23
24/* Merge two locations: result spans from start of a to end of b */
25static inline LimeLocation lime_location_merge(LimeLocation a, LimeLocation b) {
26 LimeLocation result;
27 result.first_line = a.first_line;
28 result.first_column = a.first_column;
29 result.last_line = b.last_line;
30 result.last_column = b.last_column;
31 result.filename = a.filename;
32 return result;
33}
34
35/* Create a zero/empty location */
36static inline LimeLocation lime_location_none(void) {
37 LimeLocation loc = {0, 0, 0, 0, 0};
38 return loc;
39}
40
41#ifdef __cplusplus
42}
43#endif
44
45#endif /* LIME_LOCATION_H */
Source location tracking for Lime-generated parsers.
const char * filename
Borrowed filename pointer, or NULL.
uint32_t last_line
Last line of the span (1-based)
uint32_t first_column
First column of the span (1-based)
uint32_t first_line
First line of the span (1-based)
uint32_t last_column
Last column of the span (1-based)