+2019-04-04 Tom Tromey <tom@tromey.com>
+
+ * rust-exp.y (rust_parser::lex_identifier, rustyylex)
+ (rust_parser::convert_ast_to_expression, rust_parse)
+ (rust_lex_test_completion, rust_lex_tests): Update.
+ * parser-defs.h (struct expr_completion_state): New.
+ (struct parser_state) <parser_state>: Add completion parameter.
+ <mark_struct_expression, mark_completion_tag>: New methods.
+ <parse_completion, m_completion_state>: New members.
+ (prefixify_expression, null_post_parser): Update.
+ (mark_struct_expression, mark_completion_tag): Don't declare.
+ * parse.c (parse_completion, expout_last_struct)
+ (expout_tag_completion_type, expout_completion_name): Remove
+ globals.
+ (parser_state::mark_struct_expression)
+ (parser_state::mark_completion_tag): Now methods.
+ (prefixify_expression): Add last_struct parameter.
+ (prefixify_subexp): Likewise.
+ (parse_exp_1): Update.
+ (parse_exp_in_context): Add cstate parameter. Update.
+ (parse_expression_for_completion): Create an
+ expr_completion_state.
+ (null_post_parser): Add "completion" parameter.
+ * p-exp.y: Update rules.
+ (yylex): Update.
+ * language.h (struct language_defn) <la_post_parser>: Add
+ "completing" parameter.
+ * go-exp.y: Update rules.
+ (lex_one_token): Update.
+ * expression.h (parse_completion): Don't declare.
+ * d-exp.y: Update rules.
+ (lex_one_token): Update rules.
+ * c-exp.y: Update rules.
+ (lex_one_token): Update.
+ * ada-lang.c (resolve): Add "parse_completion" parameter.
+ (resolve_subexp): Likewise.
+ (ada_resolve_function): Likewise.
+
2019-04-04 Tom Tromey <tom@tromey.com>
* parser-defs.h (struct parser_state) <start_arglist,
static struct block_symbol *defns_collected (struct obstack *, int);
static struct value *resolve_subexp (expression_up *, int *, int,
- struct type *);
+ struct type *, int);
static void replace_operator_with_call (expression_up *, int, int, int,
struct symbol *, const struct block *);
static int ada_resolve_function (struct block_symbol *, int,
struct value **, int, const char *,
- struct type *);
+ struct type *, int);
static int ada_is_direct_array_type (struct type *);
return type is preferred. May change (expand) *EXP. */
static void
-resolve (expression_up *expp, int void_context_p)
+resolve (expression_up *expp, int void_context_p, int parse_completion)
{
struct type *context_type = NULL;
int pc = 0;
if (void_context_p)
context_type = builtin_type ((*expp)->gdbarch)->builtin_void;
- resolve_subexp (expp, &pc, 1, context_type);
+ resolve_subexp (expp, &pc, 1, context_type, parse_completion);
}
/* Resolve the operator of the subexpression beginning at
static struct value *
resolve_subexp (expression_up *expp, int *pos, int deprocedure_p,
- struct type *context_type)
+ struct type *context_type, int parse_completion)
{
int pc = *pos;
int i;
else
{
*pos += 3;
- resolve_subexp (expp, pos, 0, NULL);
+ resolve_subexp (expp, pos, 0, NULL, parse_completion);
}
nargs = longest_to_int (exp->elts[pc + 1].longconst);
break;
case UNOP_ADDR:
*pos += 1;
- resolve_subexp (expp, pos, 0, NULL);
+ resolve_subexp (expp, pos, 0, NULL, parse_completion);
break;
case UNOP_QUAL:
*pos += 3;
- resolve_subexp (expp, pos, 1, check_typedef (exp->elts[pc + 1].type));
+ resolve_subexp (expp, pos, 1, check_typedef (exp->elts[pc + 1].type),
+ parse_completion);
break;
case OP_ATR_MODULUS:
struct value *arg1;
*pos += 1;
- arg1 = resolve_subexp (expp, pos, 0, NULL);
+ arg1 = resolve_subexp (expp, pos, 0, NULL, parse_completion);
if (arg1 == NULL)
- resolve_subexp (expp, pos, 1, NULL);
+ resolve_subexp (expp, pos, 1, NULL, parse_completion);
else
- resolve_subexp (expp, pos, 1, value_type (arg1));
+ resolve_subexp (expp, pos, 1, value_type (arg1), parse_completion);
break;
}
argvec = XALLOCAVEC (struct value *, nargs + 1);
for (i = 0; i < nargs; i += 1)
- argvec[i] = resolve_subexp (expp, pos, 1, NULL);
+ argvec[i] = resolve_subexp (expp, pos, 1, NULL, parse_completion);
argvec[i] = NULL;
exp = expp->get ();
i = ada_resolve_function
(candidates.data (), n_candidates, NULL, 0,
SYMBOL_LINKAGE_NAME (exp->elts[pc + 2].symbol),
- context_type);
+ context_type, parse_completion);
if (i < 0)
error (_("Could not find a match for %s"),
SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol));
(candidates.data (), n_candidates,
argvec, nargs,
SYMBOL_LINKAGE_NAME (exp->elts[pc + 5].symbol),
- context_type);
+ context_type, parse_completion);
if (i < 0)
error (_("Could not find a match for %s"),
SYMBOL_PRINT_NAME (exp->elts[pc + 5].symbol));
&candidates);
i = ada_resolve_function (candidates.data (), n_candidates, argvec,
- nargs, ada_decoded_op_name (op), NULL);
+ nargs, ada_decoded_op_name (op), NULL,
+ parse_completion);
if (i < 0)
break;
static int
ada_resolve_function (struct block_symbol syms[],
int nsyms, struct value **args, int nargs,
- const char *name, struct type *context_type)
+ const char *name, struct type *context_type,
+ int parse_completion)
{
int fallback;
int k;
;
exp : exp ARROW field_name COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
write_exp_string (pstate, $3);
write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
exp : exp ARROW COMPLETE
{ struct stoken s;
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
s.ptr = "";
s.length = 0;
;
exp : exp ARROW '~' name COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_PTR);
write_destructor_name (pstate, $4);
write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp '.' field_name COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_exp_string (pstate, $3);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
exp : exp '.' COMPLETE
{ struct stoken s;
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
;
exp : exp '.' '~' name COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_destructor_name (pstate, $4);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
}
| STRUCT COMPLETE
{
- mark_completion_tag (TYPE_CODE_STRUCT, "", 0);
+ pstate->mark_completion_tag (TYPE_CODE_STRUCT,
+ "", 0);
$$ = NULL;
}
| STRUCT name COMPLETE
{
- mark_completion_tag (TYPE_CODE_STRUCT, $2.ptr,
- $2.length);
+ pstate->mark_completion_tag (TYPE_CODE_STRUCT,
+ $2.ptr, $2.length);
$$ = NULL;
}
| CLASS name
}
| CLASS COMPLETE
{
- mark_completion_tag (TYPE_CODE_STRUCT, "", 0);
+ pstate->mark_completion_tag (TYPE_CODE_STRUCT,
+ "", 0);
$$ = NULL;
}
| CLASS name COMPLETE
{
- mark_completion_tag (TYPE_CODE_STRUCT, $2.ptr,
- $2.length);
+ pstate->mark_completion_tag (TYPE_CODE_STRUCT,
+ $2.ptr, $2.length);
$$ = NULL;
}
| UNION name
}
| UNION COMPLETE
{
- mark_completion_tag (TYPE_CODE_UNION, "", 0);
+ pstate->mark_completion_tag (TYPE_CODE_UNION,
+ "", 0);
$$ = NULL;
}
| UNION name COMPLETE
{
- mark_completion_tag (TYPE_CODE_UNION, $2.ptr,
- $2.length);
+ pstate->mark_completion_tag (TYPE_CODE_UNION,
+ $2.ptr, $2.length);
$$ = NULL;
}
| ENUM name
}
| ENUM COMPLETE
{
- mark_completion_tag (TYPE_CODE_ENUM, "", 0);
+ pstate->mark_completion_tag (TYPE_CODE_ENUM, "", 0);
$$ = NULL;
}
| ENUM name COMPLETE
{
- mark_completion_tag (TYPE_CODE_ENUM, $2.ptr,
- $2.length);
+ pstate->mark_completion_tag (TYPE_CODE_ENUM, $2.ptr,
+ $2.length);
$$ = NULL;
}
| UNSIGNED type_name
saw_name_at_eof = 0;
return COMPLETE;
}
- else if (parse_completion && saw_structop)
+ else if (par_state->parse_completion && saw_structop)
return COMPLETE;
else
return 0;
if (*tokstart == '$')
return DOLLAR_VARIABLE;
- if (parse_completion && *pstate->lexptr == '\0')
+ if (pstate->parse_completion && *pstate->lexptr == '\0')
saw_name_at_eof = 1;
yylval.ssym.stoken = yylval.sval;
PrimaryExpression
| PostfixExpression '.' COMPLETE
{ struct stoken s;
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
write_exp_string (pstate, $3);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
| PostfixExpression '.' IDENTIFIER COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_exp_string (pstate, $3);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
/* Might be a floating point number. */
if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9')
{
- if (parse_completion)
+ if (pstate->parse_completion)
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
return NAME_OR_INT;
}
- if (parse_completion && *pstate->lexptr == '\0')
+ if (pstate->parse_completion && *pstate->lexptr == '\0')
saw_name_at_eof = 1;
return IDENTIFIER;
innermost_block_tracker_types
= INNERMOST_BLOCK_FOR_SYMBOLS);
-/* For use by parsers; set if we want to parse an expression and
- attempt completion. */
-extern int parse_completion;
-
/* From eval.c */
/* Values of NOSIDE argument to eval_subexp. */
;
exp : exp '.' name_not_typename COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_exp_string (pstate, $3.stoken);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
exp : exp '.' COMPLETE
{ struct stoken s;
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
/* Might be a floating point number. */
if (par_state->lexptr[1] < '0' || par_state->lexptr[1] > '9')
{
- if (parse_completion)
+ if (pstate->parse_completion)
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
if (*tokstart == '$')
return DOLLAR_VARIABLE;
- if (parse_completion && *par_state->lexptr == '\0')
+ if (pstate->parse_completion && *par_state->lexptr == '\0')
saw_name_at_eof = 1;
return NAME;
}
la_parser, perform any remaining processing necessary to complete
its translation. *EXPP may change; la_post_parser is responsible
for releasing its previous contents, if necessary. If
- VOID_CONTEXT_P, then no value is expected from the expression. */
+ VOID_CONTEXT_P, then no value is expected from the expression.
+ If COMPLETING is non-zero, then the expression has been parsed
+ for completion, not evaluation. */
- void (*la_post_parser) (expression_up *expp, int void_context_p);
+ void (*la_post_parser) (expression_up *expp, int void_context_p,
+ int completing);
void (*la_printchar) (int ch, struct type *chtype,
struct ui_file * stream);
}
;
exp : field_exp name COMPLETE
- { mark_struct_expression (pstate);
+ { pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_exp_string (pstate, $2);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : field_exp COMPLETE
{ struct stoken s;
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
switch (c = *tokstart)
{
case 0:
- if (search_field && parse_completion)
+ if (search_field && pstate->parse_completion)
return COMPLETE;
else
return 0;
innermost_block_tracker innermost_block;
static struct type_stack type_stack;
-/* True if parsing an expression to attempt completion. */
-int parse_completion;
-
-/* The index of the last struct expression directly before a '.' or
- '->'. This is set when parsing and is only used when completing a
- field name. It is -1 if no dereference operation was found. */
-static int expout_last_struct = -1;
-
-/* If we are completing a tagged type name, this will be nonzero. */
-static enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
-
-/* The token for tagged type name completion. */
-static gdb::unique_xmalloc_ptr<char> expout_completion_name;
-
\f
static unsigned int expressiondebug = 0;
static void
static int prefixify_subexp (struct expression *, struct expression *, int,
- int);
+ int, int);
static expression_up parse_exp_in_context (const char **, CORE_ADDR,
const struct block *, int,
int, int *,
- innermost_block_tracker_types);
+ innermost_block_tracker_types,
+ expr_completion_state *);
static void increase_expout_size (struct expr_builder *ps, size_t lenelt);
write_exp_elt_opcode (ps, OP_VAR_MSYM_VALUE);
}
-/* Mark the current index as the starting location of a structure
- expression. This is used when completing on field names. */
+/* See parser-defs.h. */
void
-mark_struct_expression (struct expr_builder *ps)
+parser_state::mark_struct_expression ()
{
gdb_assert (parse_completion
- && expout_tag_completion_type == TYPE_CODE_UNDEF);
- expout_last_struct = ps->expout_ptr;
+ && (m_completion_state.expout_tag_completion_type
+ == TYPE_CODE_UNDEF));
+ m_completion_state.expout_last_struct = expout_ptr;
}
/* Indicate that the current parser invocation is completing a tag.
start of the tag name. */
void
-mark_completion_tag (enum type_code tag, const char *ptr, int length)
+parser_state::mark_completion_tag (enum type_code tag, const char *ptr,
+ int length)
{
gdb_assert (parse_completion
- && expout_tag_completion_type == TYPE_CODE_UNDEF
- && expout_completion_name == NULL
- && expout_last_struct == -1);
+ && (m_completion_state.expout_tag_completion_type
+ == TYPE_CODE_UNDEF)
+ && m_completion_state.expout_completion_name == NULL
+ && m_completion_state.expout_last_struct == -1);
gdb_assert (tag == TYPE_CODE_UNION
|| tag == TYPE_CODE_STRUCT
|| tag == TYPE_CODE_ENUM);
- expout_tag_completion_type = tag;
- expout_completion_name.reset (xstrndup (ptr, length));
+ m_completion_state.expout_tag_completion_type = tag;
+ m_completion_state.expout_completion_name.reset (xstrndup (ptr, length));
}
\f
/* See comments on parser-defs.h. */
int
-prefixify_expression (struct expression *expr)
+prefixify_expression (struct expression *expr, int last_struct)
{
gdb_assert (expr->nelts > 0);
int len = sizeof (struct expression) + EXP_ELEM_TO_BYTES (expr->nelts);
/* Copy the original expression into temp. */
memcpy (temp, expr, len);
- return prefixify_subexp (temp, expr, inpos, outpos);
+ return prefixify_subexp (temp, expr, inpos, outpos, last_struct);
}
/* Return the number of exp_elements in the postfix subexpression
/* Copy the subexpression ending just before index INEND in INEXPR
into OUTEXPR, starting at index OUTBEG.
In the process, convert it from suffix to prefix form.
- If EXPOUT_LAST_STRUCT is -1, then this function always returns -1.
+ If LAST_STRUCT is -1, then this function always returns -1.
Otherwise, it returns the index of the subexpression which is the
- left-hand-side of the expression at EXPOUT_LAST_STRUCT. */
+ left-hand-side of the expression at LAST_STRUCT. */
static int
prefixify_subexp (struct expression *inexpr,
- struct expression *outexpr, int inend, int outbeg)
+ struct expression *outexpr, int inend, int outbeg,
+ int last_struct)
{
int oplen;
int args;
EXP_ELEM_TO_BYTES (oplen));
outbeg += oplen;
- if (expout_last_struct == inend)
+ if (last_struct == inend)
result = outbeg - oplen;
/* Find the lengths of the arg subexpressions. */
oplen = arglens[i];
inend += oplen;
- r = prefixify_subexp (inexpr, outexpr, inend, outbeg);
+ r = prefixify_subexp (inexpr, outexpr, inend, outbeg, last_struct);
if (r != -1)
{
/* Return immediately. We probably have only parsed a
int comma, innermost_block_tracker_types tracker_types)
{
return parse_exp_in_context (stringptr, pc, block, comma, 0, NULL,
- tracker_types);
+ tracker_types, nullptr);
}
/* As for parse_exp_1, except that if VOID_CONTEXT_P, then
parse_exp_in_context (const char **stringptr, CORE_ADDR pc,
const struct block *block,
int comma, int void_context_p, int *out_subexp,
- innermost_block_tracker_types tracker_types)
+ innermost_block_tracker_types tracker_types,
+ expr_completion_state *cstate)
{
const struct language_defn *lang = NULL;
int subexp;
type_stack.elements.clear ();
- expout_last_struct = -1;
- expout_tag_completion_type = TYPE_CODE_UNDEF;
- expout_completion_name.reset ();
innermost_block.reset (tracker_types);
if (*stringptr == 0 || **stringptr == 0)
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, comma, *stringptr);
+ expression_context_pc, comma, *stringptr,
+ cstate != nullptr);
scoped_restore_current_language lang_saver;
set_language (lang->la_language);
/* If parsing for completion, allow this to succeed; but if no
expression elements have been written, then there's nothing
to do, so fail. */
- if (! parse_completion || ps.expout_ptr == 0)
+ if (! ps.parse_completion || ps.expout_ptr == 0)
throw_exception (except);
}
END_CATCH
dump_raw_expression (result.get (), gdb_stdlog,
"before conversion to prefix form");
- subexp = prefixify_expression (result.get ());
+ subexp = prefixify_expression (result.get (),
+ ps.m_completion_state.expout_last_struct);
if (out_subexp)
*out_subexp = subexp;
- lang->la_post_parser (&result, void_context_p);
+ lang->la_post_parser (&result, void_context_p, ps.parse_completion);
if (expressiondebug)
dump_prefix_expression (result.get (), gdb_stdlog);
+ if (cstate != nullptr)
+ *cstate = std::move (ps.m_completion_state);
*stringptr = ps.lexptr;
return result;
}
expression_up exp;
struct value *val;
int subexp;
+ expr_completion_state cstate;
TRY
{
- parse_completion = 1;
exp = parse_exp_in_context (&string, 0, 0, 0, 0, &subexp,
- INNERMOST_BLOCK_FOR_SYMBOLS);
+ INNERMOST_BLOCK_FOR_SYMBOLS, &cstate);
}
CATCH (except, RETURN_MASK_ERROR)
{
}
END_CATCH
- parse_completion = 0;
if (exp == NULL)
return NULL;
- if (expout_tag_completion_type != TYPE_CODE_UNDEF)
+ if (cstate.expout_tag_completion_type != TYPE_CODE_UNDEF)
{
- *code = expout_tag_completion_type;
- *name = std::move (expout_completion_name);
+ *code = cstate.expout_tag_completion_type;
+ *name = std::move (cstate.expout_completion_name);
return NULL;
}
- if (expout_last_struct == -1)
+ if (cstate.expout_last_struct == -1)
return NULL;
const char *fieldname = extract_field_op (exp.get (), &subexp);
/* A post-parser that does nothing. */
void
-null_post_parser (expression_up *exp, int void_context_p)
+null_post_parser (expression_up *exp, int void_context_p, int completin)
{
}
size_t expout_ptr;
};
+/* This is used for expression completion. */
+
+struct expr_completion_state
+{
+ /* The index of the last struct expression directly before a '.' or
+ '->'. This is set when parsing and is only used when completing a
+ field name. It is -1 if no dereference operation was found. */
+ int expout_last_struct = -1;
+
+ /* If we are completing a tagged type name, this will be nonzero. */
+ enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
+
+ /* The token for tagged type name completion. */
+ gdb::unique_xmalloc_ptr<char> expout_completion_name;
+};
+
/* An instance of this type is instantiated during expression parsing,
and passed to the appropriate parser. It holds both inputs to the
parser, and result. */
const struct block *context_block,
CORE_ADDR context_pc,
int comma,
- const char *input)
+ const char *input,
+ int completion)
: expr_builder (lang, gdbarch),
expression_context_block (context_block),
expression_context_pc (context_pc),
comma_terminates (comma),
- lexptr (input)
+ lexptr (input),
+ parse_completion (completion)
{
}
return val;
}
+ /* Mark the current index as the starting location of a structure
+ expression. This is used when completing on field names. */
+
+ void mark_struct_expression ();
+
+ /* Indicate that the current parser invocation is completing a tag.
+ TAG is the type code of the tag, and PTR and LENGTH represent the
+ start of the tag name. */
+
+ void mark_completion_tag (enum type_code tag, const char *ptr, int length);
+
/* If this is nonzero, this block is used as the lexical context for
symbol names. */
int arglist_len = 0;
+ /* True if parsing an expression to attempt completion. */
+ int parse_completion;
+
+ /* Completion state is updated here. */
+ expr_completion_state m_completion_state;
+
private:
/* Data structure for saving values of arglist_len for function calls whose
/* Reverse an expression from suffix form (in which it is constructed)
to prefix form (in which we can conveniently print or execute it).
- Ordinarily this always returns -1. However, if EXPOUT_LAST_STRUCT
+ Ordinarily this always returns -1. However, if LAST_STRUCT
is not -1 (i.e., we are trying to complete a field name), it will
return the index of the subexpression which is the left-hand-side
- of the struct operation at EXPOUT_LAST_STRUCT. */
+ of the struct operation at LAST_STRUCT. */
-extern int prefixify_expression (struct expression *expr);
+extern int prefixify_expression (struct expression *expr,
+ int last_struct = -1);
extern void write_exp_elt_opcode (struct expr_builder *, enum exp_opcode);
extern void write_dollar_variable (struct parser_state *, struct stoken str);
-extern void mark_struct_expression (struct expr_builder *);
-
extern const char *find_template_name_end (const char *);
extern char *copy_name (struct stoken);
extern type_instance_flags follow_type_instance_flags ();
-extern void null_post_parser (expression_up *, int);
+extern void null_post_parser (expression_up *, int, int);
extern bool parse_float (const char *p, int len,
const struct type *type, gdb_byte *data);
extern int exp_uses_objfile (struct expression *exp, struct objfile *objfile);
-extern void mark_completion_tag (enum type_code, const char *ptr,
- int length);
-
#endif /* PARSER_DEFS_H */
return 0;
}
- if (token == NULL || (parse_completion && pstate->lexptr[0] == '\0'))
+ if (token == NULL || (pstate->parse_completion && pstate->lexptr[0] == '\0'))
lvalp->sval = make_stoken (copy_name (start, length));
- if (parse_completion && pstate->lexptr[0] == '\0')
+ if (pstate->parse_completion && pstate->lexptr[0] == '\0')
{
/* Prevent rustyylex from returning two COMPLETE tokens. */
pstate->prev_lexptr = pstate->lexptr;
pstate->prev_lexptr = pstate->lexptr;
if (pstate->lexptr[0] == '\0')
{
- if (parse_completion)
+ if (pstate->parse_completion)
{
lvalp->sval = make_stoken ("");
return COMPLETE;
convert_ast_to_expression (operation->left.op, top);
if (operation->completing)
- mark_struct_expression (pstate);
+ pstate->mark_struct_expression ();
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
write_exp_string (pstate, operation->right.sval);
write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
result = rustyyparse (&parser);
- if (!result || (parse_completion && parser.rust_ast != NULL))
+ if (!result || (state->parse_completion && parser.rust_ast != NULL))
parser.convert_ast_to_expression (parser.rust_ast, parser.rust_ast);
return result;
{
const int expected[] = { IDENT, '.', COMPLETE, 0 };
- parse_completion = 1;
+ parser->pstate->parse_completion = 1;
rust_lex_test_sequence (parser, "something.wha", ARRAY_SIZE (expected),
expected);
rust_lex_test_sequence (parser, "something.", ARRAY_SIZE (expected),
expected);
- parse_completion = 0;
+ parser->pstate->parse_completion = 0;
}
/* Test pushback. */
// Set up dummy "parser", so that rust_type works.
struct parser_state ps (&rust_language_defn, target_gdbarch (),
- nullptr, 0, 0, nullptr);
+ nullptr, 0, 0, nullptr, 0);
rust_parser parser (&ps);
rust_lex_test_one (&parser, "", 0);