From 437c2d80006f7c4729cffd329c106de50dbd4acc Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 6 Nov 2002 14:11:47 +0000 Subject: [PATCH] Restore --no-lines. Reported by Jim Kent. * data/c.m4 (b4_syncline): New. * data/glr.c, data/yacc.c, data/lalr1.cc: Use it. * src/reader.c (prologue_augment, epilogue_set): Use b4_syncline. * src/output.c (user_actions_output): Likewise. (prepare): Define 'b4_synclines_flag'. --- ChangeLog | 11 +++++++++++ NEWS | 2 ++ THANKS | 1 + TODO | 10 ---------- data/c.m4 | 12 ++++++++++++ data/glr.c | 12 ++++++------ data/lalr1.cc | 10 +++++----- data/yacc.c | 16 ++++++++-------- src/muscle_tab.c | 6 ------ src/output.c | 14 +++++++------- src/reader.c | 20 ++++++-------------- 11 files changed, 58 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index 204e8960..71395e9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2002-11-06 Akim Demaille + + Restore --no-lines. + Reported by Jim Kent. + + * data/c.m4 (b4_syncline): New. + * data/glr.c, data/yacc.c, data/lalr1.cc: Use it. + * src/reader.c (prologue_augment, epilogue_set): Use b4_syncline. + * src/output.c (user_actions_output): Likewise. + (prepare): Define 'b4_synclines_flag'. + 2002-11-06 Akim Demaille * src/main.c (main): Free `infile'. diff --git a/NEWS b/NEWS index b0ec9fda..08bc9575 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ Changes in version 1.75b: * Bison now parses C99 lexical constructs like digraphs, UCNs, and backslash-newline within C escape sequences, as POSIX now requires. +* --no-line works properly. + Changes in version 1.75a, 2002-10-24: * Bison can no longer be built by a K&R C compiler; it requires C89 or diff --git a/THANKS b/THANKS index 2c59995e..3b731d18 100644 --- a/THANKS +++ b/THANKS @@ -25,6 +25,7 @@ H. Merijn Brand h.m.brand@hccnet.nl Hans Aberg haberg@matematik.su.se Jan Nieuwenhuizen janneke@gnu.org Jesse Thilo jthilo@gnu.org +Jim Kent jkent@arch.sel.sony.com Jim Meyering jim@meyering.net Juan Manuel Guerrero ST001906@HRZ1.HRZ.TU-Darmstadt.De Kees Zeelenberg kzlg@users.sourceforge.net diff --git a/TODO b/TODO index 0e3b95d9..7b4b7fd4 100644 --- a/TODO +++ b/TODO @@ -155,21 +155,11 @@ Paul notes: Show reductions. [] * Broken options ? -** %no-lines [ok] ** %no-parser [] -** %pure-parser [] ** %token-table [] -** Options which could use parse_dquoted_param (). -Maybe transferred in lex.c. -*** %skeleton [ok] -*** %output [] -*** %file-prefix [] -*** %name-prefix [] - ** Skeleton strategy. [] Must we keep %no-parser? %token-table? -*** New skeletons. [] * src/print_graph.c Find the best graph parameters. [] diff --git a/data/c.m4 b/data/c.m4 index 26171622..aafe2c7d 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -300,3 +300,15 @@ m4_define([b4_c_args], m4_define([b4_c_arg], [$2]) + + +## ----------- ## +## Synclines. ## +## ----------- ## + + +# b4_syncline(LINE, FILE) +# ----------------------- +m4_define([b4_syncline], +[m4_if(b4_synclines_flag, 1, + [[#]line $1 "$2"])]) diff --git a/data/glr.c b/data/glr.c index 6a18bcb9..daea8b99 100644 --- a/data/glr.c +++ b/data/glr.c @@ -195,10 +195,10 @@ b4_pre_prologue[ #ifndef YYSTYPE ]m4_ifdef([b4_stype], -[#line b4_stype_line "b4_filename" +[b4_syncline([b4_stype_line], [b4_filename]) typedef union b4_stype yystype; /* Line __line__ of __file__. */ -#line __oline__ "__ofile__"], +b4_syncline([__oline__], [__ofile__])], [typedef int yystype;])[ # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 @@ -228,7 +228,7 @@ static YYLTYPE yyloc_default; ]b4_post_prologue[ ]/* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) [ #if ! defined (__cplusplus) typedef char bool; @@ -656,7 +656,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp, # undef yyclearin # undef YYRECOVERING /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) } @@ -1906,10 +1906,10 @@ b4_token_defines(b4_tokens) #ifndef YYSTYPE m4_ifdef([b4_stype], -[#line b4_stype_line "b4_filename" +[b4_syncline([b4_stype_line], [b4_filename]) typedef union b4_stype yystype; /* Line __line__ of __file__. */ -#line __oline__ "__ofile__"], +b4_syncline([__oline__], [__ofile__])], [typedef int yystype;]) # define YYSTYPE yystype #endif diff --git a/data/lalr1.cc b/data/lalr1.cc index 8f3ebad8..9ab9a2cd 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -129,7 +129,7 @@ b4_token_defines(b4_tokens) b4_pre_prologue /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) /* Enabling traces. */ #ifndef YYDEBUG @@ -143,10 +143,10 @@ b4_pre_prologue #ifndef YYSTYPE m4_ifdef([b4_stype], -[#line b4_stype_line "b4_filename" +[b4_syncline([b4_stype_line], [b4_filename]) typedef union b4_stype yystype; /* Line __line__ of __file__. */ -#line __oline__ "__ofile__"], +b4_syncline([__oline__], [__ofile__])], [typedef int yystype;]) # define YYSTYPE yystype #endif @@ -155,7 +155,7 @@ typedef union b4_stype yystype; b4_post_prologue /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ Current.last_line = Rhs[[N]].last_line; \ @@ -463,7 +463,7 @@ yy::b4_parser_class_name::parse () } /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) state_stack_.pop (len_); semantic_stack_.pop (len_); diff --git a/data/yacc.c b/data/yacc.c index cd933733..c6045e20 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -165,9 +165,9 @@ m4_define([b4_symbol_actions], [m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl m4_pushdef([b4_at_dollar], [yylocation])dnl case $4: /* $3 */ -#line $2 "$1" +b4_syncline([$2], [$1]) $5; -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) break; m4_popdef([b4_at_dollar])dnl m4_popdef([b4_dollar_dollar])dnl @@ -229,10 +229,10 @@ b4_pre_prologue #ifndef YYSTYPE m4_ifdef([b4_stype], -[#line b4_stype_line "b4_filename" +[b4_syncline([b4_stype_line], [b4_filename]) typedef union b4_stype yystype; /* Line __line__ of __file__. */ -#line __oline__ "__ofile__"], +b4_syncline([__oline__], [__ofile__])], [typedef int yystype;]) # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 @@ -254,7 +254,7 @@ typedef struct yyltype b4_post_prologue /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -1053,7 +1053,7 @@ yyreduce: } /* Line __line__ of __file__. */ -#line __oline__ "__ofile__" +b4_syncline([__oline__], [__ofile__]) [ yyvsp -= yylen; yyssp -= yylen; @@ -1290,10 +1290,10 @@ b4_token_defines(b4_tokens) #ifndef YYSTYPE m4_ifdef([b4_stype], -[#line b4_stype_line "b4_filename" +[b4_syncline([b4_stype_line], [b4_filename]) typedef union b4_stype yystype; /* Line __line__ of __file__. */ -#line __oline__ "__ofile__"], +b4_syncline([__oline__], [__ofile__])], [typedef int yystype;]) # define YYSTYPE yystype #endif diff --git a/src/muscle_tab.c b/src/muscle_tab.c index b86c09bd..d5f39f42 100644 --- a/src/muscle_tab.c +++ b/src/muscle_tab.c @@ -65,12 +65,6 @@ muscle_init (void) /* Version and input file. */ MUSCLE_INSERT_STRING ("version", VERSION); MUSCLE_INSERT_STRING ("filename", infile); - - /* FIXME: there should probably be no default here, only in the - skeletons. */ - - /* Default #line formatting. */ - MUSCLE_INSERT_STRING ("linef", "#line %d %s\n"); } diff --git a/src/output.c b/src/output.c index d13e51f2..f115bd2f 100644 --- a/src/output.c +++ b/src/output.c @@ -276,11 +276,10 @@ user_actions_output (FILE *out) { fprintf (out, " case %d:\n", r + 1); - if (!no_lines_flag) - fprintf (out, muscle_find ("linef"), - rules[r].action_location.first_line, - quotearg_style (c_quoting_style, - rules[r].action_location.file)); + fprintf (out, "]b4_syncline([[%d]], [[%s]])[\n", + rules[r].action_location.first_line, + quotearg_style (escape_quoting_style, + rules[r].action_location.file)); fprintf (out, " %s\n break;\n\n", rules[r].action); } @@ -566,11 +565,12 @@ static void prepare (void) { /* Flags. */ - MUSCLE_INSERT_INT ("locations_flag", locations_flag); + MUSCLE_INSERT_INT ("debug", debug_flag); MUSCLE_INSERT_INT ("defines_flag", defines_flag); MUSCLE_INSERT_INT ("error_verbose", error_verbose); + MUSCLE_INSERT_INT ("locations_flag", locations_flag); MUSCLE_INSERT_INT ("pure", pure_parser); - MUSCLE_INSERT_INT ("debug", debug_flag); + MUSCLE_INSERT_INT ("synclines_flag", !no_lines_flag); /* FIXME: This is wrong: the muscles should decide whether they hold a copy or not, but the situation is too obscure currently. */ diff --git a/src/reader.c b/src/reader.c index 1c145c1f..e85b0420 100644 --- a/src/reader.c +++ b/src/reader.c @@ -69,13 +69,9 @@ prologue_augment (const char *prologue, location_t location) struct obstack *oout = !typed ? &pre_prologue_obstack : &post_prologue_obstack; - if (!no_lines_flag) - { - obstack_fgrow2 (oout, muscle_find ("linef"), - location.first_line, - quotearg_style (c_quoting_style, - location.file)); - } + obstack_fgrow2 (oout, "]b4_syncline([[%d]], [[%s]])[\n", + location.first_line, + quotearg_style (escape_quoting_style, location.file)); obstack_sgrow (oout, prologue); } @@ -89,13 +85,9 @@ prologue_augment (const char *prologue, location_t location) void epilogue_set (const char *epilogue, location_t location) { - if (!no_lines_flag) - { - obstack_fgrow2 (&muscle_obstack, muscle_find ("linef"), - location.first_line, - quotearg_style (c_quoting_style, - location.file)); - } + obstack_fgrow2 (&muscle_obstack, "]b4_syncline([[%d]], [[%s]])[\n", + location.first_line, + quotearg_style (escape_quoting_style, location.file)); obstack_sgrow (&muscle_obstack, epilogue); obstack_1grow (&muscle_obstack, 0); muscle_insert ("epilogue", obstack_finish (&muscle_obstack)); -- 2.45.2