+2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ Remove some globals from our parser.
+ * language.c (unk_lang_parser): Add "struct parser_state"
+ argument.
+ * language.h (struct language_defn) <la_parser>: Likewise.
+ * parse.c (expout, expout_size, expout_ptr): Remove variables.
+ (initialize_expout): Add "struct parser_state" argument.
+ Rewrite function to use the parser state.
+ (reallocate_expout, write_exp_elt, write_exp_elt_opcode,
+ write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
+ write_exp_elt_longcst, write_exp_elt_dblcst,
+ write_exp_elt_decfloatcst, write_exp_elt_type,
+ write_exp_elt_intern, write_exp_string, write_exp_string_vector,
+ write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
+ write_dollar_variable): Likewise.
+ (parse_exp_in_context_1): Use parser state.
+ (insert_type_address_space): Add "struct parser_state" argument.
+ Use parser state.
+ (increase_expout_size): New function.
+ * parser-defs.h: Forward declare "struct language_defn" and
+ "struct parser_state".
+ (expout, expout_size, expout_ptr): Remove extern declarations.
+ (parse_gdbarch, parse_language): Rewrite macro declarations to
+ accept the parser state.
+ (struct parser_state): New struct.
+ (initialize_expout, reallocate_expout, write_exp_elt_opcode,
+ write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
+ write_exp_elt_decfloatcst, write_exp_elt_type,
+ write_exp_elt_intern, write_exp_string, write_exp_string_vector,
+ write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
+ write_exp_msymbol, write_dollar_variable,
+ mark_struct_expression, insert_type_address_space): Add "struct
+ parser_state" argument.
+ (increase_expout_size): New function.
+ * utils.c (do_clear_parser_state): New function.
+ (make_cleanup_clear_parser_state): Likewise.
+ * utils.h (make_cleanup_clear_parser_state): New function
+ prototype.
+ * aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
+ Update calls to write_exp* in order to pass the parser state.
+ * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
+ * i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
+ (i386_stap_parse_special_token_three_arg_disp): Likewise.
+ * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
+ * stap-probe.c (stap_parse_register_operand): Likewise.
+ (stap_parse_single_operand): Likewise.
+ (stap_parse_argument_1): Likewise.
+ (stap_parse_argument): Use parser state.
+ * stap-probe.h: Include "parser-defs.h".
+ (struct stap_parse_info) <pstate>: New field.
+ * c-exp.y (parse_type): Rewrite to use parser state.
+ (yyparse): Redefine to c_parse_internal.
+ (pstate): New global variable.
+ (parse_number): Add "struct parser_state" argument.
+ (write_destructor_name): Likewise.
+ (type_exp): Update calls to write_exp* and similars in order to
+ use parser state.
+ (exp1, exp, variable, qualified_name, space_identifier,
+ typename, typebase): Likewise.
+ (write_destructor_name, parse_number, lex_one_token,
+ classify_name, classify_inner_name, c_parse): Add "struct
+ parser_state" argument. Update function to use parser state.
+ * c-lang.h: Forward declare "struct parser_state".
+ (c_parse): Add "struct parser_state" argument.
+ * ada-exp.y (parse_type): Rewrite macro to use parser state.
+ (yyparse): Redefine macro to ada_parse_internal.
+ (pstate): New variable.
+ (write_int, write_object_renaming, write_var_or_type,
+ write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
+ type_int, type_long, type_long_long, type_float, type_double,
+ type_long_double, type_char, type_boolean, type_system_address):
+ Add "struct parser_state" argument.
+ (exp1, primary, simple_exp, relation, and_exp, and_then_exp,
+ or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
+ var_or_type, aggregate, aggregate_component_list,
+ positional_list, others, component_group,
+ component_associations): Update calls to write_exp* and similar
+ functions in order to use parser state.
+ (ada_parse, write_var_from_sym, write_int,
+ write_exp_op_with_string, write_object_renaming,
+ find_primitive_type, write_selectors, write_ambiguous_var,
+ write_var_or_type, write_name_assoc, type_int, type_long,
+ type_long_long, type_float, type_double, type_long_double,
+ type_char, type_boolean, type_system_address): Add "struct
+ parser_state" argument. Adjust function to use parser state.
+ * ada-lang.c (parse): Likewise.
+ * ada-lang.h: Forward declare "struct parser_state".
+ (ada_parse): Add "struct parser_state" argument.
+ * ada-lex.l (processInt, processReal): Likewise. Adjust all
+ calls to both functions.
+ * f-exp.y (parse_type, parse_f_type): Rewrite macros to use
+ parser state.
+ (yyparse): Redefine macro to f_parse_internal.
+ (pstate): New variable.
+ (parse_number): Add "struct parser_state" argument.
+ (type_exp, exp, subrange, typebase): Update calls to write_exp*
+ and similars in order to use parser state.
+ (parse_number): Adjust code to use parser state.
+ (yylex): Likewise.
+ (f_parse): New function.
+ * f-lang.h: Forward declare "struct parser_state".
+ (f_parse): Add "struct parser_state" argument.
+ * jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
+ parser state.
+ (yyparse): Redefine macro for java_parse_internal.
+ (pstate): New variable.
+ (push_expression_name, push_expression_name, insert_exp): Add
+ "struct parser_state" argument.
+ (type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
+ FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
+ FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
+ PostIncrementExpression, PostDecrementExpression,
+ UnaryExpression, PreIncrementExpression, PreDecrementExpression,
+ UnaryExpressionNotPlusMinus, CastExpression,
+ MultiplicativeExpression, AdditiveExpression, ShiftExpression,
+ RelationalExpression, EqualityExpression, AndExpression,
+ ExclusiveOrExpression, InclusiveOrExpression,
+ ConditionalAndExpression, ConditionalOrExpression,
+ ConditionalExpression, Assignment, LeftHandSide): Update
+ calls to write_exp* and similars in order to use parser state.
+ (parse_number): Ajust code to use parser state.
+ (yylex): Likewise.
+ (java_parse): New function.
+ (push_variable): Add "struct parser_state" argument. Adjust
+ code to user parser state.
+ (push_fieldnames, push_qualified_expression_name,
+ push_expression_name, insert_exp): Likewise.
+ * jv-lang.h: Forward declare "struct parser_state".
+ (java_parse): Add "struct parser_state" argument.
+ * m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
+ parser state.
+ (yyparse): Redefine macro to m2_parse_internal.
+ (pstate): New variable.
+ (type_exp, exp, fblock, variable, type): Update calls to
+ write_exp* and similars to use parser state.
+ (yylex): Likewise.
+ (m2_parse): New function.
+ * m2-lang.h: Forward declare "struct parser_state".
+ (m2_parse): Add "struct parser_state" argument.
+ * objc-lang.c (end_msglist): Add "struct parser_state" argument.
+ * objc-lang.h: Forward declare "struct parser_state".
+ (end_msglist): Add "struct parser_state" argument.
+ * p-exp.y (parse_type): Rewrite macro to use parser state.
+ (yyparse): Redefine macro to pascal_parse_internal.
+ (pstate): New variable.
+ (parse_number): Add "struct parser_state" argument.
+ (type_exp, exp1, exp, qualified_name, variable): Update calls to
+ write_exp* and similars in order to use parser state.
+ (parse_number, yylex): Adjust code to use parser state.
+ (pascal_parse): New function.
+ * p-lang.h: Forward declare "struct parser_state".
+ (pascal_parse): Add "struct parser_state" argument.
+ * go-exp.y (parse_type): Rewrite macro to use parser state.
+ (yyparse): Redefine macro to go_parse_internal.
+ (pstate): New variable.
+ (parse_number): Add "struct parser_state" argument.
+ (type_exp, exp1, exp, variable, type): Update calls to
+ write_exp* and similars in order to use parser state.
+ (parse_number, lex_one_token, classify_name, yylex): Adjust code
+ to use parser state.
+ (go_parse): Likewise.
+ * go-lang.h: Forward declare "struct parser_state".
+ (go_parse): Add "struct parser_state" argument.
+
2014-03-27 Doug Evans <dje@google.com>
* dwarf2read.c (read_str_index): Delete arg cu. All callers updated.
return 0;
/* The displacement. */
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (displacement);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, displacement);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (got_minus)
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
/* The register name. */
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname;
str.length = len;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, str);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
/* Casting to the expected type. */
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (&p->pstate, UNOP_IND);
p->arg = tmp;
}
#include "frame.h"
#include "block.h"
-#define parse_type builtin_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
without BISON? (PNH) */
#define yymaxdepth ada_maxdepth
-#define yyparse _ada_parse /* ada_parse calls this after initialization */
+/* ada_parse calls this after initialization */
+#define yyparse ada_parse_internal
#define yylex ada_lex
#define yyerror ada_error
#define yylval ada_lval
struct stoken stoken;
};
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
static struct stoken empty_stoken = { "", 0 };
/* If expression is in the context of TYPE'(...), then TYPE, else
void yyerror (char *);
-static void write_int (LONGEST, struct type *);
+static void write_int (struct parser_state *, LONGEST, struct type *);
-static void write_object_renaming (const struct block *, const char *, int,
+static void write_object_renaming (struct parser_state *,
+ const struct block *, const char *, int,
const char *, int);
-static struct type* write_var_or_type (const struct block *, struct stoken);
+static struct type* write_var_or_type (struct parser_state *,
+ const struct block *, struct stoken);
-static void write_name_assoc (struct stoken);
+static void write_name_assoc (struct parser_state *, struct stoken);
-static void write_exp_op_with_string (enum exp_opcode, struct stoken);
+static void write_exp_op_with_string (struct parser_state *, enum exp_opcode,
+ struct stoken);
static struct block *block_lookup (struct block *, const char *);
static LONGEST convert_char_literal (struct type *, LONGEST);
-static void write_ambiguous_var (const struct block *, char *, int);
+static void write_ambiguous_var (struct parser_state *,
+ const struct block *, char *, int);
-static struct type *type_int (void);
+static struct type *type_int (struct parser_state *);
-static struct type *type_long (void);
+static struct type *type_long (struct parser_state *);
-static struct type *type_long_long (void);
+static struct type *type_long_long (struct parser_state *);
-static struct type *type_float (void);
+static struct type *type_float (struct parser_state *);
-static struct type *type_double (void);
+static struct type *type_double (struct parser_state *);
-static struct type *type_long_double (void);
+static struct type *type_long_double (struct parser_state *);
-static struct type *type_char (void);
+static struct type *type_char (struct parser_state *);
-static struct type *type_boolean (void);
+static struct type *type_boolean (struct parser_state *);
-static struct type *type_system_address (void);
+static struct type *type_system_address (struct parser_state *);
%}
/* Expressions, including the sequencing operator. */
exp1 : exp
| exp1 ';' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
| primary ASSIGN exp /* Extension for convenience */
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
/* Expressions, not including the sequencing operator. */
primary : primary DOT_ALL
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
primary : primary DOT_ID
- { write_exp_op_with_string (STRUCTOP_STRUCT, $2); }
+ { write_exp_op_with_string (pstate, STRUCTOP_STRUCT,
+ $2); }
;
primary : primary '(' arglist ')'
{
- write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ($3);
- write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
}
| var_or_type '(' arglist ')'
{
{
if ($3 != 1)
error (_("Invalid conversion"));
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
}
else
{
- write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ($3);
- write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
}
}
;
{
if ($1 == NULL)
error (_("Type required for qualification"));
- write_exp_elt_opcode (UNOP_QUAL);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (UNOP_QUAL);
+ write_exp_elt_opcode (pstate, UNOP_QUAL);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, UNOP_QUAL);
type_qualifier = $3;
}
;
primary :
primary '(' simple_exp DOTDOT simple_exp ')'
- { write_exp_elt_opcode (TERNOP_SLICE); }
+ { write_exp_elt_opcode (pstate, TERNOP_SLICE); }
| var_or_type '(' simple_exp DOTDOT simple_exp ')'
{ if ($1 == NULL)
- write_exp_elt_opcode (TERNOP_SLICE);
+ write_exp_elt_opcode (pstate, TERNOP_SLICE);
else
error (_("Cannot slice a type"));
}
primary : var_or_type %prec VAR
{ if ($1 != NULL)
{
- write_exp_elt_opcode (OP_TYPE);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (OP_TYPE);
+ write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE);
}
}
;
primary : SPECIAL_VARIABLE /* Various GDB extensions */
- { write_dollar_variable ($1); }
+ { write_dollar_variable (pstate, $1); }
;
primary : aggregate
;
simple_exp : '-' simple_exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
simple_exp : '+' simple_exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PLUS); }
+ { write_exp_elt_opcode (pstate, UNOP_PLUS); }
;
simple_exp : NOT simple_exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
simple_exp : ABS simple_exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ABS); }
+ { write_exp_elt_opcode (pstate, UNOP_ABS); }
;
arglist : { $$ = 0; }
{
if ($2 == NULL)
error (_("Type required within braces in coercion"));
- write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_MEMVAL);
+ write_exp_elt_opcode (pstate, UNOP_MEMVAL);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_MEMVAL);
}
;
/* Binary operators in order of decreasing precedence. */
simple_exp : simple_exp STARSTAR simple_exp
- { write_exp_elt_opcode (BINOP_EXP); }
+ { write_exp_elt_opcode (pstate, BINOP_EXP); }
;
simple_exp : simple_exp '*' simple_exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
simple_exp : simple_exp '/' simple_exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
simple_exp : simple_exp REM simple_exp /* May need to be fixed to give correct Ada REM */
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
simple_exp : simple_exp MOD simple_exp
- { write_exp_elt_opcode (BINOP_MOD); }
+ { write_exp_elt_opcode (pstate, BINOP_MOD); }
;
simple_exp : simple_exp '@' simple_exp /* GDB extension */
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
simple_exp : simple_exp '+' simple_exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
simple_exp : simple_exp '&' simple_exp
- { write_exp_elt_opcode (BINOP_CONCAT); }
+ { write_exp_elt_opcode (pstate, BINOP_CONCAT); }
;
simple_exp : simple_exp '-' simple_exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
relation : simple_exp
;
relation : simple_exp '=' simple_exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
relation : simple_exp NOTEQUAL simple_exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
relation : simple_exp LEQ simple_exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
relation : simple_exp IN simple_exp DOTDOT simple_exp
- { write_exp_elt_opcode (TERNOP_IN_RANGE); }
+ { write_exp_elt_opcode (pstate, TERNOP_IN_RANGE); }
| simple_exp IN primary TICK_RANGE tick_arglist
- { write_exp_elt_opcode (BINOP_IN_BOUNDS);
- write_exp_elt_longcst ((LONGEST) $5);
- write_exp_elt_opcode (BINOP_IN_BOUNDS);
+ { write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
+ write_exp_elt_longcst (pstate, (LONGEST) $5);
+ write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
}
| simple_exp IN var_or_type %prec TICK_ACCESS
{
if ($3 == NULL)
error (_("Right operand of 'in' must be type"));
- write_exp_elt_opcode (UNOP_IN_RANGE);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_IN_RANGE);
+ write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
+ write_exp_elt_type (pstate, $3);
+ write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
}
| simple_exp NOT IN simple_exp DOTDOT simple_exp
- { write_exp_elt_opcode (TERNOP_IN_RANGE);
- write_exp_elt_opcode (UNOP_LOGICAL_NOT);
+ { write_exp_elt_opcode (pstate, TERNOP_IN_RANGE);
+ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
}
| simple_exp NOT IN primary TICK_RANGE tick_arglist
- { write_exp_elt_opcode (BINOP_IN_BOUNDS);
- write_exp_elt_longcst ((LONGEST) $6);
- write_exp_elt_opcode (BINOP_IN_BOUNDS);
- write_exp_elt_opcode (UNOP_LOGICAL_NOT);
+ { write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
+ write_exp_elt_longcst (pstate, (LONGEST) $6);
+ write_exp_elt_opcode (pstate, BINOP_IN_BOUNDS);
+ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
}
| simple_exp NOT IN var_or_type %prec TICK_ACCESS
{
if ($4 == NULL)
error (_("Right operand of 'in' must be type"));
- write_exp_elt_opcode (UNOP_IN_RANGE);
- write_exp_elt_type ($4);
- write_exp_elt_opcode (UNOP_IN_RANGE);
- write_exp_elt_opcode (UNOP_LOGICAL_NOT);
+ write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
+ write_exp_elt_type (pstate, $4);
+ write_exp_elt_opcode (pstate, UNOP_IN_RANGE);
+ write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT);
}
;
relation : simple_exp GEQ simple_exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
relation : simple_exp '<' simple_exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
relation : simple_exp '>' simple_exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : relation
and_exp :
relation _AND_ relation
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
| and_exp _AND_ relation
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
and_then_exp :
relation _AND_ THEN relation
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
| and_then_exp _AND_ THEN relation
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
or_exp :
relation OR relation
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
| or_exp OR relation
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
or_else_exp :
relation OR ELSE relation
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
| or_else_exp OR ELSE relation
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
xor_exp : relation XOR relation
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
| xor_exp XOR relation
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
/* Primaries can denote types (OP_TYPE). In cases such as
aType'access evaluates to a type that evaluate_subexp attempts to
evaluate. */
primary : primary TICK_ACCESS
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
| primary TICK_ADDRESS
- { write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (type_system_address ());
- write_exp_elt_opcode (UNOP_CAST);
+ { write_exp_elt_opcode (pstate, UNOP_ADDR);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate,
+ type_system_address (pstate));
+ write_exp_elt_opcode (pstate, UNOP_CAST);
}
| primary TICK_FIRST tick_arglist
- { write_int ($3, type_int ());
- write_exp_elt_opcode (OP_ATR_FIRST); }
+ { write_int (pstate, $3, type_int (pstate));
+ write_exp_elt_opcode (pstate, OP_ATR_FIRST); }
| primary TICK_LAST tick_arglist
- { write_int ($3, type_int ());
- write_exp_elt_opcode (OP_ATR_LAST); }
+ { write_int (pstate, $3, type_int (pstate));
+ write_exp_elt_opcode (pstate, OP_ATR_LAST); }
| primary TICK_LENGTH tick_arglist
- { write_int ($3, type_int ());
- write_exp_elt_opcode (OP_ATR_LENGTH); }
+ { write_int (pstate, $3, type_int (pstate));
+ write_exp_elt_opcode (pstate, OP_ATR_LENGTH); }
| primary TICK_SIZE
- { write_exp_elt_opcode (OP_ATR_SIZE); }
+ { write_exp_elt_opcode (pstate, OP_ATR_SIZE); }
| primary TICK_TAG
- { write_exp_elt_opcode (OP_ATR_TAG); }
+ { write_exp_elt_opcode (pstate, OP_ATR_TAG); }
| opt_type_prefix TICK_MIN '(' exp ',' exp ')'
- { write_exp_elt_opcode (OP_ATR_MIN); }
+ { write_exp_elt_opcode (pstate, OP_ATR_MIN); }
| opt_type_prefix TICK_MAX '(' exp ',' exp ')'
- { write_exp_elt_opcode (OP_ATR_MAX); }
+ { write_exp_elt_opcode (pstate, OP_ATR_MAX); }
| opt_type_prefix TICK_POS '(' exp ')'
- { write_exp_elt_opcode (OP_ATR_POS); }
+ { write_exp_elt_opcode (pstate, OP_ATR_POS); }
| type_prefix TICK_VAL '(' exp ')'
- { write_exp_elt_opcode (OP_ATR_VAL); }
+ { write_exp_elt_opcode (pstate, OP_ATR_VAL); }
| type_prefix TICK_MODULUS
- { write_exp_elt_opcode (OP_ATR_MODULUS); }
+ { write_exp_elt_opcode (pstate, OP_ATR_MODULUS); }
;
tick_arglist : %prec '('
{
if ($1 == NULL)
error (_("Prefix must be type"));
- write_exp_elt_opcode (OP_TYPE);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (OP_TYPE); }
+ write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE); }
;
opt_type_prefix :
type_prefix
| /* EMPTY */
- { write_exp_elt_opcode (OP_TYPE);
- write_exp_elt_type (parse_type->builtin_void);
- write_exp_elt_opcode (OP_TYPE); }
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_void);
+ write_exp_elt_opcode (pstate, OP_TYPE); }
;
primary : INT
- { write_int ((LONGEST) $1.val, $1.type); }
+ { write_int (pstate, (LONGEST) $1.val, $1.type); }
;
primary : CHARLIT
- { write_int (convert_char_literal (type_qualifier, $1.val),
+ { write_int (pstate,
+ convert_char_literal (type_qualifier, $1.val),
(type_qualifier == NULL)
? $1.type : type_qualifier);
}
;
primary : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE);
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE);
}
;
primary : NULL_PTR
- { write_int (0, type_int ()); }
+ { write_int (pstate, 0, type_int (pstate)); }
;
primary : STRING
{
- write_exp_op_with_string (OP_STRING, $1);
+ write_exp_op_with_string (pstate, OP_STRING, $1);
}
;
primary : TRUEKEYWORD
- { write_int (1, type_boolean ()); }
+ { write_int (pstate, 1, type_boolean (pstate)); }
| FALSEKEYWORD
- { write_int (0, type_boolean ()); }
+ { write_int (pstate, 0, type_boolean (pstate)); }
;
primary : NEW NAME
;
var_or_type: NAME %prec VAR
- { $$ = write_var_or_type (NULL, $1); }
+ { $$ = write_var_or_type (pstate, NULL, $1); }
| block NAME %prec VAR
- { $$ = write_var_or_type ($1, $2); }
+ { $$ = write_var_or_type (pstate, $1, $2); }
| NAME TICK_ACCESS
{
- $$ = write_var_or_type (NULL, $1);
+ $$ = write_var_or_type (pstate, NULL, $1);
if ($$ == NULL)
- write_exp_elt_opcode (UNOP_ADDR);
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
else
$$ = lookup_pointer_type ($$);
}
| block NAME TICK_ACCESS
{
- $$ = write_var_or_type ($1, $2);
+ $$ = write_var_or_type (pstate, $1, $2);
if ($$ == NULL)
- write_exp_elt_opcode (UNOP_ADDR);
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
else
$$ = lookup_pointer_type ($$);
}
aggregate :
'(' aggregate_component_list ')'
{
- write_exp_elt_opcode (OP_AGGREGATE);
- write_exp_elt_longcst ($2);
- write_exp_elt_opcode (OP_AGGREGATE);
+ write_exp_elt_opcode (pstate, OP_AGGREGATE);
+ write_exp_elt_longcst (pstate, $2);
+ write_exp_elt_opcode (pstate, OP_AGGREGATE);
}
;
aggregate_component_list :
component_groups { $$ = $1; }
| positional_list exp
- { write_exp_elt_opcode (OP_POSITIONAL);
- write_exp_elt_longcst ($1);
- write_exp_elt_opcode (OP_POSITIONAL);
+ { write_exp_elt_opcode (pstate, OP_POSITIONAL);
+ write_exp_elt_longcst (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_POSITIONAL);
$$ = $1 + 1;
}
| positional_list component_groups
positional_list :
exp ','
- { write_exp_elt_opcode (OP_POSITIONAL);
- write_exp_elt_longcst (0);
- write_exp_elt_opcode (OP_POSITIONAL);
+ { write_exp_elt_opcode (pstate, OP_POSITIONAL);
+ write_exp_elt_longcst (pstate, 0);
+ write_exp_elt_opcode (pstate, OP_POSITIONAL);
$$ = 1;
}
| positional_list exp ','
- { write_exp_elt_opcode (OP_POSITIONAL);
- write_exp_elt_longcst ($1);
- write_exp_elt_opcode (OP_POSITIONAL);
+ { write_exp_elt_opcode (pstate, OP_POSITIONAL);
+ write_exp_elt_longcst (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_POSITIONAL);
$$ = $1 + 1;
}
;
;
others : OTHERS ARROW exp
- { write_exp_elt_opcode (OP_OTHERS); }
+ { write_exp_elt_opcode (pstate, OP_OTHERS); }
;
component_group :
component_associations
{
- write_exp_elt_opcode (OP_CHOICES);
- write_exp_elt_longcst ($1);
- write_exp_elt_opcode (OP_CHOICES);
+ write_exp_elt_opcode (pstate, OP_CHOICES);
+ write_exp_elt_longcst (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_CHOICES);
}
;
resolved shift/reduce conflict. */
component_associations :
NAME ARROW
- { write_name_assoc ($1); }
+ { write_name_assoc (pstate, $1); }
exp { $$ = 1; }
| simple_exp ARROW exp
{ $$ = 1; }
| simple_exp DOTDOT simple_exp ARROW
- { write_exp_elt_opcode (OP_DISCRETE_RANGE);
- write_exp_op_with_string (OP_NAME, empty_stoken);
+ { write_exp_elt_opcode (pstate, OP_DISCRETE_RANGE);
+ write_exp_op_with_string (pstate, OP_NAME,
+ empty_stoken);
}
exp { $$ = 1; }
| NAME '|'
- { write_name_assoc ($1); }
+ { write_name_assoc (pstate, $1); }
component_associations { $$ = $4 + 1; }
| simple_exp '|'
component_associations { $$ = $3 + 1; }
| simple_exp DOTDOT simple_exp '|'
- { write_exp_elt_opcode (OP_DISCRETE_RANGE); }
+ { write_exp_elt_opcode (pstate, OP_DISCRETE_RANGE); }
component_associations { $$ = $6 + 1; }
;
can't get used to Ada notation in GDB. */
primary : '*' primary %prec '.'
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
| '&' primary %prec '.'
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
| primary '[' exp ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
%%
#include "ada-lex.c"
int
-ada_parse (void)
+ada_parse (struct parser_state *par_state)
{
+ int result;
+ struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
lexer_init (yyin); /* (Re-)initialize lexer. */
type_qualifier = NULL;
obstack_free (&temp_parse_space, NULL);
obstack_init (&temp_parse_space);
- return _ada_parse ();
+ result = yyparse ();
+ do_cleanups (c);
+ return result;
}
void
/* Emit expression to access an instance of SYM, in block BLOCK (if
* non-NULL), and with :: qualification ORIG_LEFT_CONTEXT. */
static void
-write_var_from_sym (const struct block *orig_left_context,
+write_var_from_sym (struct parser_state *par_state,
+ const struct block *orig_left_context,
const struct block *block,
struct symbol *sym)
{
innermost_block = block;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (block);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
+ write_exp_elt_block (par_state, block);
+ write_exp_elt_sym (par_state, sym);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
}
/* Write integer or boolean constant ARG of type TYPE. */
static void
-write_int (LONGEST arg, struct type *type)
+write_int (struct parser_state *par_state, LONGEST arg, struct type *type)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (type);
- write_exp_elt_longcst (arg);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (par_state, OP_LONG);
+ write_exp_elt_type (par_state, type);
+ write_exp_elt_longcst (par_state, arg);
+ write_exp_elt_opcode (par_state, OP_LONG);
}
/* Write an OPCODE, string, OPCODE sequence to the current expression. */
static void
-write_exp_op_with_string (enum exp_opcode opcode, struct stoken token)
+write_exp_op_with_string (struct parser_state *par_state,
+ enum exp_opcode opcode, struct stoken token)
{
- write_exp_elt_opcode (opcode);
- write_exp_string (token);
- write_exp_elt_opcode (opcode);
+ write_exp_elt_opcode (par_state, opcode);
+ write_exp_string (par_state, token);
+ write_exp_elt_opcode (par_state, opcode);
}
/* Emit expression corresponding to the renamed object named
* new encoding entirely (FIXME pnh 7/20/2007). */
static void
-write_object_renaming (const struct block *orig_left_context,
+write_object_renaming (struct parser_state *par_state,
+ const struct block *orig_left_context,
const char *renamed_entity, int renamed_entity_len,
const char *renaming_expr, int max_depth)
{
&inner_renaming_expr))
{
case ADA_NOT_RENAMING:
- write_var_from_sym (orig_left_context, sym_info.block, sym_info.sym);
+ write_var_from_sym (par_state, orig_left_context, sym_info.block,
+ sym_info.sym);
break;
case ADA_OBJECT_RENAMING:
- write_object_renaming (sym_info.block,
+ write_object_renaming (par_state, sym_info.block,
inner_renamed_entity, inner_renamed_entity_len,
inner_renaming_expr, max_depth - 1);
break;
switch (*renaming_expr) {
case 'A':
renaming_expr += 1;
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (par_state, UNOP_IND);
break;
case 'L':
slice_state = LOWER_BOUND;
if (next == renaming_expr)
goto BadEncoding;
renaming_expr = next;
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (type_int ());
- write_exp_elt_longcst ((LONGEST) val);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (par_state, OP_LONG);
+ write_exp_elt_type (par_state, type_int (par_state));
+ write_exp_elt_longcst (par_state, (LONGEST) val);
+ write_exp_elt_opcode (par_state, OP_LONG);
}
else
{
else if (SYMBOL_CLASS (index_sym_info.sym) == LOC_TYPEDEF)
/* Index is an old-style renaming symbol. */
index_sym_info.block = orig_left_context;
- write_var_from_sym (NULL, index_sym_info.block,
+ write_var_from_sym (par_state, NULL, index_sym_info.block,
index_sym_info.sym);
}
if (slice_state == SIMPLE_INDEX)
{
- write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) 1);
- write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_opcode (par_state, OP_FUNCALL);
+ write_exp_elt_longcst (par_state, (LONGEST) 1);
+ write_exp_elt_opcode (par_state, OP_FUNCALL);
}
else if (slice_state == LOWER_BOUND)
slice_state = UPPER_BOUND;
else if (slice_state == UPPER_BOUND)
{
- write_exp_elt_opcode (TERNOP_SLICE);
+ write_exp_elt_opcode (par_state, TERNOP_SLICE);
slice_state = SIMPLE_INDEX;
}
break;
strncpy (buf, renaming_expr, end - renaming_expr);
buf[end - renaming_expr] = '\000';
renaming_expr = end;
- write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
+ write_exp_op_with_string (par_state, STRUCTOP_STRUCT, field_name);
break;
}
}
static struct type*
-find_primitive_type (char *name)
+find_primitive_type (struct parser_state *par_state, char *name)
{
struct type *type;
- type = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch,
+ type = language_lookup_primitive_type_by_name (parse_language (par_state),
+ parse_gdbarch (par_state),
name);
if (type == NULL && strcmp ("system__address", name) == 0)
- type = type_system_address ();
+ type = type_system_address (par_state);
if (type != NULL)
{
<sep> is '__' or '.', write the indicated sequence of
STRUCTOP_STRUCT expression operators. */
static void
-write_selectors (char *sels)
+write_selectors (struct parser_state *par_state, char *sels)
{
while (*sels != '\0')
{
sels += 1;
field_name.length = sels - p;
field_name.ptr = p;
- write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
+ write_exp_op_with_string (par_state, STRUCTOP_STRUCT, field_name);
}
}
a temporary symbol that is valid until the next call to ada_parse.
*/
static void
-write_ambiguous_var (const struct block *block, char *name, int len)
+write_ambiguous_var (struct parser_state *par_state,
+ const struct block *block, char *name, int len)
{
struct symbol *sym =
obstack_alloc (&temp_parse_space, sizeof (struct symbol));
SYMBOL_LINKAGE_NAME (sym) = obstack_copy0 (&temp_parse_space, name, len);
SYMBOL_LANGUAGE (sym) = language_ada;
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (block);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
+ write_exp_elt_block (par_state, block);
+ write_exp_elt_sym (par_state, sym);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
}
/* A convenient wrapper around ada_get_field_index that takes
identifier). */
static struct type*
-write_var_or_type (const struct block *block, struct stoken name0)
+write_var_or_type (struct parser_state *par_state,
+ const struct block *block, struct stoken name0)
{
int depth;
char *encoded_name;
goto TryAfterRenaming;
}
case ADA_OBJECT_RENAMING:
- write_object_renaming (block, renaming, renaming_len,
+ write_object_renaming (par_state, block, renaming, renaming_len,
renaming_expr, MAX_RENAMING_CHAIN_LENGTH);
- write_selectors (encoded_name + tail_index);
+ write_selectors (par_state, encoded_name + tail_index);
return NULL;
default:
internal_error (__FILE__, __LINE__,
}
else if (tail_index == name_len && nsyms == 0)
{
- struct type *type = find_primitive_type (encoded_name);
+ struct type *type = find_primitive_type (par_state,
+ encoded_name);
if (type != NULL)
return type;
if (nsyms == 1)
{
- write_var_from_sym (block, syms[0].block, syms[0].sym);
- write_selectors (encoded_name + tail_index);
+ write_var_from_sym (par_state, block, syms[0].block,
+ syms[0].sym);
+ write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
else if (nsyms == 0)
= ada_lookup_simple_minsym (encoded_name);
if (msym.minsym != NULL)
{
- write_exp_msymbol (msym);
+ write_exp_msymbol (par_state, msym);
/* Maybe cause error here rather than later? FIXME? */
- write_selectors (encoded_name + tail_index);
+ write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
}
else
{
- write_ambiguous_var (block, encoded_name, tail_index);
- write_selectors (encoded_name + tail_index);
+ write_ambiguous_var (par_state, block, encoded_name,
+ tail_index);
+ write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
}
ambiguous name, one must write instead ((R) => 42). */
static void
-write_name_assoc (struct stoken name)
+write_name_assoc (struct parser_state *par_state, struct stoken name)
{
if (strchr (name.ptr, '.') == NULL)
{
int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
VAR_DOMAIN, &syms);
if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF)
- write_exp_op_with_string (OP_NAME, name);
+ write_exp_op_with_string (par_state, OP_NAME, name);
else
- write_var_from_sym (NULL, syms[0].block, syms[0].sym);
+ write_var_from_sym (par_state, NULL, syms[0].block, syms[0].sym);
}
else
- if (write_var_or_type (NULL, name) != NULL)
+ if (write_var_or_type (par_state, NULL, name) != NULL)
error (_("Invalid use of type."));
}
}
static struct type *
-type_int (void)
+type_int (struct parser_state *par_state)
{
- return parse_type->builtin_int;
+ return parse_type (par_state)->builtin_int;
}
static struct type *
-type_long (void)
+type_long (struct parser_state *par_state)
{
- return parse_type->builtin_long;
+ return parse_type (par_state)->builtin_long;
}
static struct type *
-type_long_long (void)
+type_long_long (struct parser_state *par_state)
{
- return parse_type->builtin_long_long;
+ return parse_type (par_state)->builtin_long_long;
}
static struct type *
-type_float (void)
+type_float (struct parser_state *par_state)
{
- return parse_type->builtin_float;
+ return parse_type (par_state)->builtin_float;
}
static struct type *
-type_double (void)
+type_double (struct parser_state *par_state)
{
- return parse_type->builtin_double;
+ return parse_type (par_state)->builtin_double;
}
static struct type *
-type_long_double (void)
+type_long_double (struct parser_state *par_state)
{
- return parse_type->builtin_long_double;
+ return parse_type (par_state)->builtin_long_double;
}
static struct type *
-type_char (void)
+type_char (struct parser_state *par_state)
{
- return language_string_char_type (parse_language, parse_gdbarch);
+ return language_string_char_type (parse_language (par_state),
+ parse_gdbarch (par_state));
}
static struct type *
-type_boolean (void)
+type_boolean (struct parser_state *par_state)
{
- return parse_type->builtin_bool;
+ return parse_type (par_state)->builtin_bool;
}
static struct type *
-type_system_address (void)
+type_system_address (struct parser_state *par_state)
{
struct type *type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch,
+ = language_lookup_primitive_type_by_name (parse_language (par_state),
+ parse_gdbarch (par_state),
"system__address");
- return type != NULL ? type : parse_type->builtin_data_ptr;
+ return type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
}
/* Provide a prototype to silence -Wmissing-prototypes. */
}
static int
-parse (void)
+parse (struct parser_state *ps)
{
warnings_issued = 0;
- return ada_parse ();
+ return ada_parse (ps);
}
static const struct exp_descriptor ada_exp_descriptor = {
struct frame_info;
struct inferior;
struct type_print_options;
+struct parser_state;
#include "value.h"
#include "gdbtypes.h"
const char *field_name,
int maybe_missing);
-extern int ada_parse (void); /* Defined in ada-exp.y */
+extern int ada_parse (struct parser_state *); /* Defined in ada-exp.y */
extern void ada_error (char *); /* Defined in ada-exp.y */
static char numbuf[NUMERAL_WIDTH];
static void canonicalizeNumeral (char *s1, const char *);
static struct stoken processString (const char*, int);
-static int processInt (const char *, const char *, const char *);
-static int processReal (const char *);
+static int processInt (struct parser_state *, const char *, const char *,
+ const char *);
+static int processReal (struct parser_state *, const char *);
static struct stoken processId (const char *, int);
static int processAttribute (const char *);
static int find_dot_all (const char *);
{NUM10}{POSEXP} {
canonicalizeNumeral (numbuf, yytext);
- return processInt (NULL, numbuf, strrchr(numbuf, 'e')+1);
+ return processInt (pstate, NULL, numbuf,
+ strrchr (numbuf, 'e') + 1);
}
{NUM10} {
canonicalizeNumeral (numbuf, yytext);
- return processInt (NULL, numbuf, NULL);
+ return processInt (pstate, NULL, numbuf, NULL);
}
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} {
canonicalizeNumeral (numbuf, yytext);
- return processInt (numbuf,
+ return processInt (pstate, numbuf,
strchr (numbuf, '#') + 1,
strrchr(numbuf, '#') + 1);
}
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#" {
canonicalizeNumeral (numbuf, yytext);
- return processInt (numbuf, strchr (numbuf, '#') + 1, NULL);
+ return processInt (pstate, numbuf, strchr (numbuf, '#') + 1,
+ NULL);
}
"0x"{HEXDIG}+ {
canonicalizeNumeral (numbuf, yytext+2);
- return processInt ("16#", numbuf, NULL);
+ return processInt (pstate, "16#", numbuf, NULL);
}
{NUM10}"."{NUM10}{EXP} {
canonicalizeNumeral (numbuf, yytext);
- return processReal (numbuf);
+ return processReal (pstate, numbuf);
}
{NUM10}"."{NUM10} {
canonicalizeNumeral (numbuf, yytext);
- return processReal (numbuf);
+ return processReal (pstate, numbuf);
}
{NUM10}"#"{NUM16}"."{NUM16}"#"{EXP} {
}
<INITIAL>"'"({GRAPHIC}|\")"'" {
- yylval.typed_val.type = type_char ();
+ yylval.typed_val.type = type_char (pstate);
yylval.typed_val.val = yytext[1];
return CHARLIT;
}
<INITIAL>"'[\""{HEXDIG}{2}"\"]'" {
int v;
- yylval.typed_val.type = type_char ();
+ yylval.typed_val.type = type_char (pstate);
sscanf (yytext+3, "%2x", &v);
yylval.typed_val.val = v;
return CHARLIT;
*/
static int
-processInt (const char *base0, const char *num0, const char *exp0)
+processInt (struct parser_state *par_state, const char *base0,
+ const char *num0, const char *exp0)
{
ULONGEST result;
long exp;
exp -= 1;
}
- if ((result >> (gdbarch_int_bit (parse_gdbarch)-1)) == 0)
- yylval.typed_val.type = type_int ();
- else if ((result >> (gdbarch_long_bit (parse_gdbarch)-1)) == 0)
- yylval.typed_val.type = type_long ();
- else if (((result >> (gdbarch_long_bit (parse_gdbarch)-1)) >> 1) == 0)
+ if ((result >> (gdbarch_int_bit (parse_gdbarch (par_state))-1)) == 0)
+ yylval.typed_val.type = type_int (par_state);
+ else if ((result >> (gdbarch_long_bit (parse_gdbarch (par_state))-1)) == 0)
+ yylval.typed_val.type = type_long (par_state);
+ else if (((result >> (gdbarch_long_bit (parse_gdbarch (par_state))-1)) >> 1) == 0)
{
/* We have a number representable as an unsigned integer quantity.
For consistency with the C treatment, we will treat it as an
assignment does the trick (no, it doesn't; read the reference manual).
*/
yylval.typed_val.type
- = builtin_type (parse_gdbarch)->builtin_unsigned_long;
+ = builtin_type (parse_gdbarch (par_state))->builtin_unsigned_long;
if (result & LONGEST_SIGN)
yylval.typed_val.val =
(LONGEST) (result & ~LONGEST_SIGN)
return INT;
}
else
- yylval.typed_val.type = type_long_long ();
+ yylval.typed_val.type = type_long_long (par_state);
yylval.typed_val.val = (LONGEST) result;
return INT;
}
static int
-processReal (const char *num0)
+processReal (struct parser_state *par_state, const char *num0)
{
sscanf (num0, "%" DOUBLEST_SCAN_FORMAT, &yylval.typed_val_float.dval);
- yylval.typed_val_float.type = type_float ();
- if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch)
+ yylval.typed_val_float.type = type_float (par_state);
+ if (sizeof(DOUBLEST) >= gdbarch_double_bit (parse_gdbarch (par_state))
/ TARGET_CHAR_BIT)
- yylval.typed_val_float.type = type_double ();
- if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch)
+ yylval.typed_val_float.type = type_double (par_state);
+ if (sizeof(DOUBLEST) >= gdbarch_long_double_bit (parse_gdbarch (par_state))
/ TARGET_CHAR_BIT)
- yylval.typed_val_float.type = type_long_double ();
+ yylval.typed_val_float.type = type_long_double (par_state);
return FLOAT;
}
return 0;
/* The displacement. */
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (displacement);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, displacement);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (got_minus)
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
/* The register name. */
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname;
str.length = len;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, str);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
/* Casting to the expected type. */
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (&p->pstate, UNOP_IND);
p->arg = tmp;
}
#include "typeprint.h"
#include "cp-abi.h"
-#define parse_type builtin_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (const char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *par_state,
+ const char *, int, int, YYSTYPE *);
static struct stoken operator_stoken (const char *);
static void check_parameter_typelist (VEC (type_ptr) *);
-static void write_destructor_name (struct stoken);
+static void write_destructor_name (struct parser_state *par_state,
+ struct stoken);
#ifdef YYBISON
static void c_print_token (FILE *file, int type, YYSTYPE value);
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);}
+ { write_exp_elt_opcode(pstate, OP_TYPE);
+ write_exp_elt_type(pstate, $1);
+ write_exp_elt_opcode(pstate, OP_TYPE);}
| TYPEOF '(' exp ')'
{
- write_exp_elt_opcode (OP_TYPEOF);
+ write_exp_elt_opcode (pstate, OP_TYPEOF);
}
| TYPEOF '(' type ')'
{
- write_exp_elt_opcode (OP_TYPE);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (OP_TYPE);
+ write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_TYPE);
}
| DECLTYPE '(' exp ')'
{
- write_exp_elt_opcode (OP_DECLTYPE);
+ write_exp_elt_opcode (pstate, OP_DECLTYPE);
}
;
/* Expressions, including the comma operator. */
exp1 : exp
| exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
;
/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
;
exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : '+' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PLUS); }
+ { write_exp_elt_opcode (pstate, UNOP_PLUS); }
;
exp : '!' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
exp : '~' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
;
exp : INCREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
;
exp : DECREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
;
exp : exp INCREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
;
exp : exp DECREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
;
exp : TYPEID '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (OP_TYPEID); }
+ { write_exp_elt_opcode (pstate, OP_TYPEID); }
;
exp : TYPEID '(' type_exp ')' %prec UNARY
- { write_exp_elt_opcode (OP_TYPEID); }
+ { write_exp_elt_opcode (pstate, OP_TYPEID); }
;
exp : SIZEOF exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
exp : exp ARROW name
- { write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp ARROW name COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ { mark_struct_expression (pstate);
+ 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 ();
- write_exp_elt_opcode (STRUCTOP_PTR);
+ mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ write_exp_string (pstate, s);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp ARROW '~' name
- { write_exp_elt_opcode (STRUCTOP_PTR);
- write_destructor_name ($4);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_destructor_name (pstate, $4);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp ARROW '~' name COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_destructor_name ($4);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ { mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_destructor_name (pstate, $4);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR); }
;
exp : exp ARROW qualified_name
{ /* exp->type::name becomes exp->*(&type::name) */
/* Note: this doesn't work if name is a
static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MPTR); }
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
+ write_exp_elt_opcode (pstate, STRUCTOP_MPTR); }
;
exp : exp ARROW_STAR exp
- { write_exp_elt_opcode (STRUCTOP_MPTR); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_MPTR); }
;
exp : exp '.' name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '.' name COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { mark_struct_expression (pstate);
+ 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 ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ write_exp_string (pstate, s);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '.' '~' name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_destructor_name ($4);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_destructor_name (pstate, $4);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '.' '~' name COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_destructor_name ($4);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_destructor_name (pstate, $4);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '.' qualified_name
{ /* exp.type::name becomes exp.*(&type::name) */
/* Note: this doesn't work if name is a
static member! FIXME */
- write_exp_elt_opcode (UNOP_ADDR);
- write_exp_elt_opcode (STRUCTOP_MEMBER); }
+ write_exp_elt_opcode (pstate, UNOP_ADDR);
+ write_exp_elt_opcode (pstate, STRUCTOP_MEMBER); }
;
exp : exp DOT_STAR exp
- { write_exp_elt_opcode (STRUCTOP_MEMBER); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_MEMBER); }
;
exp : exp '[' exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
exp : exp OBJC_LBRAC exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
/*
{
CORE_ADDR class;
- class = lookup_objc_class (parse_gdbarch,
+ class = lookup_objc_class (parse_gdbarch (pstate),
copy_name ($2.stoken));
if (class == 0)
error (_("%s is not an ObjC Class"),
copy_name ($2.stoken));
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) class);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) class);
+ write_exp_elt_opcode (pstate, OP_LONG);
start_msglist();
}
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
exp : OBJC_LBRAC CLASSNAME
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) $2.class);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) $2.class);
+ write_exp_elt_opcode (pstate, OP_LONG);
start_msglist();
}
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
exp : OBJC_LBRAC exp
{ start_msglist(); }
msglist ']'
- { write_exp_elt_opcode (OP_OBJC_MSGCALL);
- end_msglist();
- write_exp_elt_opcode (OP_OBJC_MSGCALL);
+ { write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
+ end_msglist (pstate);
+ write_exp_elt_opcode (pstate, OP_OBJC_MSGCALL);
}
;
being accumulated by an outer function call. */
{ start_arglist (); }
arglist ')' %prec ARROW
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
exp : UNKNOWN_CPP_NAME '('
{
/* This could potentially be a an argument defined
lookup function (Koenig). */
- write_exp_elt_opcode (OP_ADL_FUNC);
- write_exp_elt_block (expression_context_block);
- write_exp_elt_sym (NULL); /* Placeholder. */
- write_exp_string ($1.stoken);
- write_exp_elt_opcode (OP_ADL_FUNC);
+ write_exp_elt_opcode (pstate, OP_ADL_FUNC);
+ write_exp_elt_block (pstate,
+ expression_context_block);
+ write_exp_elt_sym (pstate,
+ NULL); /* Placeholder. */
+ write_exp_string (pstate, $1.stoken);
+ write_exp_elt_opcode (pstate, OP_ADL_FUNC);
/* This is to save the value of arglist_len
being accumulated by an outer function call. */
}
arglist ')' %prec ARROW
{
- write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL);
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
}
;
struct type *type_elt;
LONGEST len = VEC_length (type_ptr, type_list);
- write_exp_elt_opcode (TYPE_INSTANCE);
- write_exp_elt_longcst (len);
+ write_exp_elt_opcode (pstate, TYPE_INSTANCE);
+ write_exp_elt_longcst (pstate, len);
for (i = 0;
VEC_iterate (type_ptr, type_list, i, type_elt);
++i)
- write_exp_elt_type (type_elt);
- write_exp_elt_longcst(len);
- write_exp_elt_opcode (TYPE_INSTANCE);
+ write_exp_elt_type (pstate, type_elt);
+ write_exp_elt_longcst(pstate, len);
+ write_exp_elt_opcode (pstate, TYPE_INSTANCE);
VEC_free (type_ptr, type_list);
}
;
{ $$ = end_arglist () - 1; }
;
exp : lcurly arglist rcurly %prec ARROW
- { write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) $3);
- write_exp_elt_opcode (OP_ARRAY); }
+ { write_exp_elt_opcode (pstate, OP_ARRAY);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_longcst (pstate, (LONGEST) $3);
+ write_exp_elt_opcode (pstate, OP_ARRAY); }
;
exp : lcurly type_exp rcurly exp %prec UNARY
- { write_exp_elt_opcode (UNOP_MEMVAL_TYPE); }
+ { write_exp_elt_opcode (pstate, UNOP_MEMVAL_TYPE); }
;
exp : '(' type_exp ')' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST_TYPE); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); }
;
exp : '(' exp1 ')'
/* Binary operators in order of decreasing precedence. */
exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
exp : exp '%' exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
;
exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
;
exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
exp : exp ANDAND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
exp : exp OROR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
exp : exp '?' exp ':' exp %prec '?'
- { write_exp_elt_opcode (TERNOP_COND); }
+ { write_exp_elt_opcode (pstate, TERNOP_COND); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
exp : exp ASSIGN_MODIFY exp
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, $2);
+ write_exp_elt_opcode (pstate,
+ BINOP_ASSIGN_MODIFY); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_longcst (pstate, (LONGEST) ($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : CHAR
struct stoken_vector vec;
vec.len = 1;
vec.tokens = &$1;
- write_exp_string_vector ($1.type, &vec);
+ write_exp_string_vector (pstate, $1.type, &vec);
}
;
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
+ parse_number (pstate, $1.stoken.ptr,
+ $1.stoken.length, 0, &val);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val_int.type);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) val.typed_val_int.val);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : DECFLOAT
- { write_exp_elt_opcode (OP_DECFLOAT);
- write_exp_elt_type ($1.type);
- write_exp_elt_decfloatcst ($1.val);
- write_exp_elt_opcode (OP_DECFLOAT); }
+ { write_exp_elt_opcode (pstate, OP_DECFLOAT);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_decfloatcst (pstate, $1.val);
+ write_exp_elt_opcode (pstate, OP_DECFLOAT); }
;
exp : variable
exp : VARIABLE
{
- write_dollar_variable ($1);
+ write_dollar_variable (pstate, $1);
}
;
exp : SELECTOR '(' name ')'
{
- write_exp_elt_opcode (OP_OBJC_SELECTOR);
- write_exp_string ($3);
- write_exp_elt_opcode (OP_OBJC_SELECTOR); }
+ write_exp_elt_opcode (pstate, OP_OBJC_SELECTOR);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_OBJC_SELECTOR); }
;
exp : SIZEOF '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (lookup_signed_typename
- (parse_language, parse_gdbarch,
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, lookup_signed_typename
+ (parse_language (pstate),
+ parse_gdbarch (pstate),
"int"));
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (pstate,
+ (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : REINTERPRET_CAST '<' type_exp '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_REINTERPRET_CAST); }
+ { write_exp_elt_opcode (pstate,
+ UNOP_REINTERPRET_CAST); }
;
exp : STATIC_CAST '<' type_exp '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST_TYPE); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); }
;
exp : DYNAMIC_CAST '<' type_exp '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_DYNAMIC_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_DYNAMIC_CAST); }
;
exp : CONST_CAST '<' type_exp '>' '(' exp ')' %prec UNARY
{ /* We could do more error checking here, but
it doesn't seem worthwhile. */
- write_exp_elt_opcode (UNOP_CAST_TYPE); }
+ write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); }
;
string_exp:
}
}
- write_exp_string_vector (type, &$1);
+ write_exp_string_vector (pstate, type, &$1);
for (i = 0; i < $1.len; ++i)
free ($1.tokens[i].ptr);
free ($1.tokens);
exp : NSSTRING /* ObjC NextStep NSString constant
* of the form '@' '"' string '"'.
*/
- { write_exp_elt_opcode (OP_OBJC_NSSTRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_OBJC_NSSTRING); }
+ { write_exp_elt_opcode (pstate, OP_OBJC_NSSTRING);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_OBJC_NSSTRING); }
;
/* C++. */
exp : TRUEKEYWORD
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_bool);
- write_exp_elt_longcst ((LONGEST) 1);
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_bool);
+ write_exp_elt_longcst (pstate, (LONGEST) 1);
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : FALSEKEYWORD
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_bool);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_bool);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
/* end of C++. */
"parameters, not for \"%s\""),
copy_name ($1.stoken));
- write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
}
;
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* block_found is set by lookup_symbol. */
- write_exp_elt_block (block_found);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); }
+ write_exp_elt_block (pstate, block_found);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
qualified_name: TYPENAME COLONCOLON name
error (_("`%s' is not defined as an aggregate type."),
TYPE_SAFE_NAME (type));
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string ($3);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
+ write_exp_elt_type (pstate, type);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
}
| TYPENAME COLONCOLON '~' name
{
/* Check for valid destructor name. */
destructor_name_p (tmp_token.ptr, $1.type);
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string (tmp_token);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
+ write_exp_elt_type (pstate, type);
+ write_exp_string (pstate, tmp_token);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
}
| TYPENAME COLONCOLON name COLONCOLON name
{
VAR_DOMAIN, NULL);
if (sym)
{
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
break;
}
msymbol = lookup_bound_minimal_symbol (name);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* We want to use the selected frame, not
another more inner frame which happens to
be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
}
else if ($1.is_a_field_of_this)
{
|| contained_in (block_found,
innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($1.stoken);
- write_exp_elt_opcode (STRUCTOP_PTR);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_exp_string (pstate, $1.stoken);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
}
else
{
msymbol =
lookup_bound_minimal_symbol (arg);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
;
space_identifier : '@' NAME
- { insert_type_address_space (copy_name ($2.stoken)); }
+ { insert_type_address_space (pstate, copy_name ($2.stoken)); }
;
const_or_volatile: const_or_volatile_noopt
: TYPENAME
{ $$ = $1.type; }
| INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"int"); }
| LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| SHORT
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| LONG SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| SIGNED_KEYWORD LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| UNSIGNED LONG INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| LONG UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| LONG UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long"); }
| LONG LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| LONG LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| LONG LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| LONG LONG SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| SIGNED_KEYWORD LONG LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| SIGNED_KEYWORD LONG LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| UNSIGNED LONG LONG
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| UNSIGNED LONG LONG INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| LONG LONG UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| LONG LONG UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long long"); }
| SHORT INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| SHORT SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| SHORT SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| UNSIGNED SHORT INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| SHORT UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| SHORT UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short"); }
| DOUBLE_KEYWORD
- { $$ = lookup_typename (parse_language, parse_gdbarch,
- "double", (struct block *) NULL,
+ { $$ = lookup_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
+ "double",
+ (struct block *) NULL,
0); }
| LONG DOUBLE_KEYWORD
- { $$ = lookup_typename (parse_language, parse_gdbarch,
+ { $$ = lookup_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long double",
- (struct block *) NULL, 0); }
+ (struct block *) NULL,
+ 0); }
| STRUCT name
{ $$ = lookup_struct (copy_name ($2),
expression_context_block); }
$$ = NULL;
}
| UNSIGNED typename
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
TYPE_NAME($2.type)); }
| UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"int"); }
| SIGNED_KEYWORD typename
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"int"); }
/* It appears that this rule for templates is never
reduced; template recognition happens by lookahead
{
$$.stoken.ptr = "int";
$$.stoken.length = 3;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"int");
}
| LONG
{
$$.stoken.ptr = "long";
$$.stoken.length = 4;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"long");
}
| SHORT
{
$$.stoken.ptr = "short";
$$.stoken.length = 5;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
"short");
}
;
/* Like write_exp_string, but prepends a '~'. */
static void
-write_destructor_name (struct stoken token)
+write_destructor_name (struct parser_state *par_state, struct stoken token)
{
char *copy = alloca (token.length + 1);
token.ptr = copy;
++token.length;
- write_exp_string (token);
+ write_exp_string (par_state, token);
}
/* Returns a stoken of the operator name given by OP (which does not
/*** Needs some error checking for the float case ***/
static int
-parse_number (const char *buf, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state,
+ const char *buf, int len, int parsed_float, YYSTYPE *putithere)
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
here, and we do kind of silly things like cast to unsigned. */
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_decfloat;
+ = parse_type (par_state)->builtin_decfloat;
decimal_from_string (putithere->typed_val_decfloat.val, 4,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (par_state)),
+ p);
p[len - 2] = 'd';
return DECFLOAT;
}
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_decdouble;
+ = parse_type (par_state)->builtin_decdouble;
decimal_from_string (putithere->typed_val_decfloat.val, 8,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (par_state)),
+ p);
p[len - 2] = 'd';
return DECFLOAT;
}
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_declong;
+ = parse_type (par_state)->builtin_declong;
decimal_from_string (putithere->typed_val_decfloat.val, 16,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (par_state)),
+ p);
p[len - 2] = 'd';
return DECFLOAT;
}
- if (! parse_c_float (parse_gdbarch, p, len,
+ if (! parse_c_float (parse_gdbarch (par_state), p, len,
&putithere->typed_val_float.dval,
&putithere->typed_val_float.type))
return ERROR;
un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = parse_type->builtin_unsigned_int;
- signed_type = parse_type->builtin_int;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_int;
+ signed_type = parse_type (par_state)->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
- unsigned_type = parse_type->builtin_unsigned_long;
- signed_type = parse_type->builtin_long;
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long;
+ signed_type = parse_type (par_state)->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (parse_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch (par_state)))
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
- shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
+ shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
high_bit = (ULONGEST) 1 << shift;
- unsigned_type = parse_type->builtin_unsigned_long_long;
- signed_type = parse_type->builtin_long_long;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
+ signed_type = parse_type (par_state)->builtin_long_long;
}
putithere->typed_val_int.val = n;
/* Read one token, getting characters through lexptr. */
static int
-lex_one_token (int *is_quoted_name)
+lex_one_token (struct parser_state *par_state, int *is_quoted_name)
{
int c;
int namelen;
if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
{
if ((tokentab3[i].flags & FLAG_CXX) != 0
- && parse_language->la_language != language_cplus)
+ && parse_language (par_state)->la_language != language_cplus)
break;
lexptr += 3;
if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
{
if ((tokentab2[i].flags & FLAG_CXX) != 0
- && parse_language->la_language != language_cplus)
+ && parse_language (par_state)->la_language != language_cplus)
break;
lexptr += 2;
case '(':
paren_depth++;
lexptr++;
- if (parse_language->la_language == language_objc && c == '[')
+ if (parse_language (par_state)->la_language == language_objc
+ && c == '[')
return OBJC_LBRAC;
return c;
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
+ toktype = parse_number (par_state, tokstart, p - tokstart,
+ got_dot|got_e, &yylval);
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
const char *p = &tokstart[1];
size_t len = strlen ("entry");
- if (parse_language->la_language == language_objc)
+ if (parse_language (par_state)->la_language == language_objc)
{
size_t len = strlen ("selector");
if (strcmp (copy, ident_tokens[i].operator) == 0)
{
if ((ident_tokens[i].flags & FLAG_CXX) != 0
- && parse_language->la_language != language_cplus)
+ && parse_language (par_state)->la_language != language_cplus)
break;
if ((ident_tokens[i].flags & FLAG_SHADOW) != 0)
if (lookup_symbol (copy, expression_context_block,
VAR_DOMAIN,
- (parse_language->la_language == language_cplus
- ? &is_a_field_of_this
+ (parse_language (par_state)->la_language
+ == language_cplus ? &is_a_field_of_this
: NULL))
!= NULL)
{
IS_QUOTED_NAME is non-zero if the name token was originally quoted
in single quotes. */
static int
-classify_name (const struct block *block, int is_quoted_name)
+classify_name (struct parser_state *par_state, const struct block *block,
+ int is_quoted_name)
{
struct symbol *sym;
char *copy;
memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
sym = lookup_symbol (copy, block, VAR_DOMAIN,
- parse_language->la_name_of_this
+ parse_language (par_state)->la_name_of_this
? &is_a_field_of_this : NULL);
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, copy);
+ = language_lookup_primitive_type_by_name (parse_language (par_state),
+ parse_gdbarch (par_state),
+ copy);
if (yylval.tsym.type != NULL)
return TYPENAME;
/* See if it's an ObjC classname. */
- if (parse_language->la_language == language_objc && !sym)
+ if (parse_language (par_state)->la_language == language_objc && !sym)
{
- CORE_ADDR Class = lookup_objc_class (parse_gdbarch, copy);
+ CORE_ADDR Class = lookup_objc_class (parse_gdbarch (par_state), copy);
if (Class)
{
yylval.class.class = Class;
|| (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10)))
{
YYSTYPE newlval; /* Its value is ignored. */
- int hextype = parse_number (copy, yylval.sval.length, 0, &newlval);
+ int hextype = parse_number (par_state, copy, yylval.sval.length,
+ 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
if (sym == NULL
- && parse_language->la_language == language_cplus
+ && parse_language (par_state)->la_language == language_cplus
&& is_a_field_of_this.type == NULL
&& lookup_minimal_symbol (copy, NULL, NULL).minsym == NULL)
return UNKNOWN_CPP_NAME;
NULL if this is the first component of a name. */
static int
-classify_inner_name (const struct block *block, struct type *context)
+classify_inner_name (struct parser_state *par_state,
+ const struct block *block, struct type *context)
{
struct type *type;
char *copy;
if (context == NULL)
- return classify_name (block, 0);
+ return classify_name (par_state, block, 0);
type = check_typedef (context);
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
/* Read the first token and decide what to do. Most of the
subsequent code is C++-only; but also depends on seeing a "::" or
name-like token. */
- current.token = lex_one_token (&is_quoted_name);
+ current.token = lex_one_token (pstate, &is_quoted_name);
if (current.token == NAME)
- current.token = classify_name (expression_context_block, is_quoted_name);
- if (parse_language->la_language != language_cplus
+ current.token = classify_name (pstate, expression_context_block,
+ is_quoted_name);
+ if (parse_language (pstate)->la_language != language_cplus
|| (current.token != TYPENAME && current.token != COLONCOLON
&& current.token != FILENAME))
return current.token;
/* We ignore quoted names other than the very first one.
Subsequent ones do not have any special meaning. */
- current.token = lex_one_token (&ignore);
+ current.token = lex_one_token (pstate, &ignore);
current.value = yylval;
VEC_safe_push (token_and_value, token_fifo, ¤t);
int classification;
yylval = next->value;
- classification = classify_inner_name (search_block, context_type);
+ classification = classify_inner_name (pstate, search_block,
+ context_type);
/* We keep going until we either run out of names, or until
we have a qualified name which is not a type. */
if (classification != TYPENAME && classification != NAME)
}
int
-c_parse (void)
+c_parse (struct parser_state *par_state)
{
int result;
- struct cleanup *back_to = make_cleanup (free_current_contents,
- &expression_macro_scope);
+ struct cleanup *back_to;
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ back_to = make_cleanup (free_current_contents, &expression_macro_scope);
+ make_cleanup_clear_parser_state (&pstate);
/* Set up the scope for macro expansion. */
expression_macro_scope = NULL;
result = yyparse ();
do_cleanups (back_to);
+
return result;
}
struct ui_file;
struct language_arch_info;
struct type_print_options;
+struct parser_state;
#include "value.h"
#include "macroexp.h"
/* Defined in c-exp.y. */
-extern int c_parse (void);
+extern int c_parse (struct parser_state *);
extern void c_error (char *);
#include "block.h"
#include <ctype.h>
-#define parse_type builtin_type (parse_gdbarch)
-#define parse_f_type builtin_f_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
+#define parse_f_type(ps) builtin_f_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
generators need to be fixed instead of adding those names to this list. */
#define yymaxdepth f_maxdepth
-#define yyparse f_parse
+#define yyparse f_parse_internal
#define yylex f_lex
#define yyerror f_error
#define yylval f_lval
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (const char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *, const char *, int,
+ int, YYSTYPE *);
%}
%type <voidval> exp type_exp start variable
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE); }
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE); }
;
exp : '(' exp ')'
/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
;
exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : BOOL_NOT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
exp : '~' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
;
exp : SIZEOF exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
/* No more explicit array operators, we treat everything in F77 as
exp : exp '('
{ start_arglist (); }
arglist ')'
- { write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST); }
+ { write_exp_elt_opcode (pstate,
+ OP_F77_UNDETERMINED_ARGLIST);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate,
+ OP_F77_UNDETERMINED_ARGLIST); }
;
arglist :
/* There are four sorts of subrange types in F90. */
subrange: exp ':' exp %prec ABOVE_COMMA
- { write_exp_elt_opcode (OP_F90_RANGE);
- write_exp_elt_longcst (NONE_BOUND_DEFAULT);
- write_exp_elt_opcode (OP_F90_RANGE); }
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
subrange: exp ':' %prec ABOVE_COMMA
- { write_exp_elt_opcode (OP_F90_RANGE);
- write_exp_elt_longcst (HIGH_BOUND_DEFAULT);
- write_exp_elt_opcode (OP_F90_RANGE); }
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
subrange: ':' exp %prec ABOVE_COMMA
- { write_exp_elt_opcode (OP_F90_RANGE);
- write_exp_elt_longcst (LOW_BOUND_DEFAULT);
- write_exp_elt_opcode (OP_F90_RANGE); }
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
subrange: ':' %prec ABOVE_COMMA
- { write_exp_elt_opcode (OP_F90_RANGE);
- write_exp_elt_longcst (BOTH_BOUND_DEFAULT);
- write_exp_elt_opcode (OP_F90_RANGE); }
+ { write_exp_elt_opcode (pstate, OP_F90_RANGE);
+ write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
+ write_exp_elt_opcode (pstate, OP_F90_RANGE); }
;
complexnum: exp ',' exp
;
exp : '(' complexnum ')'
- { write_exp_elt_opcode(OP_COMPLEX);
- write_exp_elt_type (parse_f_type->builtin_complex_s16);
- write_exp_elt_opcode(OP_COMPLEX); }
+ { write_exp_elt_opcode (pstate, OP_COMPLEX);
+ write_exp_elt_type (pstate,
+ parse_f_type (pstate)
+ ->builtin_complex_s16);
+ write_exp_elt_opcode (pstate, OP_COMPLEX); }
;
exp : '(' type ')' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
;
exp : exp '%' name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
/* Binary operators in order of decreasing precedence. */
exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
exp : exp STARSTAR exp
- { write_exp_elt_opcode (BINOP_EXP); }
+ { write_exp_elt_opcode (pstate, BINOP_EXP); }
;
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
;
exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
;
exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
exp : exp LESSTHAN exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
exp : exp GREATERTHAN exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
exp : exp BOOL_AND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
exp : exp BOOL_OR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
exp : exp ASSIGN_MODIFY exp
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, $2);
+ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_longcst (pstate, (LONGEST) ($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val.val);
- write_exp_elt_opcode (OP_LONG); }
+ parse_number (pstate, $1.stoken.ptr,
+ $1.stoken.length, 0, &val);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val.type);
+ write_exp_elt_longcst (pstate,
+ (LONGEST)val.typed_val.val);
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (parse_f_type->builtin_real_s8);
- write_exp_elt_dblcst ($1);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate,
+ parse_f_type (pstate)
+ ->builtin_real_s8);
+ write_exp_elt_dblcst (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : variable
;
exp : SIZEOF '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_f_type->builtin_integer);
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_f_type (pstate)
+ ->builtin_integer);
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (pstate,
+ (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : BOOLEAN_LITERAL
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_BOOL);
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_BOOL);
}
;
exp : STRING_LITERAL
{
- write_exp_elt_opcode (OP_STRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_STRING);
+ write_exp_elt_opcode (pstate, OP_STRING);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_STRING);
}
;
innermost_block))
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* We want to use the selected frame, not
another more inner frame which happens to
be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
break;
}
else
msymbol =
lookup_bound_minimal_symbol (arg);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
{
range_type =
create_range_type ((struct type *) NULL,
- parse_f_type->builtin_integer,
+ parse_f_type (pstate)
+ ->builtin_integer,
0, array_size - 1);
follow_type =
create_array_type ((struct type *) NULL,
: TYPENAME
{ $$ = $1.type; }
| INT_KEYWORD
- { $$ = parse_f_type->builtin_integer; }
+ { $$ = parse_f_type (pstate)->builtin_integer; }
| INT_S2_KEYWORD
- { $$ = parse_f_type->builtin_integer_s2; }
+ { $$ = parse_f_type (pstate)->builtin_integer_s2; }
| CHARACTER
- { $$ = parse_f_type->builtin_character; }
+ { $$ = parse_f_type (pstate)->builtin_character; }
| LOGICAL_S8_KEYWORD
- { $$ = parse_f_type->builtin_logical_s8; }
+ { $$ = parse_f_type (pstate)->builtin_logical_s8; }
| LOGICAL_KEYWORD
- { $$ = parse_f_type->builtin_logical; }
+ { $$ = parse_f_type (pstate)->builtin_logical; }
| LOGICAL_S2_KEYWORD
- { $$ = parse_f_type->builtin_logical_s2; }
+ { $$ = parse_f_type (pstate)->builtin_logical_s2; }
| LOGICAL_S1_KEYWORD
- { $$ = parse_f_type->builtin_logical_s1; }
+ { $$ = parse_f_type (pstate)->builtin_logical_s1; }
| REAL_KEYWORD
- { $$ = parse_f_type->builtin_real; }
+ { $$ = parse_f_type (pstate)->builtin_real; }
| REAL_S8_KEYWORD
- { $$ = parse_f_type->builtin_real_s8; }
+ { $$ = parse_f_type (pstate)->builtin_real_s8; }
| REAL_S16_KEYWORD
- { $$ = parse_f_type->builtin_real_s16; }
+ { $$ = parse_f_type (pstate)->builtin_real_s16; }
| COMPLEX_S8_KEYWORD
- { $$ = parse_f_type->builtin_complex_s8; }
+ { $$ = parse_f_type (pstate)->builtin_complex_s8; }
| COMPLEX_S16_KEYWORD
- { $$ = parse_f_type->builtin_complex_s16; }
+ { $$ = parse_f_type (pstate)->builtin_complex_s16; }
| COMPLEX_S32_KEYWORD
- { $$ = parse_f_type->builtin_complex_s32; }
+ { $$ = parse_f_type (pstate)->builtin_complex_s32; }
;
nonempty_typelist
/*** Needs some error checking for the float case ***/
static int
-parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state,
+ const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
LONGEST n = 0;
LONGEST prevn = 0;
are the same size. So we shift it twice, with fewer bits
each time, for the same result. */
- if ((gdbarch_int_bit (parse_gdbarch) != gdbarch_long_bit (parse_gdbarch)
+ if ((gdbarch_int_bit (parse_gdbarch (par_state))
+ != gdbarch_long_bit (parse_gdbarch (par_state))
&& ((n >> 2)
- >> (gdbarch_int_bit (parse_gdbarch)-2))) /* Avoid shift warning */
+ >> (gdbarch_int_bit (parse_gdbarch (par_state))-2))) /* Avoid
+ shift warning */
|| long_p)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch)-1);
- unsigned_type = parse_type->builtin_unsigned_long;
- signed_type = parse_type->builtin_long;
+ high_bit = ((ULONGEST)1)
+ << (gdbarch_long_bit (parse_gdbarch (par_state))-1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long;
+ signed_type = parse_type (par_state)->builtin_long;
}
else
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch)-1);
- unsigned_type = parse_type->builtin_unsigned_int;
- signed_type = parse_type->builtin_int;
+ high_bit =
+ ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_int;
+ signed_type = parse_type (par_state)->builtin_int;
}
putithere->typed_val.val = n;
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart, p - tokstart, got_dot|got_e|got_d,
+ toktype = parse_number (pstate, tokstart, p - tokstart,
+ got_dot|got_e|got_d,
&yylval);
if (toktype == ERROR)
{
if (*tokstart == '$')
{
- write_dollar_variable (yylval.sval);
+ write_dollar_variable (pstate, yylval.sval);
return VARIABLE;
}
sym = lookup_symbol (tmp, expression_context_block,
lookup_domains[i],
- parse_language->la_language == language_cplus
- ? &is_a_field_of_this : NULL);
+ parse_language (pstate)->la_language
+ == language_cplus ? &is_a_field_of_this : NULL);
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
yylval.tsym.type = SYMBOL_TYPE (sym);
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language (pstate),
+ parse_gdbarch (pstate), tmp);
if (yylval.tsym.type != NULL)
return TYPENAME;
|| (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
{
YYSTYPE newlval; /* Its value is ignored. */
- hextype = parse_number (tokstart, namelen, 0, &newlval);
+ hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = sym;
}
}
+int
+f_parse (struct parser_state *par_state)
+{
+ int result;
+ struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ result = yyparse ();
+ do_cleanups (c);
+ return result;
+}
+
void
yyerror (char *msg)
{
along with this program. If not, see <http://www.gnu.org/licenses/>. */
struct type_print_options;
+struct parser_state;
-extern int f_parse (void);
+extern int f_parse (struct parser_state *);
extern void f_error (char *); /* Defined in f-exp.y */
#include "charset.h"
#include "block.h"
-#define parse_type builtin_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
%{
/* YYSTYPE gets defined by %union. */
-static int parse_number (const char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *,
+ const char *, int, int, YYSTYPE *);
static int parse_go_float (struct gdbarch *gdbarch, const char *p, int len,
DOUBLEST *d, struct type **t);
%}
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE); }
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE); }
;
/* Expressions, including the comma operator. */
exp1 : exp
| exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
;
/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (pstate, UNOP_ADDR); }
;
exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : '+' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PLUS); }
+ { write_exp_elt_opcode (pstate, UNOP_PLUS); }
;
exp : '!' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
exp : '^' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
;
exp : exp INCREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
;
exp : exp DECREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
;
/* foo->bar is not in Go. May want as a gdb extension. Later. */
exp : exp '.' name_not_typename
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3.stoken);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $3.stoken);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '.' name_not_typename COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3.stoken);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { mark_struct_expression (pstate);
+ 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 ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ write_exp_string (pstate, s);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '[' exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
exp : exp '('
being accumulated by an outer function call. */
{ start_arglist (); }
arglist ')' %prec LEFT_ARROW
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
lcurly : '{'
;
exp : lcurly type rcurly exp %prec UNARY
- { write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_MEMVAL); }
+ { write_exp_elt_opcode (pstate, UNOP_MEMVAL);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
;
exp : type '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
;
exp : '(' exp1 ')'
/* Binary operators in order of decreasing precedence. */
exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
exp : exp '%' exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
;
exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
;
exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
exp : exp ANDAND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
exp : exp OROR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
exp : exp '?' exp ':' exp %prec '?'
- { write_exp_elt_opcode (TERNOP_COND); }
+ { write_exp_elt_opcode (pstate, TERNOP_COND); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
exp : exp ASSIGN_MODIFY exp
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, $2);
+ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_longcst (pstate, (LONGEST)($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : CHAR
struct stoken_vector vec;
vec.len = 1;
vec.tokens = &$1;
- write_exp_string_vector ($1.type, &vec);
+ write_exp_string_vector (pstate, $1.type, &vec);
}
;
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr, $1.stoken.length,
- 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)
+ parse_number (pstate, $1.stoken.ptr,
+ $1.stoken.length, 0, &val);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val_int.type);
+ write_exp_elt_longcst (pstate, (LONGEST)
val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : variable
exp : DOLLAR_VARIABLE
{
- write_dollar_variable ($1);
+ write_dollar_variable (pstate, $1);
}
;
exp : SIZEOF_KEYWORD '(' type ')' %prec UNARY
{
/* TODO(dje): Go objects in structs. */
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
/* TODO(dje): What's the right type here? */
- write_exp_elt_type (parse_type->builtin_unsigned_int);
+ write_exp_elt_type
+ (pstate,
+ parse_type (pstate)->builtin_unsigned_int);
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : SIZEOF_KEYWORD '(' exp ')' %prec UNARY
{
/* TODO(dje): Go objects in structs. */
- write_exp_elt_opcode (UNOP_SIZEOF);
+ write_exp_elt_opcode (pstate, UNOP_SIZEOF);
}
string_exp:
{
int i;
- write_exp_string_vector (0 /*always utf8*/, &$1);
+ write_exp_string_vector (pstate, 0 /*always utf8*/,
+ &$1);
for (i = 0; i < $1.len; ++i)
free ($1.tokens[i].ptr);
free ($1.tokens);
;
exp : TRUE_KEYWORD
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
exp : FALSE_KEYWORD
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
variable: name_not_typename ENTRY
"parameters, not for \"%s\""),
copy_name ($1.stoken));
- write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_ENTRY_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_ENTRY_VALUE);
}
;
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* We want to use the selected frame, not
another more inner frame which happens to
be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
}
else if ($1.is_a_field_of_this)
{
msymbol =
lookup_bound_minimal_symbol (arg);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
expression_context_block); }
*/
| BYTE_KEYWORD
- { $$ = builtin_go_type (parse_gdbarch)
+ { $$ = builtin_go_type (parse_gdbarch (pstate))
->builtin_uint8; }
;
as our YYSTYPE is different than c-exp.y's */
static int
-parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state,
+ const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
here, and we do kind of silly things like cast to unsigned. */
if (parsed_float)
{
- if (! parse_go_float (parse_gdbarch, p, len,
+ if (! parse_go_float (parse_gdbarch (par_state), p, len,
&putithere->typed_val_float.dval,
&putithere->typed_val_float.type))
return ERROR;
un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = parse_type->builtin_unsigned_int;
- signed_type = parse_type->builtin_int;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_int;
+ signed_type = parse_type (par_state)->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
- unsigned_type = parse_type->builtin_unsigned_long;
- signed_type = parse_type->builtin_long;
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long;
+ signed_type = parse_type (par_state)->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (parse_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch (par_state)))
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
- shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
+ shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
high_bit = (ULONGEST) 1 << shift;
- unsigned_type = parse_type->builtin_unsigned_long_long;
- signed_type = parse_type->builtin_long_long;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
+ signed_type = parse_type (par_state)->builtin_long_long;
}
putithere->typed_val_int.val = n;
/* Read one token, getting characters through lexptr. */
static int
-lex_one_token (void)
+lex_one_token (struct parser_state *par_state)
{
int c;
int namelen;
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
+ toktype = parse_number (par_state, tokstart, p - tokstart,
+ got_dot|got_e, &yylval);
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
The result is one of NAME, NAME_OR_INT, or TYPENAME. */
static int
-classify_name (const struct block *block)
+classify_name (struct parser_state *par_state, const struct block *block)
{
struct type *type;
struct symbol *sym;
copy = copy_name (yylval.sval);
/* Try primitive types first so they win over bad/weird debug info. */
- type = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, copy);
+ type = language_lookup_primitive_type_by_name (parse_language (par_state),
+ parse_gdbarch (par_state),
+ copy);
if (type != NULL)
{
/* NOTE: We take advantage of the fact that yylval coming in was a
|| (copy[0] >= 'A' && copy[0] < 'A' + input_radix - 10))
{
YYSTYPE newlval; /* Its value is ignored. */
- int hextype = parse_number (copy, yylval.sval.length, 0, &newlval);
+ int hextype = parse_number (par_state, copy, yylval.sval.length,
+ 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = NULL;
}
popping = 0;
- current.token = lex_one_token ();
+ current.token = lex_one_token (pstate);
/* TODO: Need a way to force specifying name1 as a package.
.name1.name2 ? */
/* See if we have "name1 . name2". */
current.value = yylval;
- next.token = lex_one_token ();
+ next.token = lex_one_token (pstate);
next.value = yylval;
if (next.token == '.')
{
token_and_value name2;
- name2.token = lex_one_token ();
+ name2.token = lex_one_token (pstate);
name2.value = yylval;
if (name2.token == NAME)
popping = 1;
yylval = current.value;
- return classify_name (expression_context_block);
+ return classify_name (pstate, expression_context_block);
}
int
-go_parse (void)
+go_parse (struct parser_state *par_state)
{
int result;
- struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
+ struct cleanup *back_to;
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ back_to = make_cleanup (null_cleanup, NULL);
make_cleanup_restore_integer (&yydebug);
+ make_cleanup_clear_parser_state (&pstate);
yydebug = parser_debug;
/* Initialize some state used by the lexer. */
#include "symtab.h"
#include "value.h"
+struct parser_state;
+
struct builtin_go_type
{
struct type *builtin_void;
/* Defined in go-exp.y. */
-extern int go_parse (void);
+extern int go_parse (struct parser_state *);
extern void go_error (char *);
for (i = 0; i < 3; i++)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (displacements[i]);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type
+ (&p->pstate, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, displacements[i]);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (got_minus[i])
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
}
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname;
str.length = len;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, str);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_data_ptr);
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate,
+ builtin_type (gdbarch)->builtin_data_ptr);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (BINOP_ADD);
- write_exp_elt_opcode (BINOP_ADD);
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate,
+ lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (&p->pstate, UNOP_IND);
p->arg = s;
if (offset)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (offset);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate,
+ builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, offset);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (offset_minus)
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
}
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
base_token.ptr = base;
base_token.length = len_base;
- write_exp_string (base_token);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, base_token);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
if (offset)
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
index_token.ptr = index;
index_token.length = len_index;
- write_exp_string (index_token);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, index_token);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
if (size)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (size);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate,
+ builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, size);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (size_minus)
- write_exp_elt_opcode (UNOP_NEG);
- write_exp_elt_opcode (BINOP_MUL);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, BINOP_MUL);
}
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate,
+ lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (&p->pstate, UNOP_IND);
p->arg = s;
#include "block.h"
#include "completer.h"
-#define parse_type builtin_type (parse_gdbarch)
-#define parse_java_type builtin_java_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
+#define parse_java_type(ps) builtin_java_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
generators need to be fixed instead of adding those names to this list. */
#define yymaxdepth java_maxdepth
-#define yyparse java_parse
+#define yyparse java_parse_internal
#define yylex java_lex
#define yyerror java_error
#define yylval java_lval
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
void yyerror (char *);
static struct type *java_type_from_name (struct stoken);
-static void push_expression_name (struct stoken);
-static void push_fieldnames (struct stoken);
+static void push_expression_name (struct parser_state *, struct stoken);
+static void push_fieldnames (struct parser_state *, struct stoken);
static struct expression *copy_exp (struct expression *, int);
-static void insert_exp (int, struct expression *);
+static void insert_exp (struct parser_state *, int, struct expression *);
%}
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (const char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *, const char *, int,
+ int, YYSTYPE *);
%}
%type <lval> rcurly Dims Dims_opt
type_exp: PrimitiveOrArrayType
{
- write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);
+ write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE);
}
;
StringLiteral:
STRING_LITERAL
{
- write_exp_elt_opcode (OP_STRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_STRING);
+ write_exp_elt_opcode (pstate, OP_STRING);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_STRING);
}
;
Literal:
INTEGER_LITERAL
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_longcst (pstate, (LONGEST)($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
| NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.ptr, $1.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
+ parse_number (pstate, $1.ptr, $1.length, 0, &val);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val_int.type);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) val.typed_val_int.val);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
| FLOATING_POINT_LITERAL
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
| BOOLEAN_LITERAL
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_java_type->builtin_boolean);
- write_exp_elt_longcst ((LONGEST)$1);
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_java_type (pstate)->builtin_boolean);
+ write_exp_elt_longcst (pstate, (LONGEST)$1);
+ write_exp_elt_opcode (pstate, OP_LONG); }
| StringLiteral
;
PrimitiveType:
NumericType
| BOOLEAN
- { $$ = parse_java_type->builtin_boolean; }
+ { $$ = parse_java_type (pstate)->builtin_boolean; }
;
NumericType:
IntegralType:
BYTE
- { $$ = parse_java_type->builtin_byte; }
+ { $$ = parse_java_type (pstate)->builtin_byte; }
| SHORT
- { $$ = parse_java_type->builtin_short; }
+ { $$ = parse_java_type (pstate)->builtin_short; }
| INT
- { $$ = parse_java_type->builtin_int; }
+ { $$ = parse_java_type (pstate)->builtin_int; }
| LONG
- { $$ = parse_java_type->builtin_long; }
+ { $$ = parse_java_type (pstate)->builtin_long; }
| CHAR
- { $$ = parse_java_type->builtin_char; }
+ { $$ = parse_java_type (pstate)->builtin_char; }
;
FloatingPointType:
FLOAT
- { $$ = parse_java_type->builtin_float; }
+ { $$ = parse_java_type (pstate)->builtin_float; }
| DOUBLE
- { $$ = parse_java_type->builtin_double; }
+ { $$ = parse_java_type (pstate)->builtin_double; }
;
/* UNUSED:
/* Expressions, including the comma operator. */
exp1 : Expression
| exp1 ',' Expression
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
;
Primary:
| MethodInvocation
| ArrayAccess
| lcurly ArgumentList rcurly
- { write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) $3);
- write_exp_elt_opcode (OP_ARRAY); }
+ { write_exp_elt_opcode (pstate, OP_ARRAY);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_longcst (pstate, (LONGEST) $3);
+ write_exp_elt_opcode (pstate, OP_ARRAY); }
;
lcurly:
FieldAccess:
Primary '.' SimpleName
- { push_fieldnames ($3); }
+ { push_fieldnames (pstate, $3); }
| VARIABLE '.' SimpleName
- { push_fieldnames ($3); }
+ { push_fieldnames (pstate, $3); }
/*| SUPER '.' SimpleName { FIXME } */
;
FuncStart:
Name '('
- { push_expression_name ($1); }
+ { push_expression_name (pstate, $1); }
;
MethodInvocation:
FuncStart
{ start_arglist(); }
ArgumentList_opt ')'
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate, (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL); }
| Primary '.' SimpleName '(' ArgumentList_opt ')'
{ error (_("Form of method invocation not implemented")); }
| SUPER '.' SimpleName '(' ArgumentList_opt ')'
for our parsing kludges. */
struct expression *name_expr;
- push_expression_name ($1);
- name_expr = copy_exp (expout, expout_ptr);
- expout_ptr -= name_expr->nelts;
- insert_exp (expout_ptr-length_of_subexp (expout, expout_ptr),
+ push_expression_name (pstate, $1);
+ name_expr = copy_exp (pstate->expout, pstate->expout_ptr);
+ pstate->expout_ptr -= name_expr->nelts;
+ insert_exp (pstate,
+ pstate->expout_ptr
+ - length_of_subexp (pstate->expout,
+ pstate->expout_ptr),
name_expr);
free (name_expr);
- write_exp_elt_opcode (BINOP_SUBSCRIPT);
+ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT);
}
| VARIABLE '[' Expression ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
| PrimaryNoNewArray '[' Expression ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
PostfixExpression:
Primary
| Name
- { push_expression_name ($1); }
+ { push_expression_name (pstate, $1); }
| VARIABLE
/* Already written by write_dollar_variable. */
| PostIncrementExpression
PostIncrementExpression:
PostfixExpression INCREMENT
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
;
PostDecrementExpression:
PostfixExpression DECREMENT
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
;
UnaryExpression:
| PreDecrementExpression
| '+' UnaryExpression
| '-' UnaryExpression
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
| '*' UnaryExpression
- { write_exp_elt_opcode (UNOP_IND); } /*FIXME not in Java */
+ { write_exp_elt_opcode (pstate,
+ UNOP_IND); } /*FIXME not in Java */
| UnaryExpressionNotPlusMinus
;
PreIncrementExpression:
INCREMENT UnaryExpression
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
;
PreDecrementExpression:
DECREMENT UnaryExpression
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
;
UnaryExpressionNotPlusMinus:
PostfixExpression
| '~' UnaryExpression
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
| '!' UnaryExpression
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
| CastExpression
;
CastExpression:
'(' PrimitiveType Dims_opt ')' UnaryExpression
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (java_array_type ($2, $3));
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, java_array_type ($2, $3));
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
| '(' Expression ')' UnaryExpressionNotPlusMinus
{
- int last_exp_size = length_of_subexp(expout, expout_ptr);
+ int last_exp_size = length_of_subexp (pstate->expout,
+ pstate->expout_ptr);
struct type *type;
int i;
- int base = expout_ptr - last_exp_size - 3;
- if (base < 0 || expout->elts[base+2].opcode != OP_TYPE)
+ int base = pstate->expout_ptr - last_exp_size - 3;
+
+ if (base < 0
+ || pstate->expout->elts[base+2].opcode != OP_TYPE)
error (_("Invalid cast expression"));
- type = expout->elts[base+1].type;
+ type = pstate->expout->elts[base+1].type;
/* Remove the 'Expression' and slide the
UnaryExpressionNotPlusMinus down to replace it. */
for (i = 0; i < last_exp_size; i++)
- expout->elts[base + i] = expout->elts[base + i + 3];
- expout_ptr -= 3;
+ pstate->expout->elts[base + i]
+ = pstate->expout->elts[base + i + 3];
+ pstate->expout_ptr -= 3;
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
type = lookup_pointer_type (type);
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (type);
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, type);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
}
| '(' Name Dims ')' UnaryExpressionNotPlusMinus
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (java_array_type (java_type_from_name ($2), $3));
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate,
+ java_array_type (java_type_from_name
+ ($2), $3));
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
;
MultiplicativeExpression:
UnaryExpression
| MultiplicativeExpression '*' UnaryExpression
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
| MultiplicativeExpression '/' UnaryExpression
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
| MultiplicativeExpression '%' UnaryExpression
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
AdditiveExpression:
MultiplicativeExpression
| AdditiveExpression '+' MultiplicativeExpression
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
| AdditiveExpression '-' MultiplicativeExpression
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
ShiftExpression:
AdditiveExpression
| ShiftExpression LSH AdditiveExpression
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
| ShiftExpression RSH AdditiveExpression
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
/* | ShiftExpression >>> AdditiveExpression { FIXME } */
;
RelationalExpression:
ShiftExpression
| RelationalExpression '<' ShiftExpression
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
| RelationalExpression '>' ShiftExpression
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
| RelationalExpression LEQ ShiftExpression
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
| RelationalExpression GEQ ShiftExpression
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
/* | RelationalExpresion INSTANCEOF ReferenceType { FIXME } */
;
EqualityExpression:
RelationalExpression
| EqualityExpression EQUAL RelationalExpression
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
| EqualityExpression NOTEQUAL RelationalExpression
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
AndExpression:
EqualityExpression
| AndExpression '&' EqualityExpression
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
ExclusiveOrExpression:
AndExpression
| ExclusiveOrExpression '^' AndExpression
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
InclusiveOrExpression:
ExclusiveOrExpression
| InclusiveOrExpression '|' ExclusiveOrExpression
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
ConditionalAndExpression:
InclusiveOrExpression
| ConditionalAndExpression ANDAND InclusiveOrExpression
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
ConditionalOrExpression:
ConditionalAndExpression
| ConditionalOrExpression OROR ConditionalAndExpression
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
ConditionalExpression:
ConditionalOrExpression
| ConditionalOrExpression '?' Expression ':' ConditionalExpression
- { write_exp_elt_opcode (TERNOP_COND); }
+ { write_exp_elt_opcode (pstate, TERNOP_COND); }
;
AssignmentExpression:
Assignment:
LeftHandSide '=' ConditionalExpression
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
| LeftHandSide ASSIGN_MODIFY ConditionalExpression
- { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode ($2);
- write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, $2);
+ write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
;
LeftHandSide:
ForcedName
- { push_expression_name ($1); }
+ { push_expression_name (pstate, $1); }
| VARIABLE
/* Already written by write_dollar_variable. */
| FieldAccess
/*** Needs some error checking for the float case ***/
static int
-parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state,
+ const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
ULONGEST n = 0;
ULONGEST limit, limit_div_base;
suffix_len = p + len - suffix;
if (suffix_len == 0)
- putithere->typed_val_float.type = parse_type->builtin_double;
+ putithere->typed_val_float.type
+ = parse_type (par_state)->builtin_double;
else if (suffix_len == 1)
{
/* See if it has `f' or `d' suffix (float or double). */
if (tolower (*suffix) == 'f')
putithere->typed_val_float.type =
- parse_type->builtin_float;
+ parse_type (par_state)->builtin_float;
else if (tolower (*suffix) == 'd')
putithere->typed_val_float.type =
- parse_type->builtin_double;
+ parse_type (par_state)->builtin_double;
else
return ERROR;
}
limit = ((limit << 16) << 16) | limit;
if (c == 'l' || c == 'L')
{
- type = parse_java_type->builtin_long;
+ type = parse_java_type (par_state)->builtin_long;
len--;
}
else
{
- type = parse_java_type->builtin_int;
+ type = parse_java_type (par_state)->builtin_int;
}
limit_div_base = limit / (ULONGEST) base;
/* If the type is bigger than a 32-bit signed integer can be, implicitly
promote to long. Java does not do this, so mark it as
- parse_type->builtin_uint64 rather than parse_java_type->builtin_long.
+ parse_type (par_state)->builtin_uint64 rather than
+ parse_java_type (par_state)->builtin_long.
0x80000000 will become -0x80000000 instead of 0x80000000L, because we
don't know the sign at this point. */
- if (type == parse_java_type->builtin_int && n > (ULONGEST)0x80000000)
- type = parse_type->builtin_uint64;
+ if (type == parse_java_type (par_state)->builtin_int
+ && n > (ULONGEST)0x80000000)
+ type = parse_type (par_state)->builtin_uint64;
putithere->typed_val_int.val = n;
putithere->typed_val_int.type = type;
lexptr++;
c = *lexptr++;
if (c == '\\')
- c = parse_escape (parse_gdbarch, &lexptr);
+ c = parse_escape (parse_gdbarch (pstate), &lexptr);
else if (c == '\'')
error (_("Empty character constant"));
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = parse_java_type->builtin_char;
+ yylval.typed_val_int.type = parse_java_type (pstate)->builtin_char;
c = *lexptr++;
if (c != '\'')
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
+ toktype = parse_number (pstate, tokstart, p - tokstart,
+ got_dot|got_e, &yylval);
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
break;
case '\\':
tokptr++;
- c = parse_escape (parse_gdbarch, &tokptr);
+ c = parse_escape (parse_gdbarch (pstate), &tokptr);
if (c == -1)
{
continue;
if (*tokstart == '$')
{
- write_dollar_variable (yylval.sval);
+ write_dollar_variable (pstate, yylval.sval);
return VARIABLE;
}
(tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
{
YYSTYPE newlval; /* Its value is ignored. */
- int hextype = parse_number (tokstart, namelen, 0, &newlval);
+ int hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
if (hextype == INTEGER_LITERAL)
return NAME_OR_INT;
}
return IDENTIFIER;
}
+int
+java_parse (struct parser_state *par_state)
+{
+ int result;
+ struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ result = yyparse ();
+ do_cleanups (c);
+
+ return result;
+}
+
void
yyerror (char *msg)
{
Otherwise, return 0. */
static int
-push_variable (struct stoken name)
+push_variable (struct parser_state *par_state, struct stoken name)
{
char *tmp = copy_name (name);
struct field_of_this_result is_a_field_of_this;
struct symbol *sym;
+
sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN,
&is_a_field_of_this);
if (sym && SYMBOL_CLASS (sym) != LOC_TYPEDEF)
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
/* We want to use the selected frame, not another more inner frame
which happens to be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (par_state, NULL);
+ write_exp_elt_sym (par_state, sym);
+ write_exp_elt_opcode (par_state, OP_VAR_VALUE);
return 1;
}
if (is_a_field_of_this.type != NULL)
if (innermost_block == 0 ||
contained_in (block_found, innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string (name);
- write_exp_elt_opcode (STRUCTOP_PTR);
+ write_exp_elt_opcode (par_state, OP_THIS);
+ write_exp_elt_opcode (par_state, OP_THIS);
+ write_exp_elt_opcode (par_state, STRUCTOP_PTR);
+ write_exp_string (par_state, name);
+ write_exp_elt_opcode (par_state, STRUCTOP_PTR);
return 1;
}
return 0;
qualified name (has '.'), generate a field access for each part. */
static void
-push_fieldnames (struct stoken name)
+push_fieldnames (struct parser_state *par_state, struct stoken name)
{
int i;
struct stoken token;
{
/* token.ptr is start of current field name. */
token.length = &name.ptr[i] - token.ptr;
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string (token);
- write_exp_elt_opcode (STRUCTOP_PTR);
+ write_exp_elt_opcode (par_state, STRUCTOP_PTR);
+ write_exp_string (par_state, token);
+ write_exp_elt_opcode (par_state, STRUCTOP_PTR);
token.ptr += token.length + 1;
}
if (i >= name.length)
Handle a qualified name, where DOT_INDEX is the index of the first '.' */
static void
-push_qualified_expression_name (struct stoken name, int dot_index)
+push_qualified_expression_name (struct parser_state *par_state,
+ struct stoken name, int dot_index)
{
struct stoken token;
char *tmp;
token.ptr = name.ptr;
token.length = dot_index;
- if (push_variable (token))
+ if (push_variable (par_state, token))
{
token.ptr = name.ptr + dot_index + 1;
token.length = name.length - dot_index - 1;
- push_fieldnames (token);
+ push_fieldnames (par_state, token);
return;
}
{
if (dot_index == name.length)
{
- write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type(typ);
- write_exp_elt_opcode(OP_TYPE);
+ write_exp_elt_opcode (par_state, OP_TYPE);
+ write_exp_elt_type (par_state, typ);
+ write_exp_elt_opcode (par_state, OP_TYPE);
return;
}
dot_index++; /* Skip '.' */
dot_index++;
token.ptr = name.ptr;
token.length = dot_index;
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (typ);
- write_exp_string (token);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (par_state, OP_SCOPE);
+ write_exp_elt_type (par_state, typ);
+ write_exp_string (par_state, token);
+ write_exp_elt_opcode (par_state, OP_SCOPE);
if (dot_index < name.length)
{
dot_index++;
name.ptr += dot_index;
name.length -= dot_index;
- push_fieldnames (name);
+ push_fieldnames (par_state, name);
}
return;
}
Handle VAR, TYPE, TYPE.FIELD1....FIELDN and VAR.FIELD1....FIELDN. */
static void
-push_expression_name (struct stoken name)
+push_expression_name (struct parser_state *par_state, struct stoken name)
{
char *tmp;
struct type *typ;
if (name.ptr[i] == '.')
{
/* It's a Qualified Expression Name. */
- push_qualified_expression_name (name, i);
+ push_qualified_expression_name (par_state, name, i);
return;
}
}
/* It's a Simple Expression Name. */
- if (push_variable (name))
+ if (push_variable (par_state, name))
return;
tmp = copy_name (name);
typ = java_lookup_class (tmp);
if (typ != NULL)
{
- write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type(typ);
- write_exp_elt_opcode(OP_TYPE);
+ write_exp_elt_opcode (par_state, OP_TYPE);
+ write_exp_elt_type (par_state, typ);
+ write_exp_elt_opcode (par_state, OP_TYPE);
}
else
{
msymbol = lookup_bound_minimal_symbol (tmp);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (par_state, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command"));
else
int len = length_of_subexp (expr, endpos);
struct expression *new
= (struct expression *) malloc (sizeof (*new) + EXP_ELEM_TO_BYTES (len));
+
new->nelts = len;
memcpy (new->elts, expr->elts + endpos - len, EXP_ELEM_TO_BYTES (len));
new->language_defn = 0;
/* Insert the expression NEW into the current expression (expout) at POS. */
static void
-insert_exp (int pos, struct expression *new)
+insert_exp (struct parser_state *par_state, int pos, struct expression *new)
{
int newlen = new->nelts;
+ int i;
/* Grow expout if necessary. In this function's only use at present,
this should never be necessary. */
- if (expout_ptr + newlen > expout_size)
- {
- expout_size = max (expout_size * 2, expout_ptr + newlen + 10);
- expout = (struct expression *)
- realloc ((char *) expout, (sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size)));
- }
-
- {
- int i;
+ increase_expout_size (par_state, newlen);
- for (i = expout_ptr - 1; i >= pos; i--)
- expout->elts[i + newlen] = expout->elts[i];
- }
+ for (i = par_state->expout_ptr - 1; i >= pos; i--)
+ par_state->expout->elts[i + newlen] = par_state->expout->elts[i];
- memcpy (expout->elts + pos, new->elts, EXP_ELEM_TO_BYTES (newlen));
- expout_ptr += newlen;
+ memcpy (par_state->expout->elts + pos, new->elts,
+ EXP_ELEM_TO_BYTES (newlen));
+ par_state->expout_ptr += newlen;
}
struct value;
struct type_print_options;
+struct parser_state;
-extern int java_parse (void); /* Defined in jv-exp.y */
+extern int java_parse (struct parser_state *); /* Defined in jv-exp.y */
extern void java_error (char *); /* Defined in jv-exp.y */
static void unk_lang_error (char *);
-static int unk_lang_parser (void);
+static int unk_lang_parser (struct parser_state *);
static void show_check (char *, int);
/* Define the language that is no language. */
static int
-unk_lang_parser (void)
+unk_lang_parser (struct parser_state *ps)
{
return 1;
}
struct value_print_options;
struct type_print_options;
struct lang_varobj_ops;
+struct parser_state;
#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims. */
/* Parser function. */
- int (*la_parser) (void);
+ int (*la_parser) (struct parser_state *);
/* Parser error function. */
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
#include "block.h"
-#define parse_type builtin_type (parse_gdbarch)
-#define parse_m2_type builtin_m2_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
+#define parse_m2_type(ps) builtin_m2_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
generators need to be fixed instead of adding those names to this list. */
#define yymaxdepth m2_maxdepth
-#define yyparse m2_parse
+#define yyparse m2_parse_internal
#define yylex m2_lex
#define yyerror m2_error
#define yylval m2_lval
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE);
}
;
/* Expressions */
exp : exp '^' %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (pstate, UNOP_IND); }
;
exp : '-'
{ number_sign = -1; }
exp %prec UNARY
{ number_sign = 1;
- write_exp_elt_opcode (UNOP_NEG); }
+ write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : '+' exp %prec UNARY
- { write_exp_elt_opcode(UNOP_PLUS); }
+ { write_exp_elt_opcode (pstate, UNOP_PLUS); }
;
exp : not_exp exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
not_exp : NOT
;
exp : CAP '(' exp ')'
- { write_exp_elt_opcode (UNOP_CAP); }
+ { write_exp_elt_opcode (pstate, UNOP_CAP); }
;
exp : ORD '(' exp ')'
- { write_exp_elt_opcode (UNOP_ORD); }
+ { write_exp_elt_opcode (pstate, UNOP_ORD); }
;
exp : ABS '(' exp ')'
- { write_exp_elt_opcode (UNOP_ABS); }
+ { write_exp_elt_opcode (pstate, UNOP_ABS); }
;
exp : HIGH '(' exp ')'
- { write_exp_elt_opcode (UNOP_HIGH); }
+ { write_exp_elt_opcode (pstate, UNOP_HIGH); }
;
exp : MIN_FUNC '(' type ')'
- { write_exp_elt_opcode (UNOP_MIN);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_MIN); }
+ { write_exp_elt_opcode (pstate, UNOP_MIN);
+ write_exp_elt_type (pstate, $3);
+ write_exp_elt_opcode (pstate, UNOP_MIN); }
;
exp : MAX_FUNC '(' type ')'
- { write_exp_elt_opcode (UNOP_MAX);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_MAX); }
+ { write_exp_elt_opcode (pstate, UNOP_MAX);
+ write_exp_elt_type (pstate, $3);
+ write_exp_elt_opcode (pstate, UNOP_MAX); }
;
exp : FLOAT_FUNC '(' exp ')'
- { write_exp_elt_opcode (UNOP_FLOAT); }
+ { write_exp_elt_opcode (pstate, UNOP_FLOAT); }
;
exp : VAL '(' type ',' exp ')'
- { write_exp_elt_opcode (BINOP_VAL);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (BINOP_VAL); }
+ { write_exp_elt_opcode (pstate, BINOP_VAL);
+ write_exp_elt_type (pstate, $3);
+ write_exp_elt_opcode (pstate, BINOP_VAL); }
;
exp : CHR '(' exp ')'
- { write_exp_elt_opcode (UNOP_CHR); }
+ { write_exp_elt_opcode (pstate, UNOP_CHR); }
;
exp : ODD '(' exp ')'
- { write_exp_elt_opcode (UNOP_ODD); }
+ { write_exp_elt_opcode (pstate, UNOP_ODD); }
;
exp : TRUNC '(' exp ')'
- { write_exp_elt_opcode (UNOP_TRUNC); }
+ { write_exp_elt_opcode (pstate, UNOP_TRUNC); }
;
exp : TSIZE '(' exp ')'
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
exp : SIZE exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
;
exp : INC '(' exp ')'
- { write_exp_elt_opcode(UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
;
exp : INC '(' exp ',' exp ')'
- { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode(BINOP_ADD);
- write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, BINOP_ADD);
+ write_exp_elt_opcode (pstate,
+ BINOP_ASSIGN_MODIFY); }
;
exp : DEC '(' exp ')'
- { write_exp_elt_opcode(UNOP_PREDECREMENT);}
+ { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT);}
;
exp : DEC '(' exp ',' exp ')'
- { write_exp_elt_opcode(BINOP_ASSIGN_MODIFY);
- write_exp_elt_opcode(BINOP_SUB);
- write_exp_elt_opcode(BINOP_ASSIGN_MODIFY); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (pstate, BINOP_SUB);
+ write_exp_elt_opcode (pstate,
+ BINOP_ASSIGN_MODIFY); }
;
exp : exp DOT NAME
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($3);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : set
function types */
{ start_arglist(); }
non_empty_arglist ']' %prec DOT
- { write_exp_elt_opcode (MULTI_SUBSCRIPT);
- write_exp_elt_longcst ((LONGEST) end_arglist());
- write_exp_elt_opcode (MULTI_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist());
+ write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT); }
;
exp : exp '[' exp ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT); }
;
exp : exp '('
being accumulated by an outer function call. */
{ start_arglist (); }
arglist ')' %prec DOT
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL); }
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL); }
;
arglist :
/* GDB construct */
exp : '{' type '}' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_MEMVAL);
- write_exp_elt_type ($2);
- write_exp_elt_opcode (UNOP_MEMVAL); }
+ { write_exp_elt_opcode (pstate, UNOP_MEMVAL);
+ write_exp_elt_type (pstate, $2);
+ write_exp_elt_opcode (pstate, UNOP_MEMVAL); }
;
exp : type '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, UNOP_CAST); }
;
exp : '(' exp ')'
/* GDB construct */
exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (pstate, BINOP_REPEAT); }
;
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (pstate, BINOP_DIV); }
;
exp : exp DIV exp
- { write_exp_elt_opcode (BINOP_INTDIV); }
+ { write_exp_elt_opcode (pstate, BINOP_INTDIV); }
;
exp : exp MOD exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
| exp '#' exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_LEQ); }
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (pstate, BINOP_GEQ); }
;
exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (pstate, BINOP_LESS); }
;
exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (pstate, BINOP_GTR); }
;
exp : exp LOGICAL_AND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
;
exp : exp OROR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
;
exp : exp ASSIGN exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
/* Constants */
exp : M2_TRUE
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
exp : M2_FALSE
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_m2_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_m2_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : UINT
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_m2_type->builtin_card);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_m2_type (pstate)
+ ->builtin_card);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : CHAR
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_m2_type->builtin_char);
- write_exp_elt_longcst ((LONGEST) $1);
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_m2_type (pstate)
+ ->builtin_char);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type (parse_m2_type->builtin_real);
- write_exp_elt_dblcst ($1);
- write_exp_elt_opcode (OP_DOUBLE); }
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate,
+ parse_m2_type (pstate)
+ ->builtin_real);
+ write_exp_elt_dblcst (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : variable
;
exp : SIZE '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : STRING
- { write_exp_elt_opcode (OP_M2_STRING);
- write_exp_string ($1);
- write_exp_elt_opcode (OP_M2_STRING); }
+ { write_exp_elt_opcode (pstate, OP_M2_STRING);
+ write_exp_string (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_M2_STRING); }
;
/* This will be used for extensions later. Like adding modules. */
fblock : BLOCKNAME
{ struct symbol *sym
- = lookup_symbol (copy_name ($1), expression_context_block,
+ = lookup_symbol (copy_name ($1),
+ expression_context_block,
VAR_DOMAIN, 0);
$$ = sym;}
;
/* Useful for assigning to PROCEDURE variables */
variable: fblock
- { write_exp_elt_opcode(OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym ($1);
- write_exp_elt_opcode (OP_VAR_VALUE); }
+ { write_exp_elt_opcode (pstate, OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
/* GDB internal ($foo) variable */
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* block_found is set by lookup_symbol. */
- write_exp_elt_block (block_found);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); }
+ write_exp_elt_block (pstate, block_found);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
/* Base case for variables. */
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* We want to use the selected frame, not
another more inner frame which happens to
be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
}
else
{
msymbol =
lookup_bound_minimal_symbol (arg);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"symbol-file\" command."));
else
type
: TYPENAME
- { $$ = lookup_typename (parse_language, parse_gdbarch,
+ { $$ = lookup_typename (parse_language (pstate),
+ parse_gdbarch (pstate),
copy_name ($1),
expression_context_block, 0); }
/* Read one token, getting characters through lexptr. */
-/* This is where we will check to make sure that the language and the operators used are
- compatible */
+/* This is where we will check to make sure that the language and the
+ operators used are compatible */
static int
yylex (void)
if (*tokstart == '$')
{
- write_dollar_variable (yylval.sval);
+ write_dollar_variable (pstate, yylval.sval);
return INTERNAL_VAR;
}
sym = lookup_symbol (tmp, expression_context_block, VAR_DOMAIN, 0);
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
return BLOCKNAME;
- if (lookup_typename (parse_language, parse_gdbarch,
- copy_name (yylval.sval), expression_context_block, 1))
+ if (lookup_typename (parse_language (pstate), parse_gdbarch (pstate),
+ copy_name (yylval.sval),
+ expression_context_block, 1))
return TYPENAME;
if(sym)
}
}
+int
+m2_parse (struct parser_state *par_state)
+{
+ int result;
+ struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ result = yyparse ();
+ do_cleanups (c);
+
+ return result;
+}
+
void
yyerror (char *msg)
{
along with this program. If not, see <http://www.gnu.org/licenses/>. */
struct type_print_options;
+struct parser_state;
-extern int m2_parse (void); /* Defined in m2-exp.y */
+extern int m2_parse (struct parser_state *); /* Defined in m2-exp.y */
extern void m2_error (char *); /* Defined in m2-exp.y */
}
int
-end_msglist(void)
+end_msglist (struct parser_state *ps)
{
int val = msglist_len;
struct selname *sel = selname_chain;
selname_chain = sel->next;
msglist_len = sel->msglist_len;
msglist_sel = sel->msglist_sel;
- selid = lookup_child_selector (parse_gdbarch, p);
+ selid = lookup_child_selector (parse_gdbarch (ps), p);
if (!selid)
error (_("Can't find selector \"%s\""), p);
- write_exp_elt_longcst (selid);
+ write_exp_elt_longcst (ps, selid);
xfree(p);
- write_exp_elt_longcst (val); /* Number of args */
+ write_exp_elt_longcst (ps, val); /* Number of args */
xfree(sel);
return val;
struct value;
struct block;
+struct parser_state;
extern CORE_ADDR lookup_objc_class (struct gdbarch *gdbarch,
char *classname);
/* for parsing Objective C */
extern void start_msglist (void);
extern void add_msglist (struct stoken *str, int addcolon);
-extern int end_msglist (void);
+extern int end_msglist (struct parser_state *);
struct symbol *lookup_struct_typedef (char *name, const struct block *block,
int noerr);
#include "block.h"
#include "completer.h"
-#define parse_type builtin_type (parse_gdbarch)
+#define parse_type(ps) builtin_type (parse_gdbarch (ps))
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
generators need to be fixed instead of adding those names to this list. */
#define yymaxdepth pascal_maxdepth
-#define yyparse pascal_parse
+#define yyparse pascal_parse_internal
#define yylex pascal_lex
#define yyerror pascal_error
#define yylval pascal_lval
#define YYFPRINTF parser_fprintf
+/* The state of the parser, used internally when we are parsing the
+ expression. */
+
+static struct parser_state *pstate = NULL;
+
int yyparse (void);
static int yylex (void);
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (const char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *,
+ const char *, int, int, YYSTYPE *);
static struct type *current_type;
static struct internalvar *intvar;
;
type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);
+ { write_exp_elt_opcode (pstate, OP_TYPE);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, OP_TYPE);
current_type = $1; } ;
/* Expressions, including the comma operator. */
exp1 : exp
| exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (pstate, BINOP_COMMA); }
;
/* Expressions, not including the comma operator. */
exp : exp '^' %prec UNARY
- { write_exp_elt_opcode (UNOP_IND);
+ { write_exp_elt_opcode (pstate, UNOP_IND);
if (current_type)
current_type = TYPE_TARGET_TYPE (current_type); }
;
exp : '@' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR);
+ { write_exp_elt_opcode (pstate, UNOP_ADDR);
if (current_type)
current_type = TYPE_POINTER_TYPE (current_type); }
;
exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (pstate, UNOP_NEG); }
;
exp : NOT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
;
exp : INCREMENT '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
;
exp : DECREMENT '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
+ { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
;
;
exp : field_exp FIELDNAME
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($2);
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $2);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
search_field = 0;
if (current_type)
{
exp : field_exp name
- { write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($2);
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, $2);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
search_field = 0;
if (current_type)
{
}
;
exp : field_exp name COMPLETE
- { mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string ($2);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ { mark_struct_expression (pstate);
+ 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 ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ mark_struct_expression (pstate);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ write_exp_string (pstate, s);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
;
exp : exp '['
strcpy (buf, arrayname);
current_type = TYPE_FIELD_TYPE (current_type,
arrayfieldindex - 1);
- write_exp_elt_opcode (STRUCTOP_STRUCT);
- write_exp_string (stringsval);
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
+ write_exp_string (pstate, stringsval);
+ write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
}
push_current_type (); }
exp1 ']'
{ pop_current_type ();
- write_exp_elt_opcode (BINOP_SUBSCRIPT);
+ write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT);
if (current_type)
current_type = TYPE_TARGET_TYPE (current_type); }
;
{ push_current_type ();
start_arglist (); }
arglist ')' %prec ARROW
- { write_exp_elt_opcode (OP_FUNCALL);
- write_exp_elt_longcst ((LONGEST) end_arglist ());
- write_exp_elt_opcode (OP_FUNCALL);
+ { write_exp_elt_opcode (pstate, OP_FUNCALL);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) end_arglist ());
+ write_exp_elt_opcode (pstate, OP_FUNCALL);
pop_current_type ();
if (current_type)
current_type = TYPE_TARGET_TYPE (current_type);
if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
&& (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
&& (TYPE_CODE ($1) == TYPE_CODE_CLASS))
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (pstate, UNOP_IND);
}
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($1);
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate, $1);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
current_type = $1; }
;
/* Binary operators in order of decreasing precedence. */
exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (pstate, BINOP_MUL); }
;
exp : exp '/' {
if (leftdiv_is_integer && current_type
&& is_integral_type (current_type))
{
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (parse_type->builtin_long_double);
- current_type = parse_type->builtin_long_double;
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (pstate, UNOP_CAST);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)
+ ->builtin_long_double);
+ current_type
+ = parse_type (pstate)->builtin_long_double;
+ write_exp_elt_opcode (pstate, UNOP_CAST);
leftdiv_is_integer = 0;
}
- write_exp_elt_opcode (BINOP_DIV);
+ write_exp_elt_opcode (pstate, BINOP_DIV);
}
;
exp : exp DIV exp
- { write_exp_elt_opcode (BINOP_INTDIV); }
+ { write_exp_elt_opcode (pstate, BINOP_INTDIV); }
;
exp : exp MOD exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (pstate, BINOP_REM); }
;
exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (pstate, BINOP_ADD); }
;
exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (pstate, BINOP_SUB); }
;
exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (pstate, BINOP_LSH); }
;
exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (pstate, BINOP_RSH); }
;
exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_EQUAL);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_EQUAL);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_LEQ);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_GEQ);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_LESS);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR);
- current_type = parse_type->builtin_bool;
+ { write_exp_elt_opcode (pstate, BINOP_GTR);
+ current_type = parse_type (pstate)->builtin_bool;
}
;
exp : exp ANDAND exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
;
exp : exp XOR exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
;
exp : exp OR exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
;
exp : exp ASSIGN exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
;
exp : TRUEKEYWORD
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- current_type = parse_type->builtin_bool;
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ current_type = parse_type (pstate)->builtin_bool;
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
exp : FALSEKEYWORD
- { write_exp_elt_opcode (OP_BOOL);
- write_exp_elt_longcst ((LONGEST) $1);
- current_type = parse_type->builtin_bool;
- write_exp_elt_opcode (OP_BOOL); }
+ { write_exp_elt_opcode (pstate, OP_BOOL);
+ write_exp_elt_longcst (pstate, (LONGEST) $1);
+ current_type = parse_type (pstate)->builtin_bool;
+ write_exp_elt_opcode (pstate, OP_BOOL); }
;
exp : INT
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type ($1.type);
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, $1.type);
current_type = $1.type;
- write_exp_elt_longcst ((LONGEST)($1.val));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (pstate, (LONGEST)($1.val));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr,
+ parse_number (pstate, $1.stoken.ptr,
$1.stoken.length, 0, &val);
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (val.typed_val_int.type);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate, val.typed_val_int.type);
current_type = val.typed_val_int.type;
- write_exp_elt_longcst ((LONGEST)
+ write_exp_elt_longcst (pstate, (LONGEST)
val.typed_val_int.val);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
}
;
exp : FLOAT
- { write_exp_elt_opcode (OP_DOUBLE);
- write_exp_elt_type ($1.type);
+ { write_exp_elt_opcode (pstate, OP_DOUBLE);
+ write_exp_elt_type (pstate, $1.type);
current_type = $1.type;
- write_exp_elt_dblcst ($1.dval);
- write_exp_elt_opcode (OP_DOUBLE); }
+ write_exp_elt_dblcst (pstate, $1.dval);
+ write_exp_elt_opcode (pstate, OP_DOUBLE); }
;
exp : variable
struct value * val, * mark;
mark = value_mark ();
- val = value_of_internalvar (parse_gdbarch,
+ val = value_of_internalvar (parse_gdbarch (pstate),
intvar);
current_type = value_type (val);
value_release_to_mark (mark);
;
exp : SIZEOF '(' type ')' %prec UNARY
- { write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_int);
- current_type = parse_type->builtin_int;
+ { write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)->builtin_int);
+ current_type = parse_type (pstate)->builtin_int;
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (pstate,
+ (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (pstate, OP_LONG); }
;
exp : SIZEOF '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF);
- current_type = parse_type->builtin_int; }
+ { write_exp_elt_opcode (pstate, UNOP_SIZEOF);
+ current_type = parse_type (pstate)->builtin_int; }
exp : STRING
{ /* C strings are converted into array constants with
while (count-- > 0)
{
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_char);
- write_exp_elt_longcst ((LONGEST)(*sp++));
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)
+ ->builtin_char);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) (*sp++));
+ write_exp_elt_opcode (pstate, OP_LONG);
}
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (parse_type->builtin_char);
- write_exp_elt_longcst ((LONGEST)'\0');
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_opcode (OP_ARRAY);
- write_exp_elt_longcst ((LONGEST) 0);
- write_exp_elt_longcst ((LONGEST) ($1.length));
- write_exp_elt_opcode (OP_ARRAY); }
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_type (pstate,
+ parse_type (pstate)
+ ->builtin_char);
+ write_exp_elt_longcst (pstate, (LONGEST)'\0');
+ write_exp_elt_opcode (pstate, OP_LONG);
+ write_exp_elt_opcode (pstate, OP_ARRAY);
+ write_exp_elt_longcst (pstate, (LONGEST) 0);
+ write_exp_elt_longcst (pstate,
+ (LONGEST) ($1.length));
+ write_exp_elt_opcode (pstate, OP_ARRAY); }
;
/* Object pascal */
{
struct value * this_val;
struct type * this_type;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, OP_THIS);
/* We need type of this. */
- this_val = value_of_this_silent (parse_language);
+ this_val
+ = value_of_this_silent (parse_language (pstate));
if (this_val)
this_type = value_type (this_val);
else
if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
{
this_type = TYPE_TARGET_TYPE (this_type);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (pstate, UNOP_IND);
}
}
error (_("No symbol \"%s\" in specified context."),
copy_name ($3));
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* block_found is set by lookup_symbol. */
- write_exp_elt_block (block_found);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE); }
+ write_exp_elt_block (pstate, block_found);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE); }
;
qualified_name: typebase COLONCOLON name
error (_("`%s' is not defined as an aggregate type."),
TYPE_NAME (type));
- write_exp_elt_opcode (OP_SCOPE);
- write_exp_elt_type (type);
- write_exp_string ($3);
- write_exp_elt_opcode (OP_SCOPE);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
+ write_exp_elt_type (pstate, type);
+ write_exp_string (pstate, $3);
+ write_exp_elt_opcode (pstate, OP_SCOPE);
}
;
VAR_DOMAIN, NULL);
if (sym)
{
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
break;
}
msymbol = lookup_bound_minimal_symbol (name);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
innermost_block = block_found;
}
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
/* We want to use the selected frame, not
another more inner frame which happens to
be in the same block. */
- write_exp_elt_block (NULL);
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_block (pstate, NULL);
+ write_exp_elt_sym (pstate, sym);
+ write_exp_elt_opcode (pstate, OP_VAR_VALUE);
current_type = sym->type; }
else if ($1.is_a_field_of_this)
{
|| contained_in (block_found,
innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (STRUCTOP_PTR);
- write_exp_string ($1.stoken);
- write_exp_elt_opcode (STRUCTOP_PTR);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, OP_THIS);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
+ write_exp_string (pstate, $1.stoken);
+ write_exp_elt_opcode (pstate, STRUCTOP_PTR);
/* We need type of this. */
- this_val = value_of_this_silent (parse_language);
+ this_val
+ = value_of_this_silent (parse_language (pstate));
if (this_val)
this_type = value_type (this_val);
else
msymbol =
lookup_bound_minimal_symbol (arg);
if (msymbol.minsym != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols ()
&& !have_partial_symbols ())
error (_("No symbol table is loaded. "
/*** Needs some error checking for the float case ***/
static int
-parse_number (const char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *par_state,
+ const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative values
here, and we do kind of silly things like cast to unsigned. */
if (parsed_float)
{
- if (! parse_c_float (parse_gdbarch, p, len,
+ if (! parse_c_float (parse_gdbarch (par_state), p, len,
&putithere->typed_val_float.dval,
&putithere->typed_val_float.type))
return ERROR;
un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
int. This probably should be fixed. GCC gives a warning on
such constants. */
- unsigned_type = parse_type->builtin_unsigned_int;
- signed_type = parse_type->builtin_int;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_int;
+ signed_type = parse_type (par_state)->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
- unsigned_type = parse_type->builtin_unsigned_long;
- signed_type = parse_type->builtin_long;
+ high_bit
+ = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long;
+ signed_type = parse_type (par_state)->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (parse_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch (par_state)))
/* A long long does not fit in a LONGEST. */
shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
else
- shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
+ shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
high_bit = (ULONGEST) 1 << shift;
- unsigned_type = parse_type->builtin_unsigned_long_long;
- signed_type = parse_type->builtin_long_long;
+ unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
+ signed_type = parse_type (par_state)->builtin_long_long;
}
putithere->typed_val_int.val = n;
lexptr++;
c = *lexptr++;
if (c == '\\')
- c = parse_escape (parse_gdbarch, &lexptr);
+ c = parse_escape (parse_gdbarch (pstate), &lexptr);
else if (c == '\'')
error (_("Empty character constant."));
yylval.typed_val_int.val = c;
- yylval.typed_val_int.type = parse_type->builtin_char;
+ yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
c = *lexptr++;
if (c != '\'')
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart,
+ toktype = parse_number (pstate, tokstart,
p - tokstart, got_dot | got_e, &yylval);
if (toktype == ERROR)
{
break;
case '\\':
++tokptr;
- c = parse_escape (parse_gdbarch, &tokptr);
+ c = parse_escape (parse_gdbarch (pstate), &tokptr);
if (c == -1)
{
continue;
but this conflicts with the GDB use for debugger variables
so in expression to enter hexadecimal values
we still need to use C syntax with 0xff */
- write_dollar_variable (yylval.sval);
+ write_dollar_variable (pstate, yylval.sval);
tmp = alloca (namelen + 1);
memcpy (tmp, tokstart, namelen);
tmp[namelen] = '\0';
return TYPENAME;
}
yylval.tsym.type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, tmp);
+ = language_lookup_primitive_type_by_name (parse_language (pstate),
+ parse_gdbarch (pstate), tmp);
if (yylval.tsym.type != NULL)
{
free (uptokstart);
|| (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
{
YYSTYPE newlval; /* Its value is ignored. */
- hextype = parse_number (tokstart, namelen, 0, &newlval);
+ hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = sym;
}
}
+int
+pascal_parse (struct parser_state *par_state)
+{
+ int result;
+ struct cleanup *c = make_cleanup_clear_parser_state (&pstate);
+
+ /* Setting up the parser state. */
+ gdb_assert (par_state != NULL);
+ pstate = par_state;
+
+ result = yyparse ();
+ do_cleanups (c);
+ return result;
+}
+
void
yyerror (char *msg)
{
/* This file is derived from c-lang.h */
struct value;
+struct parser_state;
/* Defined in p-lang.c */
extern const char *pascal_main_name (void);
-extern int pascal_parse (void); /* Defined in p-exp.y */
+extern int pascal_parse (struct parser_state *); /* Defined in p-exp.y */
extern void pascal_error (char *); /* Defined in p-exp.y */
};
\f
/* Global variables declared in parser-defs.h (and commented there). */
-struct expression *expout;
-int expout_size;
-int expout_ptr;
const struct block *expression_context_block;
CORE_ADDR expression_context_pc;
const struct block *innermost_block;
}
}
\f
-/* This page contains the functions for adding data to the struct expression
- being constructed. */
/* See definition in parser-defs.h. */
void
-initialize_expout (int initial_size, const struct language_defn *lang,
+initialize_expout (struct parser_state *ps, size_t initial_size,
+ const struct language_defn *lang,
struct gdbarch *gdbarch)
{
- expout_size = initial_size;
- expout_ptr = 0;
- expout = xmalloc (sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size));
- expout->language_defn = lang;
- expout->gdbarch = gdbarch;
+ ps->expout_size = initial_size;
+ ps->expout_ptr = 0;
+ ps->expout = xmalloc (sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (ps->expout_size));
+ ps->expout->language_defn = lang;
+ ps->expout->gdbarch = gdbarch;
}
/* See definition in parser-defs.h. */
void
-reallocate_expout (void)
+reallocate_expout (struct parser_state *ps)
{
/* Record the actual number of expression elements, and then
reallocate the expression memory so that we free up any
excess elements. */
- expout->nelts = expout_ptr;
- expout = xrealloc ((char *) expout,
- sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_ptr));
+ ps->expout->nelts = ps->expout_ptr;
+ ps->expout = (struct expression *)
+ xrealloc (ps->expout,
+ sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (ps->expout_ptr));
}
+/* This page contains the functions for adding data to the struct expression
+ being constructed. */
+
/* Add one element to the end of the expression. */
/* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
a register through here. */
static void
-write_exp_elt (const union exp_element *expelt)
+write_exp_elt (struct parser_state *ps, const union exp_element *expelt)
{
- if (expout_ptr >= expout_size)
+ if (ps->expout_ptr >= ps->expout_size)
{
- expout_size *= 2;
- expout = (struct expression *)
- xrealloc ((char *) expout, sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size));
+ ps->expout_size *= 2;
+ ps->expout = (struct expression *)
+ xrealloc (ps->expout, sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (ps->expout_size));
}
- expout->elts[expout_ptr++] = *expelt;
+ ps->expout->elts[ps->expout_ptr++] = *expelt;
}
void
-write_exp_elt_opcode (enum exp_opcode expelt)
+write_exp_elt_opcode (struct parser_state *ps, enum exp_opcode expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.opcode = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_sym (struct symbol *expelt)
+write_exp_elt_sym (struct parser_state *ps, struct symbol *expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.symbol = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_block (const struct block *b)
+write_exp_elt_block (struct parser_state *ps, const struct block *b)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.block = b;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_objfile (struct objfile *objfile)
+write_exp_elt_objfile (struct parser_state *ps, struct objfile *objfile)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.objfile = objfile;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_longcst (LONGEST expelt)
+write_exp_elt_longcst (struct parser_state *ps, LONGEST expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.longconst = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_dblcst (DOUBLEST expelt)
+write_exp_elt_dblcst (struct parser_state *ps, DOUBLEST expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.doubleconst = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_decfloatcst (gdb_byte expelt[16])
+write_exp_elt_decfloatcst (struct parser_state *ps, gdb_byte expelt[16])
{
union exp_element tmp;
int index;
for (index = 0; index < 16; index++)
tmp.decfloatconst[index] = expelt[index];
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_type (struct type *expelt)
+write_exp_elt_type (struct parser_state *ps, struct type *expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.type = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
void
-write_exp_elt_intern (struct internalvar *expelt)
+write_exp_elt_intern (struct parser_state *ps, struct internalvar *expelt)
{
union exp_element tmp;
memset (&tmp, 0, sizeof (union exp_element));
tmp.internalvar = expelt;
- write_exp_elt (&tmp);
+ write_exp_elt (ps, &tmp);
}
/* Add a string constant to the end of the expression.
void
-write_exp_string (struct stoken str)
+write_exp_string (struct parser_state *ps, struct stoken str)
{
int len = str.length;
- int lenelt;
+ size_t lenelt;
char *strdata;
/* Compute the number of expression elements required to hold the string
lenelt = 2 + BYTES_TO_EXP_ELEM (len + 1);
- /* Ensure that we have enough available expression elements to store
- everything. */
-
- if ((expout_ptr + lenelt) >= expout_size)
- {
- expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
- expout = (struct expression *)
- xrealloc ((char *) expout, (sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size)));
- }
+ increase_expout_size (ps, lenelt);
/* Write the leading length expression element (which advances the current
expression element index), then write the string constant followed by a
terminating null byte, and then write the trailing length expression
element. */
- write_exp_elt_longcst ((LONGEST) len);
- strdata = (char *) &expout->elts[expout_ptr];
+ write_exp_elt_longcst (ps, (LONGEST) len);
+ strdata = (char *) &ps->expout->elts[ps->expout_ptr];
memcpy (strdata, str.ptr, len);
*(strdata + len) = '\0';
- expout_ptr += lenelt - 2;
- write_exp_elt_longcst ((LONGEST) len);
+ ps->expout_ptr += lenelt - 2;
+ write_exp_elt_longcst (ps, (LONGEST) len);
}
/* Add a vector of string constants to the end of the expression.
long constant, followed by the contents of the string. */
void
-write_exp_string_vector (int type, struct stoken_vector *vec)
+write_exp_string_vector (struct parser_state *ps, int type,
+ struct stoken_vector *vec)
{
- int i, n_slots, len;
+ int i, len;
+ size_t n_slots;
/* Compute the size. We compute the size in number of slots to
avoid issues with string padding. */
len = EXP_ELEM_TO_BYTES (n_slots) - 1;
n_slots += 4;
- if ((expout_ptr + n_slots) >= expout_size)
- {
- expout_size = max (expout_size * 2, expout_ptr + n_slots + 10);
- expout = (struct expression *)
- xrealloc ((char *) expout, (sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size)));
- }
+ increase_expout_size (ps, n_slots);
- write_exp_elt_opcode (OP_STRING);
- write_exp_elt_longcst (len);
- write_exp_elt_longcst (type);
+ write_exp_elt_opcode (ps, OP_STRING);
+ write_exp_elt_longcst (ps, len);
+ write_exp_elt_longcst (ps, type);
for (i = 0; i < vec->len; ++i)
{
- write_exp_elt_longcst (vec->tokens[i].length);
- memcpy (&expout->elts[expout_ptr], vec->tokens[i].ptr,
+ write_exp_elt_longcst (ps, vec->tokens[i].length);
+ memcpy (&ps->expout->elts[ps->expout_ptr], vec->tokens[i].ptr,
vec->tokens[i].length);
- expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
+ ps->expout_ptr += BYTES_TO_EXP_ELEM (vec->tokens[i].length);
}
- write_exp_elt_longcst (len);
- write_exp_elt_opcode (OP_STRING);
+ write_exp_elt_longcst (ps, len);
+ write_exp_elt_opcode (ps, OP_STRING);
}
/* Add a bitstring constant to the end of the expression.
either end of the bitstring. */
void
-write_exp_bitstring (struct stoken str)
+write_exp_bitstring (struct parser_state *ps, struct stoken str)
{
int bits = str.length; /* length in bits */
int len = (bits + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT;
- int lenelt;
+ size_t lenelt;
char *strdata;
/* Compute the number of expression elements required to hold the bitstring,
lenelt = 2 + BYTES_TO_EXP_ELEM (len);
- /* Ensure that we have enough available expression elements to store
- everything. */
-
- if ((expout_ptr + lenelt) >= expout_size)
- {
- expout_size = max (expout_size * 2, expout_ptr + lenelt + 10);
- expout = (struct expression *)
- xrealloc ((char *) expout, (sizeof (struct expression)
- + EXP_ELEM_TO_BYTES (expout_size)));
- }
+ increase_expout_size (ps, lenelt);
/* Write the leading length expression element (which advances the current
expression element index), then write the bitstring constant, and then
write the trailing length expression element. */
- write_exp_elt_longcst ((LONGEST) bits);
- strdata = (char *) &expout->elts[expout_ptr];
+ write_exp_elt_longcst (ps, (LONGEST) bits);
+ strdata = (char *) &ps->expout->elts[ps->expout_ptr];
memcpy (strdata, str.ptr, len);
- expout_ptr += lenelt - 2;
- write_exp_elt_longcst ((LONGEST) bits);
+ ps->expout_ptr += lenelt - 2;
+ write_exp_elt_longcst (ps, (LONGEST) bits);
}
/* Add the appropriate elements for a minimal symbol to the end of
the expression. */
void
-write_exp_msymbol (struct bound_minimal_symbol bound_msym)
+write_exp_msymbol (struct parser_state *ps,
+ struct bound_minimal_symbol bound_msym)
{
struct minimal_symbol *msymbol = bound_msym.minsym;
struct objfile *objfile = bound_msym.objfile;
if (overlay_debugging)
addr = symbol_overlayed_address (addr, section);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (ps, OP_LONG);
/* Let's make the type big enough to hold a 64-bit address. */
- write_exp_elt_type (objfile_type (objfile)->builtin_core_addr);
- write_exp_elt_longcst ((LONGEST) addr);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (ps, objfile_type (objfile)->builtin_core_addr);
+ write_exp_elt_longcst (ps, (LONGEST) addr);
+ write_exp_elt_opcode (ps, OP_LONG);
if (section && section->the_bfd_section->flags & SEC_THREAD_LOCAL)
{
- write_exp_elt_opcode (UNOP_MEMVAL_TLS);
- write_exp_elt_objfile (objfile);
- write_exp_elt_type (objfile_type (objfile)->nodebug_tls_symbol);
- write_exp_elt_opcode (UNOP_MEMVAL_TLS);
+ write_exp_elt_opcode (ps, UNOP_MEMVAL_TLS);
+ write_exp_elt_objfile (ps, objfile);
+ write_exp_elt_type (ps, objfile_type (objfile)->nodebug_tls_symbol);
+ write_exp_elt_opcode (ps, UNOP_MEMVAL_TLS);
return;
}
- write_exp_elt_opcode (UNOP_MEMVAL);
+ write_exp_elt_opcode (ps, UNOP_MEMVAL);
switch (type)
{
case mst_text:
case mst_file_text:
case mst_solib_trampoline:
- write_exp_elt_type (objfile_type (objfile)->nodebug_text_symbol);
+ write_exp_elt_type (ps, objfile_type (objfile)->nodebug_text_symbol);
break;
case mst_text_gnu_ifunc:
- write_exp_elt_type (objfile_type (objfile)
- ->nodebug_text_gnu_ifunc_symbol);
+ write_exp_elt_type (ps, objfile_type (objfile)
+ ->nodebug_text_gnu_ifunc_symbol);
break;
case mst_data:
case mst_file_data:
case mst_bss:
case mst_file_bss:
- write_exp_elt_type (objfile_type (objfile)->nodebug_data_symbol);
+ write_exp_elt_type (ps, objfile_type (objfile)->nodebug_data_symbol);
break;
case mst_slot_got_plt:
- write_exp_elt_type (objfile_type (objfile)->nodebug_got_plt_symbol);
+ write_exp_elt_type (ps, objfile_type (objfile)->nodebug_got_plt_symbol);
break;
default:
- write_exp_elt_type (objfile_type (objfile)->nodebug_unknown_symbol);
+ write_exp_elt_type (ps, objfile_type (objfile)->nodebug_unknown_symbol);
break;
}
- write_exp_elt_opcode (UNOP_MEMVAL);
+ write_exp_elt_opcode (ps, UNOP_MEMVAL);
}
/* Mark the current index as the starting location of a structure
expression. This is used when completing on field names. */
void
-mark_struct_expression (void)
+mark_struct_expression (struct parser_state *ps)
{
gdb_assert (parse_completion
&& expout_tag_completion_type == TYPE_CODE_UNDEF);
- expout_last_struct = expout_ptr;
+ expout_last_struct = ps->expout_ptr;
}
/* Indicate that the current parser invocation is completing a tag.
value in the value history, I.e. $$1 */
void
-write_dollar_variable (struct stoken str)
+write_dollar_variable (struct parser_state *ps, struct stoken str)
{
struct symbol *sym = NULL;
struct bound_minimal_symbol msym;
/* Handle tokens that refer to machine registers:
$ followed by a register name. */
- i = user_reg_map_name_to_regnum (parse_gdbarch,
+ i = user_reg_map_name_to_regnum (parse_gdbarch (ps),
str.ptr + 1, str.length - 1);
if (i >= 0)
goto handle_register;
isym = lookup_only_internalvar (copy_name (str) + 1);
if (isym)
{
- write_exp_elt_opcode (OP_INTERNALVAR);
- write_exp_elt_intern (isym);
- write_exp_elt_opcode (OP_INTERNALVAR);
+ write_exp_elt_opcode (ps, OP_INTERNALVAR);
+ write_exp_elt_intern (ps, isym);
+ write_exp_elt_opcode (ps, OP_INTERNALVAR);
return;
}
VAR_DOMAIN, NULL);
if (sym)
{
- write_exp_elt_opcode (OP_VAR_VALUE);
- write_exp_elt_block (block_found); /* set by lookup_symbol */
- write_exp_elt_sym (sym);
- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (ps, OP_VAR_VALUE);
+ write_exp_elt_block (ps, block_found); /* set by lookup_symbol */
+ write_exp_elt_sym (ps, sym);
+ write_exp_elt_opcode (ps, OP_VAR_VALUE);
return;
}
msym = lookup_bound_minimal_symbol (copy_name (str));
if (msym.minsym)
{
- write_exp_msymbol (msym);
+ write_exp_msymbol (ps, msym);
return;
}
/* Any other names are assumed to be debugger internal variables. */
- write_exp_elt_opcode (OP_INTERNALVAR);
- write_exp_elt_intern (create_internalvar (copy_name (str) + 1));
- write_exp_elt_opcode (OP_INTERNALVAR);
+ write_exp_elt_opcode (ps, OP_INTERNALVAR);
+ write_exp_elt_intern (ps, create_internalvar (copy_name (str) + 1));
+ write_exp_elt_opcode (ps, OP_INTERNALVAR);
return;
handle_last:
- write_exp_elt_opcode (OP_LAST);
- write_exp_elt_longcst ((LONGEST) i);
- write_exp_elt_opcode (OP_LAST);
+ write_exp_elt_opcode (ps, OP_LAST);
+ write_exp_elt_longcst (ps, (LONGEST) i);
+ write_exp_elt_opcode (ps, OP_LAST);
return;
handle_register:
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (ps, OP_REGISTER);
str.length--;
str.ptr++;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (ps, str);
+ write_exp_elt_opcode (ps, OP_REGISTER);
return;
}
volatile struct gdb_exception except;
struct cleanup *old_chain, *inner_chain;
const struct language_defn *lang = NULL;
+ struct parser_state ps;
int subexp;
lexptr = *stringptr;
While we need CURRENT_LANGUAGE to be set to LANG (for lookup_symbol
and others called from *.y) ensure CURRENT_LANGUAGE gets restored
to the value matching SELECTED_FRAME as set by get_current_arch. */
- initialize_expout (10, lang, get_current_arch ());
+
+ initialize_expout (&ps, 10, lang, get_current_arch ());
inner_chain = make_cleanup_restore_current_language ();
set_language (lang->la_language);
TRY_CATCH (except, RETURN_MASK_ALL)
{
- if (lang->la_parser ())
+ if (lang->la_parser (&ps))
lang->la_error (NULL);
}
if (except.reason < 0)
{
if (! parse_completion)
{
- xfree (expout);
+ xfree (ps.expout);
throw_exception (except);
}
}
- reallocate_expout ();
+ reallocate_expout (&ps);
/* Convert expression from postfix form as generated by yacc
parser, to a prefix form. */
if (expressiondebug)
- dump_raw_expression (expout, gdb_stdlog,
+ dump_raw_expression (ps.expout, gdb_stdlog,
"before conversion to prefix form");
- subexp = prefixify_expression (expout);
+ subexp = prefixify_expression (ps.expout);
if (out_subexp)
*out_subexp = subexp;
- lang->la_post_parser (&expout, void_context_p);
+ lang->la_post_parser (&ps.expout, void_context_p);
if (expressiondebug)
- dump_prefix_expression (expout, gdb_stdlog);
+ dump_prefix_expression (ps.expout, gdb_stdlog);
do_cleanups (inner_chain);
discard_cleanups (old_chain);
*stringptr = lexptr;
- return expout;
+ return ps.expout;
}
/* Parse STRING as an expression, and complain if this fails
item. */
void
-insert_type_address_space (char *string)
+insert_type_address_space (struct parser_state *pstate, char *string)
{
union type_stack_elt element;
int slot;
element.piece = tp_space_identifier;
insert_into_type_stack (slot, element);
- element.int_val = address_space_name_to_int (parse_gdbarch, string);
+ element.int_val = address_space_name_to_int (parse_gdbarch (pstate),
+ string);
insert_into_type_stack (slot, element);
}
return exp_iterate (exp, exp_uses_objfile_iter, objfile);
}
+/* See definition in parser-defs.h. */
+
+void
+increase_expout_size (struct parser_state *ps, size_t lenelt)
+{
+ if ((ps->expout_ptr + lenelt) >= ps->expout_size)
+ {
+ ps->expout_size = max (ps->expout_size * 2,
+ ps->expout_ptr + lenelt + 10);
+ ps->expout = (struct expression *)
+ xrealloc (ps->expout, (sizeof (struct expression)
+ + EXP_ELEM_TO_BYTES (ps->expout_size)));
+ }
+}
+
void
_initialize_parse (void)
{
#include "expression.h"
struct block;
+struct language_defn;
+struct internalvar;
extern int parser_debug;
-extern struct expression *expout;
-extern int expout_size;
-extern int expout_ptr;
+#define parse_gdbarch(ps) ((ps)->expout->gdbarch)
+#define parse_language(ps) ((ps)->expout->language_defn)
-#define parse_gdbarch (expout->gdbarch)
-#define parse_language (expout->language_defn)
+struct parser_state
+{
+ /* The expression related to this parser state. */
+
+ struct expression *expout;
+
+ /* The size of the expression above. */
+
+ size_t expout_size;
+
+ /* The number of elements already in the expression. This is used
+ to know where to put new elements. */
+
+ size_t expout_ptr;
+};
/* If this is nonzero, this block is used as the lexical context
for symbol names. */
};
/* Helper function to initialize the expout, expout_size, expout_ptr
- trio before it is used to store expression elements created during
- the parsing of an expression. INITIAL_SIZE is the initial size of
+ trio inside PS before it is used to store expression elements created
+ during the parsing of an expression. INITIAL_SIZE is the initial size of
the expout array. LANG is the language used to parse the expression.
And GDBARCH is the gdbarch to use during parsing. */
-extern void initialize_expout (int, const struct language_defn *,
- struct gdbarch *);
+extern void initialize_expout (struct parser_state *ps,
+ size_t initial_size,
+ const struct language_defn *lang,
+ struct gdbarch *gdbarch);
-/* Helper function that frees any unsed space in the expout array.
- It is generally used when the parser has just been parsed and
- created. */
+/* Helper function that reallocates the EXPOUT inside PS in order to
+ eliminate any unused space. It is generally used when the expression
+ has just been parsed and created. */
-extern void reallocate_expout (void);
+extern void reallocate_expout (struct parser_state *ps);
/* Reverse an expression from suffix form (in which it is constructed)
to prefix form (in which we can conveniently print or execute it).
extern int prefixify_expression (struct expression *expr);
-extern void write_exp_elt_opcode (enum exp_opcode);
+extern void write_exp_elt_opcode (struct parser_state *, enum exp_opcode);
-extern void write_exp_elt_sym (struct symbol *);
+extern void write_exp_elt_sym (struct parser_state *, struct symbol *);
-extern void write_exp_elt_longcst (LONGEST);
+extern void write_exp_elt_longcst (struct parser_state *, LONGEST);
-extern void write_exp_elt_dblcst (DOUBLEST);
+extern void write_exp_elt_dblcst (struct parser_state *, DOUBLEST);
-extern void write_exp_elt_decfloatcst (gdb_byte *);
+extern void write_exp_elt_decfloatcst (struct parser_state *, gdb_byte *);
-extern void write_exp_elt_type (struct type *);
+extern void write_exp_elt_type (struct parser_state *, struct type *);
-extern void write_exp_elt_intern (struct internalvar *);
+extern void write_exp_elt_intern (struct parser_state *, struct internalvar *);
-extern void write_exp_string (struct stoken);
+extern void write_exp_string (struct parser_state *, struct stoken);
-void write_exp_string_vector (int type, struct stoken_vector *vec);
+void write_exp_string_vector (struct parser_state *, int type,
+ struct stoken_vector *vec);
-extern void write_exp_bitstring (struct stoken);
+extern void write_exp_bitstring (struct parser_state *, struct stoken);
-extern void write_exp_elt_block (const struct block *);
+extern void write_exp_elt_block (struct parser_state *, const struct block *);
-extern void write_exp_elt_objfile (struct objfile *objfile);
+extern void write_exp_elt_objfile (struct parser_state *,
+ struct objfile *objfile);
-extern void write_exp_msymbol (struct bound_minimal_symbol);
+extern void write_exp_msymbol (struct parser_state *,
+ struct bound_minimal_symbol);
-extern void write_dollar_variable (struct stoken str);
+extern void write_dollar_variable (struct parser_state *, struct stoken str);
-extern void mark_struct_expression (void);
+extern void mark_struct_expression (struct parser_state *);
extern const char *find_template_name_end (const char *);
extern void push_type_int (int);
-extern void insert_type_address_space (char *);
+extern void insert_type_address_space (struct parser_state *, char *);
extern enum type_pieces pop_type (void);
extern void mark_completion_tag (enum type_code, const char *ptr,
int length);
+/* Reallocate the `expout' pointer inside PS so that it can accommodate
+ at least LENELT expression elements. This function does nothing if
+ there is enough room for the elements. */
+
+extern void increase_expout_size (struct parser_state *ps, size_t lenelt);
+
#endif /* PARSER_DEFS_H */
error (_("Invalid register name `%s' on expression `%s'."),
regname, p->saved_arg);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname;
str.length = len;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, str);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
p->arg = s;
}
p->arg = endp;
/* Generating the expression for the displacement. */
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (displacement);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, displacement);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (got_minus)
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
}
/* Getting rid of register indirection prefix. */
error (_("Invalid register name `%s' on expression `%s'."),
regname, p->saved_arg);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
str.ptr = regname;
str.length = len;
- write_exp_string (str);
- write_exp_elt_opcode (OP_REGISTER);
+ write_exp_string (&p->pstate, str);
+ write_exp_elt_opcode (&p->pstate, OP_REGISTER);
if (indirect_p)
{
if (disp_p)
- write_exp_elt_opcode (BINOP_ADD);
+ write_exp_elt_opcode (&p->pstate, BINOP_ADD);
/* Casting to the expected type. */
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (lookup_pointer_type (p->arg_type));
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
+ write_exp_elt_type (&p->pstate, lookup_pointer_type (p->arg_type));
+ write_exp_elt_opcode (&p->pstate, UNOP_CAST);
- write_exp_elt_opcode (UNOP_IND);
+ write_exp_elt_opcode (&p->pstate, UNOP_IND);
}
/* Getting rid of the register name suffix. */
++p->arg;
stap_parse_argument_conditionally (p);
if (c == '-')
- write_exp_elt_opcode (UNOP_NEG);
+ write_exp_elt_opcode (&p->pstate, UNOP_NEG);
else if (c == '~')
- write_exp_elt_opcode (UNOP_COMPLEMENT);
+ write_exp_elt_opcode (&p->pstate, UNOP_COMPLEMENT);
}
else
{
const char *int_suffix;
/* We are dealing with a numeric constant. */
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (number);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate,
+ builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, number);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
p->arg = tmp;
number = strtol (p->arg, &endp, 10);
p->arg = endp;
- write_exp_elt_opcode (OP_LONG);
- write_exp_elt_type (builtin_type (gdbarch)->builtin_long);
- write_exp_elt_longcst (number);
- write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
+ write_exp_elt_type (&p->pstate, builtin_type (gdbarch)->builtin_long);
+ write_exp_elt_longcst (&p->pstate, number);
+ write_exp_elt_opcode (&p->pstate, OP_LONG);
if (stap_check_integer_suffix (gdbarch, p->arg, &int_suffix))
p->arg += strlen (int_suffix);
stap_parse_argument_1 (p, 1, lookahead_prec);
}
- write_exp_elt_opcode (opcode);
+ write_exp_elt_opcode (&p->pstate, opcode);
}
}
/* We need to initialize the expression buffer, in order to begin
our parsing efforts. The language here does not matter, since we
are using our own parser. */
- initialize_expout (10, current_language, gdbarch);
- back_to = make_cleanup (free_current_contents, &expout);
+ initialize_expout (&p.pstate, 10, current_language, gdbarch);
+ back_to = make_cleanup (free_current_contents, &p.pstate.expout);
p.saved_arg = *arg;
p.arg = *arg;
gdb_assert (p.inside_paren_p == 0);
/* Casting the final expression to the appropriate type. */
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type (atype);
- write_exp_elt_opcode (UNOP_CAST);
+ write_exp_elt_opcode (&p.pstate, UNOP_CAST);
+ write_exp_elt_type (&p.pstate, atype);
+ write_exp_elt_opcode (&p.pstate, UNOP_CAST);
- reallocate_expout ();
+ reallocate_expout (&p.pstate);
p.arg = skip_spaces_const (p.arg);
*arg = p.arg;
- return expout;
+ /* We can safely return EXPOUT here. */
+ return p.pstate.expout;
}
/* Function which parses an argument string from PROBE, correctly splitting
#if !defined (STAP_PROBE_H)
#define STAP_PROBE_H 1
+/* For `struct parser_state'. */
+#include "parser-defs.h"
+
/* Structure which holds information about the parsing process of one probe's
argument. */
/* The probe's argument in a string format. */
const char *arg;
+ /* The parser state to be used when generating the expression. */
+ struct parser_state pstate;
+
/* A pointer to the full chain of arguments. This is useful for printing
error messages. The parser functions should not modify this argument
directly; instead, they should use the ARG pointer above. */
(void *) (uintptr_t) saved_lang);
}
+/* Helper function for make_cleanup_clear_parser_state. */
+
+static void
+do_clear_parser_state (void *ptr)
+{
+ struct parser_state **p = (struct parser_state **) ptr;
+
+ *p = NULL;
+}
+
+/* Clean (i.e., set to NULL) the parser state variable P. */
+
+struct cleanup *
+make_cleanup_clear_parser_state (struct parser_state **p)
+{
+ return make_cleanup (do_clear_parser_state, (void *) p);
+}
+
/* This function is useful for cleanups.
Do
extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
+struct parser_state;
+extern struct cleanup *make_cleanup_clear_parser_state
+ (struct parser_state **p);
+
extern void free_current_contents (void *);
extern void init_page_info (void);