-
Notifications
You must be signed in to change notification settings - Fork 0
/
location.h
47 lines (40 loc) · 1.33 KB
/
location.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*---------------------------------------------------------*
* This file just defines some basic structs and functions *
* to handle location-information, i.e. line no. and *
* column number in line. *
*---------------------------------------------------------*/
#ifndef YYLTYPE
/**
* a struct to represent lexical locations in the program.
*/
typedef struct yyltype {
int first_line, first_column; /**< beginning position */
int last_line, last_column; /**< ending position */
char *text; /**< the content at that location */
} yyltype;
#define YYLTYPE yyltype
extern struct yyltype yylloc;
/**
* Takes two locations and combines their span into one.
* @param first first location
* @param second second location
* @return combined location
*/
inline yyltype Join(yyltype first, yyltype second) {
yyltype combined;
combined.first_line = first.first_line;
combined.first_column = first.first_column;
combined.last_line = second.last_line;
combined.last_column = second.last_column;
return combined;
}
/**
* Combines two locations using pointers.
* @param first pointer to first location
* @param second pointer to second location
* @param combined location
*/
inline yyltype Join(yyltype *first, yyltype *second) {
return Join(*first,*second);
}
#endif