mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
Merge maint into master
* upstream/maint: fix generated comments traces: provide a means to get short m4 traces traces: show the full m4 invocation
This commit is contained in:
@@ -34,6 +34,7 @@ dist_skeletons_DATA = \
|
|||||||
data/skeletons/lalr1.java \
|
data/skeletons/lalr1.java \
|
||||||
data/skeletons/location.cc \
|
data/skeletons/location.cc \
|
||||||
data/skeletons/stack.hh \
|
data/skeletons/stack.hh \
|
||||||
|
data/skeletons/traceon.m4 \
|
||||||
data/skeletons/variant.hh \
|
data/skeletons/variant.hh \
|
||||||
data/skeletons/yacc.c
|
data/skeletons/yacc.c
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,27 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# m4_gsub(STRING, RE1, SUBST1, RE2, SUBST2, ...)
|
||||||
|
# ----------------------------------------------
|
||||||
|
# m4 equivalent of
|
||||||
|
#
|
||||||
|
# $_ = STRING;
|
||||||
|
# s/RE1/SUBST1/g;
|
||||||
|
# s/RE2/SUBST2/g;
|
||||||
|
# ...
|
||||||
|
#
|
||||||
|
# Really similar to m4_bpatsubsts, but behaves properly with quotes.
|
||||||
|
# See m4.at's "Generating Comments". Super inelegant, but so far, I
|
||||||
|
# did not find any better solution.
|
||||||
|
m4_define([b4_gsub],
|
||||||
|
[m4_bpatsubst(m4_bpatsubst(m4_bpatsubst([[[[$1]]]],
|
||||||
|
[$2], [$3]),
|
||||||
|
[$4], [$5]),
|
||||||
|
[$6], [$7])])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
## Identification. ##
|
## Identification. ##
|
||||||
## ---------------- ##
|
## ---------------- ##
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
# _b4_comment(TEXT, OPEN, CONTINUE, END)
|
||||||
# --------------------------------------
|
# --------------------------------------
|
||||||
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
# Put TEXT in comment. Avoid trailing spaces: don't indent empty lines.
|
||||||
@@ -27,9 +28,10 @@
|
|||||||
#
|
#
|
||||||
# Prefix all the output lines with PREFIX.
|
# Prefix all the output lines with PREFIX.
|
||||||
m4_define([_b4_comment],
|
m4_define([_b4_comment],
|
||||||
[$2[]m4_bpatsubsts(m4_expand([$1]),
|
[$2[]b4_gsub(m4_expand([$1]),
|
||||||
[[*]/], [*\\/],
|
[[*]/], [*\\/],
|
||||||
[/[*]], [/\\*], [
|
[/[*]], [/\\*],
|
||||||
|
[
|
||||||
\(.\)], [
|
\(.\)], [
|
||||||
$3\1])$4])
|
$3\1])$4])
|
||||||
|
|
||||||
|
|||||||
2
data/skeletons/traceon.m4
Normal file
2
data/skeletons/traceon.m4
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
dnl GNU M4 treats -dV in a position-independent manner.
|
||||||
|
m4_debugmode(V)m4_traceon()dnl
|
||||||
@@ -257,7 +257,8 @@ static const argmatch_trace_doc argmatch_trace_docs[] =
|
|||||||
{ "sets", "grammar sets: firsts, nullable etc." },
|
{ "sets", "grammar sets: firsts, nullable etc." },
|
||||||
{ "muscles", "m4 definitions passed to the skeleton" },
|
{ "muscles", "m4 definitions passed to the skeleton" },
|
||||||
{ "tools", "m4 invocation" },
|
{ "tools", "m4 invocation" },
|
||||||
{ "m4", "m4 traces" },
|
{ "m4-early", "m4 traces starting from the start" },
|
||||||
|
{ "m4", "m4 traces starting from the skeleton evaluation" },
|
||||||
{ "skeleton", "skeleton postprocessing" },
|
{ "skeleton", "skeleton postprocessing" },
|
||||||
{ "time", "time consumption" },
|
{ "time", "time consumption" },
|
||||||
{ "ielr", "IELR conversion" },
|
{ "ielr", "IELR conversion" },
|
||||||
@@ -280,6 +281,7 @@ static const argmatch_trace_arg argmatch_trace_args[] =
|
|||||||
{ "sets", trace_sets },
|
{ "sets", trace_sets },
|
||||||
{ "muscles", trace_muscles },
|
{ "muscles", trace_muscles },
|
||||||
{ "tools", trace_tools },
|
{ "tools", trace_tools },
|
||||||
|
{ "m4-early", trace_m4_early },
|
||||||
{ "m4", trace_m4 },
|
{ "m4", trace_m4 },
|
||||||
{ "skeleton", trace_skeleton },
|
{ "skeleton", trace_skeleton },
|
||||||
{ "time", trace_time },
|
{ "time", trace_time },
|
||||||
|
|||||||
@@ -100,12 +100,13 @@ enum trace
|
|||||||
trace_grammar = 1 << 7, /**< Reading, reducing the grammar. */
|
trace_grammar = 1 << 7, /**< Reading, reducing the grammar. */
|
||||||
trace_time = 1 << 8, /**< Time consumption. */
|
trace_time = 1 << 8, /**< Time consumption. */
|
||||||
trace_skeleton = 1 << 9, /**< Skeleton postprocessing. */
|
trace_skeleton = 1 << 9, /**< Skeleton postprocessing. */
|
||||||
trace_m4 = 1 << 10, /**< M4 traces. */
|
trace_m4_early = 1 << 10, /**< M4 early traces. */
|
||||||
trace_muscles = 1 << 11, /**< M4 definitions of the muscles. */
|
trace_m4 = 1 << 11, /**< M4 traces. */
|
||||||
trace_ielr = 1 << 12, /**< IELR conversion. */
|
trace_muscles = 1 << 12, /**< M4 definitions of the muscles. */
|
||||||
trace_closure = 1 << 13, /**< Input/output of closure(). */
|
trace_ielr = 1 << 13, /**< IELR conversion. */
|
||||||
trace_locations = 1 << 14, /**< Full display of locations. */
|
trace_closure = 1 << 14, /**< Input/output of closure(). */
|
||||||
trace_cex = 1 << 15, /**< Counterexample generation */
|
trace_locations = 1 << 15, /**< Full display of locations. */
|
||||||
|
trace_cex = 1 << 16, /**< Counterexample generation */
|
||||||
trace_all = ~0 /**< All of the above. */
|
trace_all = ~0 /**< All of the above. */
|
||||||
};
|
};
|
||||||
/** What debug items bison displays during its run. */
|
/** What debug items bison displays during its run. */
|
||||||
|
|||||||
31
src/output.c
31
src/output.c
@@ -687,6 +687,7 @@ output_skeleton (void)
|
|||||||
char *skeldir = xpath_join (datadir, "skeletons");
|
char *skeldir = xpath_join (datadir, "skeletons");
|
||||||
char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4");
|
char *m4sugar = xpath_join (datadir, "m4sugar/m4sugar.m4");
|
||||||
char *m4bison = xpath_join (skeldir, "bison.m4");
|
char *m4bison = xpath_join (skeldir, "bison.m4");
|
||||||
|
char *traceon = xpath_join (skeldir, "traceon.m4");
|
||||||
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
char *skel = (IS_PATH_WITH_DIR (skeleton)
|
||||||
? xstrdup (skeleton)
|
? xstrdup (skeleton)
|
||||||
: xpath_join (skeldir, skeleton));
|
: xpath_join (skeldir, skeleton));
|
||||||
@@ -698,21 +699,10 @@ output_skeleton (void)
|
|||||||
|
|
||||||
/* Create an m4 subprocess connected to us via two pipes. */
|
/* Create an m4 subprocess connected to us via two pipes. */
|
||||||
|
|
||||||
if (trace_flag & trace_tools)
|
|
||||||
fprintf (stderr, "running: %s %s - %s %s\n",
|
|
||||||
m4, m4sugar, m4bison, skel);
|
|
||||||
|
|
||||||
/* Some future version of GNU M4 (most likely 1.6) may treat the -dV in a
|
|
||||||
position-dependent manner. Keep it as the first argument so that all
|
|
||||||
files are traced.
|
|
||||||
|
|
||||||
See the thread starting at
|
|
||||||
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
|
||||||
for details. */
|
|
||||||
int filter_fd[2];
|
int filter_fd[2];
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
{
|
{
|
||||||
char const *argv[10];
|
char const *argv[11];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
argv[i++] = m4;
|
argv[i++] = m4;
|
||||||
|
|
||||||
@@ -730,15 +720,29 @@ output_skeleton (void)
|
|||||||
|
|
||||||
argv[i++] = "-I";
|
argv[i++] = "-I";
|
||||||
argv[i++] = datadir;
|
argv[i++] = datadir;
|
||||||
if (trace_flag & trace_m4)
|
/* Some future version of GNU M4 (most likely 1.6) may treat the
|
||||||
|
-dV in a position-dependent manner. See the thread starting at
|
||||||
|
<http://lists.gnu.org/archive/html/bug-bison/2008-07/msg00000.html>
|
||||||
|
for details. */
|
||||||
|
if (trace_flag & trace_m4_early)
|
||||||
argv[i++] = "-dV";
|
argv[i++] = "-dV";
|
||||||
argv[i++] = m4sugar;
|
argv[i++] = m4sugar;
|
||||||
argv[i++] = "-";
|
argv[i++] = "-";
|
||||||
argv[i++] = m4bison;
|
argv[i++] = m4bison;
|
||||||
|
if (trace_flag & trace_m4)
|
||||||
|
argv[i++] = traceon;
|
||||||
argv[i++] = skel;
|
argv[i++] = skel;
|
||||||
argv[i++] = NULL;
|
argv[i++] = NULL;
|
||||||
aver (i <= ARRAY_CARDINALITY (argv));
|
aver (i <= ARRAY_CARDINALITY (argv));
|
||||||
|
|
||||||
|
if (trace_flag & trace_tools)
|
||||||
|
{
|
||||||
|
fputs ("running:", stderr);
|
||||||
|
for (int j = 0; argv[j]; ++j)
|
||||||
|
fprintf (stderr, " %s", argv[j]);
|
||||||
|
fputc ('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
/* The ugly cast is because gnulib gets the const-ness wrong. */
|
||||||
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
pid = create_pipe_bidi ("m4", m4, (char **)(void*)argv, false, true,
|
||||||
true, filter_fd);
|
true, filter_fd);
|
||||||
@@ -747,6 +751,7 @@ output_skeleton (void)
|
|||||||
free (skeldir);
|
free (skeldir);
|
||||||
free (m4sugar);
|
free (m4sugar);
|
||||||
free (m4bison);
|
free (m4bison);
|
||||||
|
free (traceon);
|
||||||
free (skel);
|
free (skel);
|
||||||
|
|
||||||
if (trace_flag & trace_muscles)
|
if (trace_flag & trace_muscles)
|
||||||
|
|||||||
30
tests/m4.at
30
tests/m4.at
@@ -29,18 +29,44 @@ AT_DATA([input.m4],
|
|||||||
[[m4@&t@_include(b4_skeletonsdir/[c.m4])
|
[[m4@&t@_include(b4_skeletonsdir/[c.m4])
|
||||||
|
|
||||||
b4_output_begin([output.txt])
|
b4_output_begin([output.txt])
|
||||||
|
|
||||||
|
b4_gsub([[abcd]],
|
||||||
|
[a], [b])
|
||||||
|
b4_gsub([[abcd]],
|
||||||
|
[a], [b],
|
||||||
|
[b], [c],
|
||||||
|
[c], [d])
|
||||||
|
|
||||||
|
_b4_comment([["/* () */"]])
|
||||||
|
_b4_comment([["/* ( */"]])
|
||||||
|
_b4_comment([["/* ) */"]])
|
||||||
|
_b4_comment([["/* [] */"]])
|
||||||
|
|
||||||
b4_comment([["/* () */"]])
|
b4_comment([["/* () */"]])
|
||||||
b4_comment([["/* ( */"]])
|
b4_comment([["/* ( */"]])
|
||||||
b4_comment([["/* ) */"]])
|
b4_comment([["/* ) */"]])
|
||||||
|
b4_comment([["/* [] */"]])
|
||||||
|
|
||||||
b4_output_end([output.txt])
|
b4_output_end([output.txt])
|
||||||
]])
|
]])
|
||||||
|
|
||||||
AT_BISON_CHECK([-S ./input.m4 input.y])
|
AT_BISON_CHECK([-S ./input.m4 input.y])
|
||||||
|
|
||||||
AT_CHECK([cat output.txt], [],
|
AT_CHECK([cat output.txt], [],
|
||||||
[/* "/\* () *\/" */
|
[[
|
||||||
|
[bbcd]
|
||||||
|
[dddd]
|
||||||
|
|
||||||
|
"/\* () *\/"
|
||||||
|
"/\* ( *\/"
|
||||||
|
"/\* ) *\/"
|
||||||
|
"/\* [] *\/"
|
||||||
|
|
||||||
|
/* "/\* () *\/" */
|
||||||
/* "/\* ( *\/" */
|
/* "/\* ( *\/" */
|
||||||
/* "/\* ) *\/" */
|
/* "/\* ) *\/" */
|
||||||
])
|
/* "/\* [] *\/" */
|
||||||
|
|
||||||
|
]])
|
||||||
|
|
||||||
AT_CLEANUP
|
AT_CLEANUP
|
||||||
|
|||||||
Reference in New Issue
Block a user