/* Parser definitions for GDB.
- Copyright (C) 1986-2019 Free Software Foundation, Inc.
+ Copyright (C) 1986-2021 Free Software Foundation, Inc.
Modified from expread.y by the Department of Computer Science at the
State University of New York at Buffalo.
#if !defined (PARSER_DEFS_H)
#define PARSER_DEFS_H 1
-#include "gdbsupport/vec.h"
#include "expression.h"
+#include "symtab.h"
+#include "expop.h"
struct block;
struct language_defn;
struct internalvar;
class innermost_block_tracker;
-extern int parser_debug;
+extern bool parser_debug;
/* A class that can be used to build a "struct expression". */
return expout->language_defn;
}
+ /* Set the root operation of the expression that is currently being
+ built. */
+ void set_operation (expr::operation_up &&op)
+ {
+ expout->op = std::move (op);
+ }
+
/* The size of the expression above. */
size_t expout_size;
field name. It is -1 if no dereference operation was found. */
int expout_last_struct = -1;
+ /* The last struct expression directly before a '.' or '->'. This
+ is set when parsing and is only used when completing a field
+ name. It is nullptr if no dereference operation was found. */
+ expr::structop_base_operation *expout_last_op = nullptr;
+
/* If we are completing a tagged type name, this will be nonzero. */
enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
int comma,
const char *input,
int completion,
- innermost_block_tracker *tracker)
+ innermost_block_tracker *tracker,
+ bool void_p)
: expr_builder (lang, gdbarch),
expression_context_block (context_block),
expression_context_pc (context_pc),
comma_terminates (comma),
lexptr (input),
parse_completion (completion),
- block_tracker (tracker)
+ block_tracker (tracker),
+ void_context_p (void_p)
{
}
void mark_struct_expression ();
+ /* Mark the given operation as the starting location of a structure
+ expression. This is used when completing on field names. */
+
+ void mark_struct_expression (expr::structop_base_operation *op);
+
/* 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. */
/* The innermost block tracker. */
innermost_block_tracker *block_tracker;
+ /* True if no value is expected from the expression. */
+ bool void_context_p;
+
private:
/* Data structure for saving values of arglist_len for function calls whose
extern void write_dollar_variable (struct parser_state *, struct stoken str);
+/* Write a reference to a symbol to the expression being built in PS.
+ NAME is the name of the symbol to write; SYM is the symbol. If SYM
+ is nullptr (meaning the 'symbol' member), a minimal symbol will be
+ searched for and used if available. Throws an exception if SYM is
+ nullptr and no minimal symbol can be found. */
+
+extern void write_exp_symbol_reference (struct parser_state *ps,
+ const char *name,
+ struct block_symbol sym);
+
extern const char *find_template_name_end (const char *);
extern std::string copy_name (struct stoken);
extern int dump_subexp_body_standard (struct expression *,
struct ui_file *, int);
+/* Dump (to STREAM) a function call like expression at position ELT in the
+ expression array EXP. Return a new value for ELT just after the
+ function call expression. */
+
+extern int dump_subexp_body_funcall (struct expression *exp,
+ struct ui_file *stream, int elt);
+
extern void operator_length (const struct expression *, int, int *, int *);
extern void operator_length_standard (const struct expression *, int, int *,
(struct objfile *objfile, void *data),
void *data);
-extern const char *op_name_standard (enum exp_opcode);
-
-extern void null_post_parser (expression_up *, int, int,
- innermost_block_tracker *);
-
extern bool parse_float (const char *p, int len,
const struct type *type, gdb_byte *data);
\f
void *data),
void *data);
- /* Name of this operator for dumping purposes.
- The returned value should never be NULL, even if EXP_OPCODE is
- an unknown opcode (a string containing an image of the numeric
- value of the opcode can be returned, for instance). */
- const char *(*op_name) (enum exp_opcode);
-
/* Dump the rest of this (prefix) expression after the operator
itself has been printed. See dump_subexp_body_standard in
(expprint.c). */
extern void print_subexp_standard (struct expression *, int *,
struct ui_file *, enum precedence);
+/* Print a function call like expression to STREAM. This is called as a
+ helper function by which point the expression node identifying this as a
+ function call has already been stripped off and POS should point to the
+ number of function call arguments. EXP is the object containing the
+ list of expression elements. */
+
+extern void print_subexp_funcall (struct expression *exp, int *pos,
+ struct ui_file *stream);
+
/* Function used to avoid direct calls to fprintf
in the code generated by the bison parser. */