bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 2/4] parse stats: add --trace=parse-stats


From: Akim Demaille
Subject: [RFC PATCH 2/4] parse stats: add --trace=parse-stats
Date: Sun, 7 Jul 2019 20:20:34 +0200

Let Bison expose statistics about its own parsing.

* src/getargs.h, src/getargs.c (trace_args, trace_types, trace):
Support parse-trace.
* src/reader.c (reader): Update the definition of gram_debug.
---
 src/getargs.c | 2 ++
 src/getargs.h | 1 +
 src/reader.c  | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/getargs.c b/src/getargs.c
index 68894633..89fa8e66 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -249,6 +249,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" },
@@ -271,6 +272,7 @@ static const argmatch_trace_arg argmatch_trace_args[] =
   { "locations",   trace_locations },
   { "scan",        trace_scan },
   { "parse",       trace_parse },
+  { "parse-stats", trace_parse_stats },
   { "automaton",   trace_automaton },
   { "bitsets",     trace_bitsets },
   { "closure",     trace_closure },
diff --git a/src/getargs.h b/src/getargs.h
index ab6af6c3..fad33bb7 100644
--- a/src/getargs.h
+++ b/src/getargs.h
@@ -105,6 +105,7 @@ enum trace
     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.  */
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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]