mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
%merge: delegate the generation of calls to mergers to m4
Don't generate C code from bison, leave that to the skeletons. * src/output.c (merger_output): Emit invocations to b4_call_merger. * data/skeletons/glr.c, data/skeletons/glr2.cc (b4_call_merger): New.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
-*- C -*-
|
# -*- C -*-
|
||||||
|
|
||||||
# GLR skeleton for Bison
|
# GLR skeleton for Bison
|
||||||
|
|
||||||
@@ -147,6 +147,15 @@ m4_define([b4_rhs_location],
|
|||||||
[(b4_rhs_data([$1], [$2]).yyloc)])
|
[(b4_rhs_data([$1], [$2]).yyloc)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_call_merger(MERGER-NUM, MERGER-NAME, SYMBOL-SUM)
|
||||||
|
# ---------------------------------------------------
|
||||||
|
m4_define([b4_call_merger],
|
||||||
|
[b4_case([$1],
|
||||||
|
[ b4_symbol_if([$3], [has_type],
|
||||||
|
[yy0->b4_symbol($3, type) = $2 (*yy0, *yy1);],
|
||||||
|
[*yy0 = $2 (*yy0, *yy1);])])])
|
||||||
|
|
||||||
|
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
## Declarations. ##
|
## Declarations. ##
|
||||||
## -------------- ##
|
## -------------- ##
|
||||||
|
|||||||
@@ -122,6 +122,14 @@ m4_define([b4_rhs_location],
|
|||||||
[(b4_rhs_data([$1], [$2]).yyloc)])
|
[(b4_rhs_data([$1], [$2]).yyloc)])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_call_merger(MERGER-NUM, MERGER-NAME, SYMBOL-SUM)
|
||||||
|
# ---------------------------------------------------
|
||||||
|
m4_define([b4_call_merger],
|
||||||
|
[b4_case([$1],
|
||||||
|
[ b4_symbol_if([$3], [has_type],
|
||||||
|
[yy0->b4_symbol($3, type) = $2 (*yy0, *yy1);],
|
||||||
|
[*yy0 = $2 (*yy0, *yy1);])])])
|
||||||
|
|
||||||
# b4_lex
|
# b4_lex
|
||||||
# ------
|
# ------
|
||||||
# Call yylex.
|
# Call yylex.
|
||||||
|
|||||||
@@ -554,12 +554,8 @@ merger_output (FILE *out)
|
|||||||
int n;
|
int n;
|
||||||
merger_list* p;
|
merger_list* p;
|
||||||
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
|
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
|
||||||
if (p->sym && p->sym->content->type_name)
|
fprintf (out, "]b4_call_merger([%d], [%s], [%d])[\n",
|
||||||
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
|
n, p->name, p->sym->content->number);
|
||||||
n, p->sym->content->type_name, p->name);
|
|
||||||
else
|
|
||||||
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
|
|
||||||
n, p->name);
|
|
||||||
fputs ("]])\n\n", out);
|
fputs ("]])\n\n", out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user