2 * $Id: loc.h,v 1.3 2007/08/10 20:21:26 khansen Exp $
4 * Revision 1.3 2007/08/10 20:21:26 khansen
5 * *** empty log message ***
7 * Revision 1.2 2007/07/22 13:35:20 khansen
8 * convert tabs to whitespaces
10 * Revision 1.1 2004/06/30 07:56:29 kenth
16 * Definitions for flex location tracking.
22 #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
23 typedef struct YYLTYPE
31 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
32 # define YYLTYPE_IS_DECLARED 1
33 # define YYLTYPE_IS_TRIVIAL 1
36 #ifndef YYLLOC_DEFAULT
37 # define YYLLOC_DEFAULT(Current, Rhs, N) \
38 Current.first_line = Rhs[1].first_line; \
39 Current.first_column = Rhs[1].first_column; \
40 Current.last_line = Rhs[N].last_line; \
41 Current.last_column = Rhs[N].last_column; \
42 Current.file = Rhs[1].file;
45 const char *yy_current_filename();
47 typedef struct YYLTYPE location
;
50 # define LOCATION_RESET(Loc) \
51 (Loc).first_column = (Loc).first_line = 1; \
52 (Loc).last_column = (Loc).last_line = 1; \
53 (Loc).file = yy_current_filename();
55 /* Advance of NUM lines. */
56 # define LOCATION_LINES(Loc, Num) \
57 (Loc).last_column = 1; \
58 (Loc).last_line += Num; \
59 (Loc).file = (Loc).file;
61 /* Restart: move the first cursor to the last position. */
62 # define LOCATION_STEP(Loc) \
63 (Loc).first_column = (Loc).last_column; \
64 (Loc).first_line = (Loc).last_line; \
65 (Loc).file = (Loc).file;
67 /* Output LOC on the stream OUT. */
68 # define LOCATION_PRINT(Out, Loc) \
69 fprintf (Out, "%d", (Loc).first_line)
71 # define LOCATION_PRINT(Out, Loc) \
72 if ((Loc).first_line != (Loc).last_line) \
73 fprintf (Out, "%d.%d-%d.%d", \
74 (Loc).first_line, (Loc).first_column, \
75 (Loc).last_line, (Loc).last_column - 1); \
76 else if ((Loc).first_column < (Loc).last_column - 1) \
77 fprintf (Out, "%d.%d-%d", (Loc).first_line, \
78 (Loc).first_column, (Loc).last_column - 1); \
80 fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column)