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
37 # define YYRHSLOC(Rhs, K) ((Rhs)[K])
39 #ifndef YYLLOC_DEFAULT
40 # define YYLLOC_DEFAULT(Current, Rhs, N) \
44 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
45 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
46 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
47 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
48 (Current).file = YYRHSLOC (Rhs, 1).file; \
52 (Current).first_line = (Current).last_line = \
53 YYRHSLOC (Rhs, 0).last_line; \
54 (Current).first_column = (Current).last_column = \
55 YYRHSLOC (Rhs, 0).last_column; \
56 (Current).file = YYRHSLOC (Rhs, 0).file; \
61 const char *yy_current_filename();
63 typedef struct YYLTYPE location
;
66 # define LOCATION_RESET(Loc) \
67 (Loc).first_column = (Loc).first_line = 1; \
68 (Loc).last_column = (Loc).last_line = 1; \
69 (Loc).file = yy_current_filename();
71 /* Advance of NUM lines. */
72 # define LOCATION_LINES(Loc, Num) \
73 (Loc).last_column = 1; \
74 (Loc).last_line += Num; \
75 (Loc).file = (Loc).file;
77 /* Restart: move the first cursor to the last position. */
78 # define LOCATION_STEP(Loc) \
79 (Loc).first_column = (Loc).last_column; \
80 (Loc).first_line = (Loc).last_line; \
81 (Loc).file = (Loc).file;
83 /* Output LOC on the stream OUT. */
84 # define LOCATION_PRINT(Out, Loc) \
85 fprintf (Out, "%d", (Loc).first_line)
87 # define LOCATION_PRINT(Out, Loc) \
88 if ((Loc).first_line != (Loc).last_line) \
89 fprintf (Out, "%d.%d-%d.%d", \
90 (Loc).first_line, (Loc).first_column, \
91 (Loc).last_line, (Loc).last_column - 1); \
92 else if ((Loc).first_column < (Loc).last_column - 1) \
93 fprintf (Out, "%d.%d-%d", (Loc).first_line, \
94 (Loc).first_column, (Loc).last_column - 1); \
96 fprintf (Out, "%d.%d", (Loc).first_line, (Loc).first_column)