/[bison]/bison/src/location.h
ViewVC logotype

Diff of /bison/src/location.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by akim, Tue Nov 12 08:30:47 2002 UTC revision 1.7 by eggert, Sat Dec 7 05:58:38 2002 UTC
# Line 1  Line 1 
1  /* Locations for Bison  /* Locations for Bison
2     Copyright (C) 2002  Free Software Foundation, Inc.     Copyright (C) 2002 Free Software Foundation, Inc.
3    
4     This file is part of Bison, the GNU Compiler Compiler.     This file is part of Bison, the GNU Compiler Compiler.
5    
# Line 20  Line 20 
20    
21  #ifndef LOCATION_H_  #ifndef LOCATION_H_
22  # define LOCATION_H_  # define LOCATION_H_
 # include "quotearg.h"  
23    
24  typedef struct location_s  /* A boundary between two characters.  */
25    typedef struct
26  {  {
27    const char *file;    /* The name of the file that contains the boundary.  */
28    int first_line;    char const *file;
29    int first_column;  
30    int last_line;    /* The (origin-1) line that contains the boundary.  */
31    int last_column;    int line;
32  }  location_t;  
33  #define YYLTYPE location_t    /* The (origin-1) column just after the boundary.  This is neither a
34         byte count, nor a character count; it is a column count.  */
35      int column;
36    
37    } boundary;
38    
39    /* Return nonzero if A and B are equal boundaries.  */
40    static inline bool
41    equal_boundaries (boundary a, boundary b)
42    {
43      return (a.column == b.column
44              && a.line == b.line
45              && a.file == b.file);
46    }
47    
48  /* Initialize LOC. */  /* A location, that is, a region of source code.  */
49  # define LOCATION_RESET(Loc)                    \  typedef struct
50  do {                                            \  {
51    (Loc).file = NULL;                            \    /* Boundary just before the location starts.  */
52    (Loc).first_column = (Loc).first_line = 1;    \    boundary start;
53    (Loc).last_column =  (Loc).last_line = 1;     \  
54  } while (0)    /* Boundary just after the location ends.  */
55      boundary end;
56    
57  /* Restart: move the first cursor to the last position. */  } location_t;
58  # define LOCATION_STEP(Loc)                     \  
59  do {                                            \  #define YYLTYPE location_t
   (Loc).first_column = (Loc).last_column;       \  
   (Loc).first_line = (Loc).last_line;           \  
 } while (0)  
   
   
 /* Output LOC on the stream OUT.  
    Warning: it uses quotearg's slot 3.  */  
 # define LOCATION_PRINT(Out, Loc)                                       \  
 do {                                                                    \  
   fprintf (stderr, "%s:", quotearg_n_style (3, escape_quoting_style,    \  
                                             (Loc).file));               \  
   if ((Loc).first_line)                                                 \  
     {                                                                   \  
       if ((Loc).first_line != (Loc).last_line)                          \  
         fprintf (Out, "%d.%d-%d.%d",                                    \  
                  (Loc).first_line, (Loc).first_column,                  \  
                  (Loc).last_line, (Loc).last_column - 1);               \  
       else if ((Loc).first_column < (Loc).last_column - 1)              \  
         fprintf (Out, "%d.%d-%d", (Loc).first_line,                     \  
                  (Loc).first_column, (Loc).last_column - 1);            \  
       else                                                              \  
         fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column);   \  
   }                                                                     \  
 } while (0)  
60    
61    extern location_t const empty_location;
62    
63  extern location_t empty_location;  void location_print (FILE *, location_t);
64    
65  #endif /* !LOCATION_H_ */  #endif /* ! defined LOCATION_H_ */

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26