]>
git.saurik.com Git - bison.git/blob - src/location.h
e8e591c9711ff470a0b34fc1349712140143e06c
2 Copyright (C) 2002, 2004-2010 Free Software Foundation, Inc.
4 This file is part of Bison, the GNU Compiler Compiler.
6 This program 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 3 of the License, or
9 (at your option) any later version.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* A boundary between two characters. */
27 /* The name of the file that contains the boundary. */
30 /* If nonnegative, the (origin-1) line that contains the boundary.
31 If this is INT_MAX, the line number has overflowed.
33 Meaningless and not displayed if negative.
37 /* If nonnegative, the (origin-1) column just after the boundary.
38 This is neither a byte count, nor a character count; it is a
39 column count. If this is INT_MAX, the column number has
42 Meaningless and not displayed if negative.
48 /* Set the position of \a a. */
50 boundary_set (boundary
*b
, const char *f
, int l
, int c
)
57 /* Return -1, 0, 1, depending whether a is before, equal, or
60 boundary_cmp (boundary a
, boundary b
)
62 int res
= strcmp (a
.file
, b
.file
);
64 res
= a
.line
- b
.line
;
66 res
= a
.column
- b
.column
;
70 /* Return nonzero if A and B are equal boundaries. */
72 equal_boundaries (boundary a
, boundary b
)
74 return (a
.column
== b
.column
76 && UNIQSTR_EQ (a
.file
, b
.file
));
79 /* A location, that is, a region of source code. */
82 /* Boundary just before the location starts. */
85 /* Boundary just after the location ends. */
90 #define YYLTYPE location
92 #define EMPTY_LOCATION_INIT {{NULL, 0, 0}, {NULL, 0, 0}}
93 extern location
const empty_location
;
95 /* Set *LOC and adjust scanner cursor to account for token TOKEN of
97 void location_compute (location
*loc
,
98 boundary
*cur
, char const *token
, size_t size
);
100 /* Print location to file. Return number of actually printed
102 unsigned location_print (FILE *out
, location loc
);
104 /* Return -1, 0, 1, depending whether a is before, equal, or
107 location_cmp (location a
, location b
)
109 int res
= boundary_cmp (a
.start
, b
.start
);
111 res
= boundary_cmp (a
.end
, b
.end
);
115 /* LOC_STR must be formatted as `file:line.column', it will be modified. */
116 void boundary_set_from_string (boundary
*bound
, char *loc_str
);
118 #endif /* ! defined LOCATION_H_ */