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'.
This commit is contained in:
Akim Demaille
2002-11-06 14:11:47 +00:00
parent 900c5db537
commit 437c2d8000
11 changed files with 58 additions and 56 deletions

View File

@@ -1,3 +1,14 @@
2002-11-06 Akim Demaille <akim@epita.fr>
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 <akim@epita.fr> 2002-11-06 Akim Demaille <akim@epita.fr>
* src/main.c (main): Free `infile'. * src/main.c (main): Free `infile'.

2
NEWS
View File

@@ -6,6 +6,8 @@ Changes in version 1.75b:
* Bison now parses C99 lexical constructs like digraphs, UCNs, and * Bison now parses C99 lexical constructs like digraphs, UCNs, and
backslash-newline within C escape sequences, as POSIX now requires. backslash-newline within C escape sequences, as POSIX now requires.
* --no-line works properly.
Changes in version 1.75a, 2002-10-24: Changes in version 1.75a, 2002-10-24:
* Bison can no longer be built by a K&R C compiler; it requires C89 or * Bison can no longer be built by a K&R C compiler; it requires C89 or

1
THANKS
View File

@@ -25,6 +25,7 @@ H. Merijn Brand h.m.brand@hccnet.nl
Hans Aberg haberg@matematik.su.se Hans Aberg haberg@matematik.su.se
Jan Nieuwenhuizen janneke@gnu.org Jan Nieuwenhuizen janneke@gnu.org
Jesse Thilo jthilo@gnu.org Jesse Thilo jthilo@gnu.org
Jim Kent jkent@arch.sel.sony.com
Jim Meyering jim@meyering.net Jim Meyering jim@meyering.net
Juan Manuel Guerrero ST001906@HRZ1.HRZ.TU-Darmstadt.De Juan Manuel Guerrero ST001906@HRZ1.HRZ.TU-Darmstadt.De
Kees Zeelenberg kzlg@users.sourceforge.net Kees Zeelenberg kzlg@users.sourceforge.net

10
TODO
View File

@@ -155,21 +155,11 @@ Paul notes:
Show reductions. [] Show reductions. []
* Broken options ? * Broken options ?
** %no-lines [ok]
** %no-parser [] ** %no-parser []
** %pure-parser []
** %token-table [] ** %token-table []
** Options which could use parse_dquoted_param ().
Maybe transferred in lex.c.
*** %skeleton [ok]
*** %output []
*** %file-prefix []
*** %name-prefix []
** Skeleton strategy. [] ** Skeleton strategy. []
Must we keep %no-parser? Must we keep %no-parser?
%token-table? %token-table?
*** New skeletons. []
* src/print_graph.c * src/print_graph.c
Find the best graph parameters. [] Find the best graph parameters. []

View File

