[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] parse.stats: add --trace=parse-stats
From: |
Akim Demaille |
Subject: |
[PATCH 2/4] parse.stats: add --trace=parse-stats |
Date: |
Wed, 3 Jul 2019 07:25:36 +0200 |
Let Bison expose statistics about its own parsing.
* src/getargs.h, src/getargs.c (trace_args, trace_types, trace):
Support parse-trace.
* src/parse-gram.y: Define parse.stats.
* src/reader.c (reader): Update the definition of gram_debug.
---
src/getargs.c | 38 ++++++++++++++++++++------------------
src/getargs.h | 35 ++++++++++++++++++-----------------
src/parse-gram.y | 1 +
src/reader.c | 4 +++-
4 files changed, 42 insertions(+), 36 deletions(-)
diff --git a/src/getargs.c b/src/getargs.c
index 0e6b1d60..d0d3a1b4 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -204,6 +204,7 @@ static const argmatch_trace_doc argmatch_trace_docs[] =
{ "locations", "full display of the locations" },
{ "scan", "grammar scanner traces" },
{ "parse", "grammar parser traces" },
+ { "parse-stats","grammar parser stats" },
{ "automaton", "construction of the automaton" },
{ "bitsets", "use of bitsets" },
{ "closure", "input/output of closure" },
@@ -222,24 +223,25 @@ static const argmatch_trace_doc argmatch_trace_docs[] =
static const argmatch_trace_arg argmatch_trace_args[] =
{
- { "none", trace_none },
- { "locations", trace_locations },
- { "scan", trace_scan },
- { "parse", trace_parse },
- { "automaton", trace_automaton },
- { "bitsets", trace_bitsets },
- { "closure", trace_closure },
- { "grammar", trace_grammar },
- { "resource", trace_resource },
- { "sets", trace_sets },
- { "muscles", trace_muscles },
- { "tools", trace_tools },
- { "m4", trace_m4 },
- { "skeleton", trace_skeleton },
- { "time", trace_time },
- { "ielr", trace_ielr },
- { "all", trace_all },
- { NULL, trace_none},
+ { "none", trace_none },
+ { "locations", trace_locations },
+ { "scan", trace_scan },
+ { "parse", trace_parse },
+ { "parse-stats", trace_parse_stats },
+ { "automaton", trace_automaton },
+ { "bitsets", trace_bitsets },
+ { "closure", trace_closure },
+ { "grammar", trace_grammar },
+ { "resource", trace_resource },
+ { "sets", trace_sets },
+ { "muscles", trace_muscles },
+ { "tools", trace_tools },
+ { "m4", trace_m4 },
+ { "skeleton", trace_skeleton },
+ { "time", trace_time },
+ { "ielr", trace_ielr },
+ { "all", trace_all },
+ { NULL, trace_none},
};
const argmatch_trace_group_type argmatch_trace_group =
diff --git a/src/getargs.h b/src/getargs.h
index ab6af6c3..fad33bb7 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -89,23 +89,24 @@ extern int report_flag;
`----------*/
enum trace
{
- trace_none = 0, /**< No traces. */
- trace_scan = 1 << 0, /**< Grammar scanner traces. */
- trace_parse = 1 << 1, /**< Grammar parser traces. */
- trace_resource = 1 << 2, /**< Memory allocation. */
- trace_sets = 1 << 3, /**< Grammar sets: firsts, nullable etc. */
- trace_bitsets = 1 << 4, /**< Use of bitsets. */
- trace_tools = 1 << 5, /**< m4 invocation. */
- trace_automaton = 1 << 6, /**< Construction of the automaton. */
- trace_grammar = 1 << 7, /**< Reading, reducing the grammar. */
- trace_time = 1 << 8, /**< Time consumption. */
- trace_skeleton = 1 << 9, /**< Skeleton postprocessing. */
- trace_m4 = 1 << 10, /**< M4 traces. */
- trace_muscles = 1 << 11, /**< M4 definitions of the muscles. */
- trace_ielr = 1 << 12, /**< IELR conversion. */
- trace_closure = 1 << 13, /**< Input/output of closure(). */
- trace_locations = 1 << 14, /**< Full display of locations. */
- trace_all = ~0 /**< All of the above. */
+ trace_none = 0, /**< No traces. */
+ trace_scan = 1 << 0, /**< Grammar scanner traces. */
+ trace_parse = 1 << 1, /**< Grammar parser traces. */
+ trace_resource = 1 << 2, /**< Memory allocation. */
+ trace_sets = 1 << 3, /**< Grammar sets: firsts, nullable etc. */
+ trace_bitsets = 1 << 4, /**< Use of bitsets. */
+ trace_tools = 1 << 5, /**< m4 invocation. */
+ trace_automaton = 1 << 6, /**< Construction of the automaton. */
+ trace_grammar = 1 << 7, /**< Reading, reducing the grammar. */
+ trace_time = 1 << 8, /**< Time consumption. */
+ trace_skeleton = 1 << 9, /**< Skeleton postprocessing. */
+ trace_m4 = 1 << 10, /**< M4 traces. */
+ trace_muscles = 1 << 11, /**< M4 definitions of the muscles. */
+ trace_ielr = 1 << 12, /**< IELR conversion. */
+ trace_closure = 1 << 13, /**< Input/output of closure(). */
+ trace_locations = 1 << 14, /**< Full display of locations. */
+ trace_parse_stats = 1 << 15, /**< Facts about a parser run. */
+ trace_all = ~0 /**< All of the above. */
};
/** What debug items bison displays during its run. */
extern int trace_flag;
diff --git a/src/parse-gram.y b/src/parse-gram.y
index c7cc35fd..0bd9b77f 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -128,6 +128,7 @@
%define locations
%define parse.error verbose
%define parse.lac full
+%define parse.stats
%define parse.trace
%defines
%expect 0
diff --git a/src/reader.c b/src/reader.c
index 43ca2036..86c0a2f8 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -732,7 +732,9 @@ reader (void)
gram_in = xfopen (grammar_file, "r");
gram__flex_debug = trace_flag & trace_scan;
- gram_debug = trace_flag & trace_parse;
+ gram_debug =
+ (trace_flag & trace_parse ? gram_debug_trace : gram_debug_none)
+ | (trace_flag & trace_parse_stats ? gram_debug_stats : gram_debug_none);
gram_scanner_initialize ();
gram_parse ();
prepare_percent_define_front_end_variables ();
--
2.22.0
- [PATCH 0/4] RFC: add stats about parsing, Akim Demaille, 2019/07/03
- [PATCH 2/4] parse.stats: add --trace=parse-stats,
Akim Demaille <=
- [PATCH 1/4] parse.stats: new feature of yacc.c, Akim Demaille, 2019/07/03
- [PATCH 4/4] parse.stats: documentation, Akim Demaille, 2019/07/03
- [PATCH 3/4] regen, Akim Demaille, 2019/07/03
- Re: [PATCH 0/4] RFC: add stats about parsing, Adrian Vogelsgesang, 2019/07/03
- Re: [PATCH 0/4] RFC: add stats about parsing, Akim Demaille, 2019/07/03
- Re: [PATCH 0/4] RFC: add stats about parsing, Adrian Vogelsgesang, 2019/07/04
- [RFC PATCH 0/4] RFC: add stats about parsing, Akim Demaille, 2019/07/07
- [RFC PATCH 1/4] parse stats: new feature of yacc.c, Akim Demaille, 2019/07/07
- [RFC PATCH 2/4] parse stats: add --trace=parse-stats, Akim Demaille, 2019/07/07
- [RFC PATCH 3/4] regen, Akim Demaille, 2019/07/07