]>
Commit | Line | Data |
---|---|---|
0c15323d | 1 | /* Locations for Bison |
a51d426a | 2 | Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
0c15323d AD |
3 | |
4 | This file is part of Bison, the GNU Compiler Compiler. | |
5 | ||
6 | Bison is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation; either version 2, or (at your option) | |
9 | any later version. | |
10 | ||
11 | Bison is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
17 | along with Bison; see the file COPYING. If not, write to | |
0fb669f9 PE |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. */ | |
0c15323d AD |
20 | |
21 | #ifndef LOCATION_H_ | |
22 | # define LOCATION_H_ | |
23 | ||
dca81a78 PE |
24 | # include "uniqstr.h" |
25 | ||
8f759107 PE |
26 | /* A boundary between two characters. */ |
27 | typedef struct | |
0c15323d | 28 | { |
8f759107 | 29 | /* The name of the file that contains the boundary. */ |
dca81a78 | 30 | uniqstr file; |
8f759107 | 31 | |
4517da37 PE |
32 | /* The (origin-1) line that contains the boundary. |
33 | If this is INT_MAX, the line number has overflowed. */ | |
8f759107 PE |
34 | int line; |
35 | ||
36 | /* The (origin-1) column just after the boundary. This is neither a | |
4517da37 PE |
37 | byte count, nor a character count; it is a column count. |
38 | If this is INT_MAX, the column number has overflowed. */ | |
8f759107 PE |
39 | int column; |
40 | ||
41 | } boundary; | |
42 | ||
43 | /* Return nonzero if A and B are equal boundaries. */ | |
44 | static inline bool | |
45 | equal_boundaries (boundary a, boundary b) | |
46 | { | |
47 | return (a.column == b.column | |
48 | && a.line == b.line | |
dca81a78 | 49 | && UNIQSTR_EQ (a.file, b.file)); |
8f759107 PE |
50 | } |
51 | ||
52 | /* A location, that is, a region of source code. */ | |
53 | typedef struct | |
54 | { | |
55 | /* Boundary just before the location starts. */ | |
56 | boundary start; | |
57 | ||
58 | /* Boundary just after the location ends. */ | |
59 | boundary end; | |
60 | ||
69b8cc09 | 61 | } location; |
8f759107 | 62 | |
69b8cc09 | 63 | #define YYLTYPE location |
0c15323d | 64 | |
69b8cc09 | 65 | extern location const empty_location; |
8f759107 | 66 | |
69b8cc09 | 67 | void location_print (FILE *, location); |
8f759107 PE |
68 | |
69 | #endif /* ! defined LOCATION_H_ */ |