]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Move "paren_depth" into ada_parse_state
authorTom Tromey <tromey@adacore.com>
Thu, 14 Mar 2024 18:29:40 +0000 (12:29 -0600)
committerTom Tromey <tromey@adacore.com>
Tue, 2 Apr 2024 17:24:27 +0000 (11:24 -0600)
This moves the "paren_depth" global into ada_parse_state.

gdb/ada-exp.y
gdb/ada-lex.l

index b685ce968f7787a35ddbd448285d76a5d3e32a3c..21a384bc6927948a8e2e2500e566f5f756c83df7 100644 (file)
@@ -102,6 +102,9 @@ struct ada_parse_state
 
   auto_obstack temp_space;
 
+  /* Depth of parentheses, used by the lexer.  */
+  int paren_depth = 0;
+
 private:
 
   /* We don't have a good way to manage non-POD data in Yacc, so store
index 90cb5ba1b8a2173b5d208025ae996b53c053e90e..9161c4377c0dae94865c25c6557a2c487e2ea0b4 100644 (file)
@@ -108,9 +108,6 @@ static bool returned_complete = false;
       pstate->lexptr += 1;                                             \
     }
 
-/* Depth of parentheses.  */
-static int paren_depth;
-
 %}
 
 %option case-insensitive interactive nodefault noyywrap
@@ -268,7 +265,7 @@ false               { return FALSEKEYWORD; }
 
 [-&*+{}@/:<>=|;\[\]] { return yytext[0]; }
 
-","            { if (paren_depth == 0 && pstate->comma_terminates)
+","            { if (ada_parser->paren_depth == 0 && pstate->comma_terminates)
                    {
                      rewind_to_char (',');
                      return 0;
@@ -277,15 +274,15 @@ false             { return FALSEKEYWORD; }
                    return ',';
                }
 
-"("            { paren_depth += 1; return '('; }
-")"            { if (paren_depth == 0)
+"("            { ada_parser->paren_depth += 1; return '('; }
+")"            { if (ada_parser->paren_depth == 0)
                    {
                      rewind_to_char (')');
                      return 0;
                    }
                  else
                    {
-                     paren_depth -= 1;
+                     ada_parser->paren_depth -= 1;
                      return ')';
                    }
                }
@@ -349,7 +346,6 @@ static void
 lexer_init (FILE *inp)
 {
   BEGIN INITIAL;
-  paren_depth = 0;
   returned_complete = false;
   yyrestart (inp);
 }