mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 01:03:04 +00:00
* src/bison.simple: Remove a useless #line directive.
s/#line %%line %%skeleton/#line %%line "%%parser-file-name"/'. * src/output.c (get_lines_number): New. (output_parser): Adjust, now takes care about the lines of a output muscles. Fix line numbering. (actions_output): Computes the number of lines taken by actions. (output_master_parser): Insert new skeleton which is the name of the output parser file name.
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
|||||||
|
2001-12-16 Marc Autret <autret_m@epita.fr>
|
||||||
|
|
||||||
|
* src/bison.simple: Remove a useless #line directive.
|
||||||
|
s/#line %%line %%skeleton/#line %%line "%%parser-file-name"/'.
|
||||||
|
* src/output.c (get_lines_number): New.
|
||||||
|
(output_parser): Adjust, now takes care about the lines of a
|
||||||
|
output muscles.
|
||||||
|
Fix line numbering.
|
||||||
|
(actions_output): Computes the number of lines taken by actions.
|
||||||
|
(output_master_parser): Insert new skeleton which is the name of
|
||||||
|
the output parser file name.
|
||||||
|
|
||||||
2001-12-15 Marc Autret <autret_m@epita.fr>
|
2001-12-15 Marc Autret <autret_m@epita.fr>
|
||||||
|
|
||||||
* src/bison.simple [YYERROR_VERBOSE]: Restore backward compatibility.
|
* src/bison.simple [YYERROR_VERBOSE]: Restore backward compatibility.
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ typedef struct yyltype
|
|||||||
/* Copy the user declarations. */
|
/* Copy the user declarations. */
|
||||||
%%prologue
|
%%prologue
|
||||||
|
|
||||||
#line %%line "%%skeleton"
|
/* Line 85 of bison.simple. */
|
||||||
|
#line %%line "%%parser-file-name"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -511,8 +512,6 @@ yystpcpy (yydest, yysrc)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#line %%line "%%skeleton"
|
|
||||||
|
|
||||||
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
|
||||||
into yyparse. The argument should have type void *.
|
into yyparse. The argument should have type void *.
|
||||||
It should actually point to an object.
|
It should actually point to an object.
|
||||||
@@ -897,7 +896,8 @@ yyreduce:
|
|||||||
{
|
{
|
||||||
%%actions
|
%%actions
|
||||||
}
|
}
|
||||||
#line %%line "%%skeleton"
|
/* Line 902 of bison.simple. */
|
||||||
|
#line %%line "%%parser-file-name"
|
||||||
|
|
||||||
yyvsp -= yylen;
|
yyvsp -= yylen;
|
||||||
yyssp -= yylen;
|
yyssp -= yylen;
|
||||||
|
|||||||
34
src/output.c
34
src/output.c
@@ -125,6 +125,23 @@ struct obstack output_obstack;
|
|||||||
|
|
||||||
int error_verbose = 0;
|
int error_verbose = 0;
|
||||||
|
|
||||||
|
/* Returns the number of lines of S. */
|
||||||
|
static size_t
|
||||||
|
get_lines_number (const char *s)
|
||||||
|
{
|
||||||
|
size_t lines = 0;
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; s[i]; ++i)
|
||||||
|
{
|
||||||
|
if (s[i] == '\n')
|
||||||
|
++lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME. */
|
/* FIXME. */
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -519,7 +536,7 @@ token_actions (void)
|
|||||||
`-----------------------------*/
|
`-----------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
actions_output (FILE *out)
|
actions_output (FILE *out, size_t *line)
|
||||||
{
|
{
|
||||||
int rule;
|
int rule;
|
||||||
for (rule = 1; rule < nrules + 1; ++rule)
|
for (rule = 1; rule < nrules + 1; ++rule)
|
||||||
@@ -538,6 +555,11 @@ actions_output (FILE *out)
|
|||||||
fprintf (out, "{ %s%s }\n break;\n\n",
|
fprintf (out, "{ %s%s }\n break;\n\n",
|
||||||
rule_table[rule].action,
|
rule_table[rule].action,
|
||||||
yacc_flag ? ";" : "");
|
yacc_flag ? ";" : "");
|
||||||
|
|
||||||
|
/* We always output 5 '\n' per action. */
|
||||||
|
*line += 5;
|
||||||
|
/* Get the number of lines written by the user. */
|
||||||
|
*line += get_lines_number (rule_table[rule].action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -962,11 +984,14 @@ output_parser (const char *skel_filename, FILE *out)
|
|||||||
muscle_key = obstack_finish (&muscle_obstack);
|
muscle_key = obstack_finish (&muscle_obstack);
|
||||||
muscle_value = muscle_find (muscle_key);
|
muscle_value = muscle_find (muscle_key);
|
||||||
if (!strcmp (muscle_key, "actions"))
|
if (!strcmp (muscle_key, "actions"))
|
||||||
actions_output (out);
|
actions_output (out, &line);
|
||||||
else if (!strcmp (muscle_key, "line"))
|
else if (!strcmp (muscle_key, "line"))
|
||||||
fprintf (out, "%d", line + 1);
|
fprintf (out, "%d", line);
|
||||||
else if (muscle_value)
|
else if (muscle_value)
|
||||||
fputs (muscle_value, out);
|
{
|
||||||
|
fputs (muscle_value, out);
|
||||||
|
line += get_lines_number (muscle_value);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fputs ("%%", out);
|
fputs ("%%", out);
|
||||||
@@ -997,6 +1022,7 @@ output_master_parser (void)
|
|||||||
skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE);
|
skeleton = skeleton_find ("BISON_SIMPLE", BISON_SIMPLE);
|
||||||
}
|
}
|
||||||
muscle_insert ("skeleton", skeleton);
|
muscle_insert ("skeleton", skeleton);
|
||||||
|
muscle_insert ("parser-file-name", parser_file_name);
|
||||||
|
|
||||||
output_parser (skeleton, parser);
|
output_parser (skeleton, parser);
|
||||||
xfclose (parser);
|
xfclose (parser);
|
||||||
|
|||||||
Reference in New Issue
Block a user