mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 22:33:03 +00:00
Equip the skeleton chain with location tracking, runtime trace,
pure parser and scanner. * src/parse-skel.y: Request a pure parser, locations, and prefix renaming. (%union): Having several members with the same type does not help type mismatches, simplify. (YYPRINT, yyprint): New. (yyerror): ``Rename'' (there is a #define yyerror skel_error) as... (skel_error): this. Handle locations. * src/scan-skel.l: Adjust to these changes. * src/skeleton.h (LOCATION_RESET, LOCATION_LINES, LOCATION_STEP) (LOCATION_PRINT, skel_control_t): New.
This commit is contained in:
@@ -21,12 +21,56 @@
|
||||
#ifndef SKELETON_H_
|
||||
# define SKELETON_H_
|
||||
|
||||
/* From parse-skel.y. */
|
||||
# include "parse-skel.h"
|
||||
|
||||
/* Initialize LOC. */
|
||||
# define LOCATION_RESET(Loc) \
|
||||
(Loc).first_column = (Loc).first_line = 1; \
|
||||
(Loc).last_column = (Loc).last_line = 1;
|
||||
|
||||
/* Advance of NUM lines. */
|
||||
# define LOCATION_LINES(Loc, Num) \
|
||||
(Loc).last_column = 1; \
|
||||
(Loc).last_line += Num;
|
||||
|
||||
/* Restart: move the first cursor to the last position. */
|
||||
# define LOCATION_STEP(Loc) \
|
||||
(Loc).first_column = (Loc).last_column; \
|
||||
(Loc).first_line = (Loc).last_line;
|
||||
|
||||
/* Output LOC on the stream OUT. */
|
||||
# define LOCATION_PRINT(Out, Loc) \
|
||||
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)
|
||||
|
||||
|
||||
/* Pure parsers need to pass arguments to yyparse. */
|
||||
typedef struct skel_control_s
|
||||
{
|
||||
/* For the time being, nothing. */
|
||||
} skel_control_t;
|
||||
|
||||
/* From parse-skel.y. */
|
||||
extern int skel_debug;
|
||||
void skel_error PARAMS ((skel_control_t *control,
|
||||
const yyltype *loc, const char *msg));
|
||||
void process_skeleton PARAMS ((const char* skel));
|
||||
|
||||
/* From scan-skel.l. */
|
||||
extern int skel__flex_debug;
|
||||
|
||||
/* Renamed yyin. */
|
||||
extern FILE* skel_in;
|
||||
|
||||
# define YY_DECL \
|
||||
int yylex PARAMS ((void))
|
||||
int skel_lex PARAMS ((yystype *yylval, yyltype *yylloc))
|
||||
YY_DECL;
|
||||
|
||||
#endif SKELETON_H_
|
||||
|
||||
Reference in New Issue
Block a user