]> git.saurik.com Git - bison.git/blame_incremental - src/location.h
Credit Satya for the graphviz change.
[bison.git] / src / location.h
... / ...
CommitLineData
1/* Locations for Bison
2 Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
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
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21#ifndef LOCATION_H_
22# define LOCATION_H_
23
24# include "uniqstr.h"
25
26/* A boundary between two characters. */
27typedef struct
28{
29 /* The name of the file that contains the boundary. */
30 uniqstr file;
31
32 /* The (origin-1) line that contains the boundary.
33 If this is INT_MAX, the line number has overflowed. */
34 int line;
35
36 /* The (origin-1) column just after the boundary. This is neither a
37 byte count, nor a character count; it is a column count.
38 If this is INT_MAX, the column number has overflowed. */
39 int column;
40
41} boundary;
42
43/* Set the position of \a a. */
44static inline void
45boundary_set (boundary *b, const char *f, int l, int c)
46{
47 b->file = f;
48 b->line = l;
49 b->column = c;
50}
51
52/* Return nonzero if A and B are equal boundaries. */
53static inline bool
54equal_boundaries (boundary a, boundary b)
55{
56 return (a.column == b.column
57 && a.line == b.line
58 && UNIQSTR_EQ (a.file, b.file));
59}
60
61/* A location, that is, a region of source code. */
62typedef struct
63{
64 /* Boundary just before the location starts. */
65 boundary start;
66
67 /* Boundary just after the location ends. */
68 boundary end;
69
70} location;
71
72#define YYLTYPE location
73
74extern location const empty_location;
75
76/* Set *LOC and adjust scanner cursor to account for token TOKEN of
77 size SIZE. */
78void location_compute (location *loc,
79 boundary *cur, char const *token, size_t size);
80
81void location_print (FILE *out, location loc);
82
83#endif /* ! defined LOCATION_H_ */