-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocation.h
79 lines (66 loc) · 2.05 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/***********************************************************************\
*
* Contents: scanner location tracking
* Systems: all
*
\***********************************************************************/
#ifndef __LOCATION__
#define __LOCATION__
/****************************** Includes *******************************/
#include <stdlib.h>
#include <stdint.h>
/****************** Conditional compilation switches *******************/
/***************************** Constants *******************************/
#define YYLTYPE Location
#define YYLTYPE_IS_DEFINED
#define YYLLOC_DEFAULT(location, rhs, n) \
do \
{ \
if (n == 0) \
{ \
(location).first.line = YYRHSLOC(rhs, 0).last.line; \
(location).first.column = YYRHSLOC(rhs, 0).last.column; \
(location).last.line = YYRHSLOC(rhs, 0).last.line; \
(location).last.column = YYRHSLOC(rhs, 0).last.column; \
} \
else \
{ \
(location).first.line = YYRHSLOC(rhs, 1).first.line; \
(location).first.column = YYRHSLOC(rhs, 1).first.column; \
(location).last.line = YYRHSLOC(rhs, n).last.line; \
(location).last.column = YYRHSLOC(rhs, n).last.column; \
} \
} while (0)
/***************************** Datatypes *******************************/
class Location
{
public:
struct
{
size_t line;
size_t column;
} first;
struct
{
size_t line;
size_t column;
} last;
Location(size_t firstLine,
size_t firstColumn,
size_t lastLine,
size_t lastColumn
)
{
first.line = firstLine;
first.column = firstColumn;
last.line = lastLine;
last.column = lastColumn;
}
Location() = default;
};
/***************************** Variables *******************************/
/***************************** Forwards ********************************/
/****************************** Macros *********************************/
/***************************** Functions *******************************/
#endif // __LOCATION__
/* end of file */