Move comma_terminates global to parser_state
authorTom Tromey <tom@tromey.com>
Mon, 25 Mar 2019 00:07:00 +0000 (18:07 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 5 Apr 2019 01:55:11 +0000 (19:55 -0600)
This moves the comma_terminates global to parser_state.

gdb/ChangeLog
2019-04-04  Tom Tromey  <tom@tromey.com>

* rust-exp.y (rustyylex, rust_lex_tests): Update.
* parser-defs.h (struct parser_state) <parser_state>: Add new
parameter.
<comma_terminates>: New member.
(comma_terminates): Don't declare global.
* parse.c (comma_terminates): Remove global.
(parse_exp_in_context): Update.
* p-exp.y (yylex): Update.
* m2-exp.y (yylex): Update.
* go-exp.y (lex_one_token): Update.
* f-exp.y (yylex): Update.
* d-exp.y (lex_one_token): Update.
* c-exp.y (lex_one_token): Update.
* ada-lex.l: Update.

gdb/ChangeLog
gdb/ada-lex.l
gdb/c-exp.y
gdb/d-exp.y
gdb/f-exp.y
gdb/go-exp.y
gdb/m2-exp.y
gdb/p-exp.y
gdb/parse.c
gdb/parser-defs.h
gdb/rust-exp.y

index 3e03604528bb6b1d89deb16bbccc71f4841a5e15..8217a763259c4c8b0d2e5fa49f5c31dcaa410250 100644 (file)
@@ -1,3 +1,20 @@
+2019-04-04  Tom Tromey  <tom@tromey.com>
+
+       * rust-exp.y (rustyylex, rust_lex_tests): Update.
+       * parser-defs.h (struct parser_state) <parser_state>: Add new
+       parameter.
+       <comma_terminates>: New member.
+       (comma_terminates): Don't declare global.
+       * parse.c (comma_terminates): Remove global.
+       (parse_exp_in_context): Update.
+       * p-exp.y (yylex): Update.
+       * m2-exp.y (yylex): Update.
+       * go-exp.y (lex_one_token): Update.
+       * f-exp.y (yylex): Update.
+       * d-exp.y (lex_one_token): Update.
+       * c-exp.y (lex_one_token): Update.
+       * ada-lex.l: Update.
+
 2019-04-04  Tom Tromey  <tom@tromey.com>
 
        * rust-exp.y (struct rust_parser) <paren_depth>: New member.
index 6163405545d4c4c10d2c92f26bfa3ecd5a7cd2d1..43bd25c1e2ff2de91cc3d04dc5ea0e0da95ac648 100644 (file)
@@ -232,7 +232,7 @@ false               { return FALSEKEYWORD; }
 
 [-&*+./:<>=|;\[\]] { return yytext[0]; }
 
-","            { if (paren_depth == 0 && comma_terminates)
+","            { if (paren_depth == 0 && pstate->comma_terminates)
                    {
                      rewind_to_char (',');
                      return 0;
index cb9e9e002c74c7c749564ac75c0dcf03e0014321..16b291f9c700ff9c8453a5d51357be9cad038bee 100644 (file)
@@ -2637,7 +2637,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
       return c;
 
     case ',':
-      if (comma_terminates
+      if (pstate->comma_terminates
           && paren_depth == 0
           && ! scanning_macro_expansion ())
        return 0;
index c15199535214abc79a0e7b7e1d0c34a8abdbcb5c..06e12e3201104a8b23c79d25264c4f512c0a6492 100644 (file)
@@ -1098,7 +1098,7 @@ lex_one_token (struct parser_state *par_state)
       return c;
 
     case ',':
-      if (comma_terminates && paren_depth == 0)
+      if (pstate->comma_terminates && paren_depth == 0)
        return 0;
       lexptr++;
       return c;
index 100a3bbec145a84643711ad23ba3ffbdda95490c..522751d2263ae74366740347ff902000e349dfbd 100644 (file)
@@ -1115,7 +1115,7 @@ yylex (void)
       return c;
       
     case ',':
-      if (comma_terminates && paren_depth == 0)
+      if (pstate->comma_terminates && paren_depth == 0)
        return 0;
       lexptr++;
       return c;
index aaffe3d45a063a23025339fee12a1111a22cf6ce..ea1487cb0082439a80a5aa2825207cb8ab84850a 100644 (file)
@@ -1077,7 +1077,7 @@ lex_one_token (struct parser_state *par_state)
       return c;
 
     case ',':
-      if (comma_terminates
+      if (pstate->comma_terminates
           && paren_depth == 0)
        return 0;
       lexptr++;
index c0f5e75be2a9f09bd00fda96161272dc5ffbedda..2174014e79ae3afd16d3e05d74b7e556e4cf4104 100644 (file)
@@ -819,7 +819,7 @@ yylex (void)
       return c;
 
     case ',':
-      if (comma_terminates && paren_depth == 0)
+      if (pstate->comma_terminates && paren_depth == 0)
        return 0;
       lexptr++;
       return c;
index 768f302592198a1405c76d468d2065c880067b6c..65874c6327d084945fab51440577988cb50c9a61 100644 (file)
@@ -1218,7 +1218,7 @@ yylex (void)
       return c;
 
     case ',':
-      if (comma_terminates && paren_depth == 0)
+      if (pstate->comma_terminates && paren_depth == 0)
        return 0;
       lexptr++;
       return c;
index 4ac79faaeae3e6cf5215bb5071554fbea0b5c3c0..617ff70d67ea77efb73fc92b90153b6f42e137a8 100644 (file)
@@ -71,7 +71,6 @@ int arglist_len;
 static struct type_stack type_stack;
 const char *lexptr;
 const char *prev_lexptr;
-int comma_terminates;
 
 /* True if parsing an expression to attempt completion.  */
 int parse_completion;
@@ -1122,8 +1121,6 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
   expout_completion_name.reset ();
   innermost_block.reset (tracker_types);
 
-  comma_terminates = comma;
-
   if (lexptr == 0 || *lexptr == 0)
     error_no_arg (_("expression to compute"));
 
@@ -1187,7 +1184,7 @@ parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
      to the value matching SELECTED_FRAME as set by get_current_arch.  */
 
   parser_state ps (lang, get_current_arch (), expression_context_block,
-                  expression_context_pc);
+                  expression_context_pc, comma);
 
   scoped_restore_current_language lang_saver;
   set_language (lang->la_language);
index 6fb0f8e5533503f292089ee5b080736d2c455d21..f2bb18fd9c74ab8a2bf9a87c2232d633721a72da 100644 (file)
@@ -88,10 +88,12 @@ struct parser_state : public expr_builder
   parser_state (const struct language_defn *lang,
                struct gdbarch *gdbarch,
                const struct block *context_block,
-               CORE_ADDR context_pc)
+               CORE_ADDR context_pc,
+               int comma)
     : expr_builder (lang, gdbarch),
       expression_context_block (context_block),
-      expression_context_pc (context_pc)
+      expression_context_pc (context_pc),
+      comma_terminates (comma)
   {
   }
 
@@ -108,6 +110,10 @@ struct parser_state : public expr_builder
      at, and then look up the macro definitions active at that
      point.  */
   const CORE_ADDR expression_context_pc;
+
+  /* Nonzero means stop parsing on first comma (if not within parentheses).  */
+
+  int comma_terminates;
 };
 
 /* When parsing expressions we track the innermost block that was
@@ -355,10 +361,6 @@ extern const char *lexptr;
 /* After a token has been recognized, this variable points to it.
    Currently used only for error reporting.  */
 extern const char *prev_lexptr;
-
-/* Nonzero means stop parsing on first comma (if not within parentheses).  */
-
-extern int comma_terminates;
 \f
 /* These codes indicate operator precedences for expression printing,
    least tightly binding first.  */
index 9d3083ead929ff42e3aa2ea427e1a23dab150b72..2f2cc8f31fe29241b8afa5f33bef2eff0a885706 100644 (file)
@@ -1674,7 +1674,8 @@ rustyylex (YYSTYPE *lvalp, rust_parser *parser)
       /* Falls through to lex_operator.  */
       ++parser->paren_depth;
     }
-  else if (lexptr[0] == ',' && comma_terminates && parser->paren_depth == 0)
+  else if (lexptr[0] == ',' && parser->pstate->comma_terminates
+          && parser->paren_depth == 0)
     return 0;
 
   return lex_operator (lvalp);
@@ -2713,7 +2714,7 @@ rust_lex_tests (void)
 
   // Set up dummy "parser", so that rust_type works.
   struct parser_state ps (&rust_language_defn, target_gdbarch (),
-                         nullptr, 0);
+                         nullptr, 0, 0);
   rust_parser parser (&ps);
 
   rust_lex_test_one (&parser, "", 0);
This page took 0.033287 seconds and 4 git commands to generate.