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.
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.
(rustyylex, rust_lex_test_init, rust_lex_test_one)
(rust_lex_test_sequence, rust_lex_test_push_back): Update.
[-&*+./:<>=|;\[\]] { return yytext[0]; }
-"," { if (paren_depth == 0 && comma_terminates)
+"," { if (paren_depth == 0 && pstate->comma_terminates)
{
rewind_to_char (',');
return 0;
return c;
case ',':
- if (comma_terminates
+ if (pstate->comma_terminates
&& paren_depth == 0
&& ! scanning_macro_expansion ())
return 0;
return c;
case ',':
- if (comma_terminates && paren_depth == 0)
+ if (pstate->comma_terminates && paren_depth == 0)
return 0;
lexptr++;
return c;
return c;
case ',':
- if (comma_terminates && paren_depth == 0)
+ if (pstate->comma_terminates && paren_depth == 0)
return 0;
lexptr++;
return c;
return c;
case ',':
- if (comma_terminates
+ if (pstate->comma_terminates
&& paren_depth == 0)
return 0;
lexptr++;
return c;
case ',':
- if (comma_terminates && paren_depth == 0)
+ if (pstate->comma_terminates && paren_depth == 0)
return 0;
lexptr++;
return c;
return c;
case ',':
- if (comma_terminates && paren_depth == 0)
+ if (pstate->comma_terminates && paren_depth == 0)
return 0;
lexptr++;
return c;
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;
expout_completion_name.reset ();
innermost_block.reset (tracker_types);
- comma_terminates = comma;
-
if (lexptr == 0 || *lexptr == 0)
error_no_arg (_("expression to compute"));
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);
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)
{
}
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
/* 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. */
/* 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);
// 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);