@@ -300,3 +300,15 @@ m4_define([b4_c_args],
m4_define([b4_c_arg], m4_define([b4_c_arg],
[$2]) [$2])
## ----------- ##
## Synclines. ##
## ----------- ##
# b4_syncline(LINE, FILE)
# -----------------------
m4_define([b4_syncline],
[m4_if(b4_synclines_flag, 1,
[[#]line $1 "$2"])])

View File

@@ -195,10 +195,10 @@ b4_pre_prologue[
#ifndef YYSTYPE #ifndef YYSTYPE
]m4_ifdef([b4_stype], ]m4_ifdef([b4_stype],
[#line b4_stype_line "b4_filename" [b4_syncline([b4_stype_line], [b4_filename])
typedef union b4_stype yystype; typedef union b4_stype yystype;
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__"], b4_syncline([__oline__], [__ofile__])],
[typedef int yystype;])[ [typedef int yystype;])[
# define YYSTYPE yystype # define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
@@ -228,7 +228,7 @@ static YYLTYPE yyloc_default;
]b4_post_prologue[ ]b4_post_prologue[
]/* Line __line__ of __file__. */ ]/* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
[ [
#if ! defined (__cplusplus) #if ! defined (__cplusplus)
typedef char bool; typedef char bool;
@@ -656,7 +656,7 @@ yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
# undef yyclearin # undef yyclearin
# undef YYRECOVERING # undef YYRECOVERING
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
} }
@@ -1906,10 +1906,10 @@ b4_token_defines(b4_tokens)
#ifndef YYSTYPE #ifndef YYSTYPE
m4_ifdef([b4_stype], m4_ifdef([b4_stype],
[#line b4_stype_line "b4_filename" [b4_syncline([b4_stype_line], [b4_filename])
typedef union b4_stype yystype; typedef union b4_stype yystype;
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__"], b4_syncline([__oline__], [__ofile__])],
[typedef int yystype;]) [typedef int yystype;])
# define YYSTYPE yystype # define YYSTYPE yystype
#endif #endif

View File

@@ -129,7 +129,7 @@ b4_token_defines(b4_tokens)
b4_pre_prologue b4_pre_prologue
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@@ -143,10 +143,10 @@ b4_pre_prologue
#ifndef YYSTYPE #ifndef YYSTYPE
m4_ifdef([b4_stype], m4_ifdef([b4_stype],
[#line b4_stype_line "b4_filename" [b4_syncline([b4_stype_line], [b4_filename])
typedef union b4_stype yystype; typedef union b4_stype yystype;
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__"], b4_syncline([__oline__], [__ofile__])],
[typedef int yystype;]) [typedef int yystype;])
# define YYSTYPE yystype # define YYSTYPE yystype
#endif #endif
@@ -155,7 +155,7 @@ typedef union b4_stype yystype;
b4_post_prologue b4_post_prologue
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
#ifndef YYLLOC_DEFAULT #ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \ # define YYLLOC_DEFAULT(Current, Rhs, N) \
Current.last_line = Rhs[[N]].last_line; \ Current.last_line = Rhs[[N]].last_line; \
@@ -463,7 +463,7 @@ yy::b4_parser_class_name::parse ()
} }
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
state_stack_.pop (len_); state_stack_.pop (len_);
semantic_stack_.pop (len_); semantic_stack_.pop (len_);

View File

@@ -165,9 +165,9 @@ m4_define([b4_symbol_actions],
[m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl [m4_pushdef([b4_dollar_dollar], [yyvalue.$6])dnl
m4_pushdef([b4_at_dollar], [yylocation])dnl m4_pushdef([b4_at_dollar], [yylocation])dnl
case $4: /* $3 */ case $4: /* $3 */
#line $2 "$1" b4_syncline([$2], [$1])
$5; $5;
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
break; break;
m4_popdef([b4_at_dollar])dnl m4_popdef([b4_at_dollar])dnl
m4_popdef([b4_dollar_dollar])dnl m4_popdef([b4_dollar_dollar])dnl
@@ -229,10 +229,10 @@ b4_pre_prologue
#ifndef YYSTYPE #ifndef YYSTYPE
m4_ifdef([b4_stype], m4_ifdef([b4_stype],
[#line b4_stype_line "b4_filename" [b4_syncline([b4_stype_line], [b4_filename])
typedef union b4_stype yystype; typedef union b4_stype yystype;
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__"], b4_syncline([__oline__], [__ofile__])],
[typedef int yystype;]) [typedef int yystype;])
# define YYSTYPE yystype # define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
@@ -254,7 +254,7 @@ typedef struct yyltype
b4_post_prologue b4_post_prologue
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
#if ! defined (yyoverflow) || YYERROR_VERBOSE #if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -1053,7 +1053,7 @@ yyreduce:
} }
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__" b4_syncline([__oline__], [__ofile__])
[ yyvsp -= yylen; [ yyvsp -= yylen;
yyssp -= yylen; yyssp -= yylen;
@@ -1290,10 +1290,10 @@ b4_token_defines(b4_tokens)
#ifndef YYSTYPE #ifndef YYSTYPE
m4_ifdef([b4_stype], m4_ifdef([b4_stype],
[#line b4_stype_line "b4_filename" [b4_syncline([b4_stype_line], [b4_filename])
typedef union b4_stype yystype; typedef union b4_stype yystype;
/* Line __line__ of __file__. */ /* Line __line__ of __file__. */
#line __oline__ "__ofile__"], b4_syncline([__oline__], [__ofile__])],
[typedef int yystype;]) [typedef int yystype;])
# define YYSTYPE yystype # define YYSTYPE yystype
#endif #endif

View File

@@ -65,12 +65,6 @@ muscle_init (void)
/* Version and input file. */ /* Version and input file. */
MUSCLE_INSERT_STRING ("version", VERSION); MUSCLE_INSERT_STRING ("version", VERSION);
MUSCLE_INSERT_STRING ("filename", infile); 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");
} }

View File

@@ -276,11 +276,10 @@ user_actions_output (FILE *out)
{ {
fprintf (out, " case %d:\n", r + 1); fprintf (out, " case %d:\n", r + 1);
if (!no_lines_flag) fprintf (out, "]b4_syncline([[%d]], [[%s]])[\n",
fprintf (out, muscle_find ("linef"), rules[r].action_location.first_line,
rules[r].action_location.first_line, quotearg_style (escape_quoting_style,
quotearg_style (c_quoting_style, rules[r].action_location.file));
rules[r].action_location.file));
fprintf (out, " %s\n break;\n\n", fprintf (out, " %s\n break;\n\n",
rules[r].action); rules[r].action);
} }
@@ -566,11 +565,12 @@ static void
prepare (void) prepare (void)
{ {
/* Flags. */ /* Flags. */
MUSCLE_INSERT_INT ("locations_flag", locations_flag); MUSCLE_INSERT_INT ("debug", debug_flag);
MUSCLE_INSERT_INT ("defines_flag", defines_flag); MUSCLE_INSERT_INT ("defines_flag", defines_flag);
MUSCLE_INSERT_INT ("error_verbose", error_verbose); MUSCLE_INSERT_INT ("error_verbose", error_verbose);
MUSCLE_INSERT_INT ("locations_flag", locations_flag);
MUSCLE_INSERT_INT ("pure", pure_parser); 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 /* FIXME: This is wrong: the muscles should decide whether they hold
a copy or not, but the situation is too obscure currently. */ a copy or not, but the situation is too obscure currently. */

View File

@@ -69,13 +69,9 @@ prologue_augment (const char *prologue, location_t location)
struct obstack *oout = struct obstack *oout =
!typed ? &pre_prologue_obstack : &post_prologue_obstack; !typed ? &pre_prologue_obstack : &post_prologue_obstack;
if (!no_lines_flag) obstack_fgrow2 (oout, "]b4_syncline([[%d]], [[%s]])[\n",
{ location.first_line,
obstack_fgrow2 (oout, muscle_find ("linef"), quotearg_style (escape_quoting_style, location.file));
location.first_line,
quotearg_style (c_quoting_style,
location.file));
}
obstack_sgrow (oout, prologue); obstack_sgrow (oout, prologue);
} }
@@ -89,13 +85,9 @@ prologue_augment (const char *prologue, location_t location)
void void
epilogue_set (const char *epilogue, location_t location) epilogue_set (const char *epilogue, location_t location)
{ {
if (!no_lines_flag) obstack_fgrow2 (&muscle_obstack, "]b4_syncline([[%d]], [[%s]])[\n",
{ location.first_line,
obstack_fgrow2 (&muscle_obstack, muscle_find ("linef"), quotearg_style (escape_quoting_style, location.file));
location.first_line,
quotearg_style (c_quoting_style,
location.file));
}
obstack_sgrow (&muscle_obstack, epilogue); obstack_sgrow (&muscle_obstack, epilogue);
obstack_1grow (&muscle_obstack, 0); obstack_1grow (&muscle_obstack, 0);
muscle_insert ("epilogue", obstack_finish (&muscle_obstack)); muscle_insert ("epilogue", obstack_finish (&muscle_obstack));