]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add PARSER_DEBUG flag
authorTom Tromey <tromey@adacore.com>
Fri, 28 Apr 2023 14:08:54 +0000 (08:08 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 23 May 2023 19:57:54 +0000 (13:57 -0600)
This adds a new PARSER_DEBUG constant and changes the parser code to
use it.  This lets us make the 'parser_debug' global 'static'.

gdb/ada-exp.y
gdb/c-exp.y
gdb/d-exp.y
gdb/expression.h
gdb/f-exp.y
gdb/go-exp.y
gdb/parse.c
gdb/parser-defs.h

index 3e31d27504684ef3ea31586aadc31b04554e4389..23aebf0e2368614d828cfdaded1554b34b3c4b9f 100644 (file)
@@ -1150,7 +1150,7 @@ ada_parse (struct parser_state *par_state)
   original_expr = par_state->lexptr;
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
-                                                       parser_debug);
+                                                       par_state->debug);
 
   lexer_init (yyin);           /* (Re-)initialize lexer.  */
   obstack_free (&temp_parse_space, NULL);
index 9ee4115560ab9b3ea2cb3f3c56c324f2d6e9bcae..a8c784142537d0482a4fdfa8cf0e3a564ca6e4ca 100644 (file)
@@ -3403,7 +3403,7 @@ c_parse (struct parser_state *par_state)
     = make_scoped_restore (&expression_macro_scope, macro_scope.get ());
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
-                                                       parser_debug);
+                                                       par_state->debug);
 
   /* Initialize some state used by the lexer.  */
   last_was_structop = false;
index 3a4e7ee043410118a0a19f7342d23e2624c69f06..b0f2c0d1c10254e05e7589a5aaf236908d6a73a1 100644 (file)
@@ -1607,7 +1607,7 @@ d_parse (struct parser_state *par_state)
   pstate = par_state;
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
-                                                       parser_debug);
+                                                       par_state->debug);
 
   struct type_stack stack;
   scoped_restore restore_type_stack = make_scoped_restore (&type_stack,
index 2e2d2a090f9f7016e728829054e45d05d440fa8f..c485b159ef8b26a53f98e33d0008c7be8c54b5b4 100644 (file)
@@ -296,6 +296,11 @@ enum parser_flag
   /* This flag is set if a top-level comma terminates the
      expression.  */
   PARSER_COMMA_TERMINATES = (1 << 1),
+
+  /* This flag is set if the parser should print debugging output as
+     it parses.  For yacc-based parsers, this translates to setting
+     yydebug.  */
+  PARSER_DEBUG = (1 << 2),
 };
 DEF_ENUM_FLAGS_TYPE (enum parser_flag, parser_flags);
 
index 7fb1a9054e36112d7fc41ff9fac10850a32b3d2c..c0afebc0589007ed399662e5664126a185a6751b 100644 (file)
@@ -1697,7 +1697,7 @@ f_language::parser (struct parser_state *par_state) const
   /* Setting up the parser state.  */
   scoped_restore pstate_restore = make_scoped_restore (&pstate);
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
-                                                       parser_debug);
+                                                       par_state->debug);
   gdb_assert (par_state != NULL);
   pstate = par_state;
   last_was_structop = false;
index 542a06d06d6eb903524e79fa8113308e5726fad8..5c213f138f0f3f150908abdf185832e581e7f02e 100644 (file)
@@ -1525,7 +1525,7 @@ go_language::parser (struct parser_state *par_state) const
   pstate = par_state;
 
   scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
-                                                       parser_debug);
+                                                       par_state->debug);
 
   /* Initialize some state used by the lexer.  */
   last_was_structop = 0;
index 2f014dd2172eb7f892595096041e1d31f85d5519..bbe5cf12d370713507a5116b6c38bf05cbcf8ae9 100644 (file)
@@ -62,7 +62,7 @@ show_expressiondebug (struct ui_file *file, int from_tty,
 
 
 /* True if an expression parser should set yydebug.  */
-bool parser_debug;
+static bool parser_debug;
 
 static void
 show_parserdebug (struct ui_file *file, int from_tty,
index 39046d04c8d8ee485bd056107ac7db86333e886c..93ebdf5c06145b5cd3decb29f07f6f73674b554b 100644 (file)
@@ -32,8 +32,6 @@ struct language_defn;
 struct internalvar;
 class innermost_block_tracker;
 
-extern bool parser_debug;
-
 /* A class that can be used to build a "struct expression".  */
 
 struct expr_builder
@@ -157,7 +155,8 @@ struct parser_state : public expr_builder
       block_tracker (tracker),
       comma_terminates ((flags & PARSER_COMMA_TERMINATES) != 0),
       parse_completion (completion),
-      void_context_p ((flags & PARSER_VOID_CONTEXT) != 0)
+      void_context_p ((flags & PARSER_VOID_CONTEXT) != 0),
+      debug ((flags & PARSER_DEBUG) != 0)
   {
   }
 
@@ -303,6 +302,9 @@ struct parser_state : public expr_builder
   /* True if no value is expected from the expression.  */
   bool void_context_p;
 
+  /* True if parser debugging should be enabled.  */
+  bool debug;
+
 private:
 
   /* Data structure for saving values of arglist_len for function calls whose