[RFC 2/8] C language

Sergio Durigan Junior
2012-01-15T18:59:28Z

Hi,

This patch modifies gdb/{c-exp.y,c-lang.h} in order to reflect the
changes made by the first patch of the series.

Here and in all the .y files, I had to add an argument to the parser and
the lexer functions, which is a `struct parser_state *ps'.

Thanks,

Sergio.

diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index bf4f4bc..139cf67 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -54,7 +54,7 @@
#include "gdb_assert.h"
#include "macroscope.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
@@ -110,14 +110,17 @@

#define YYFPRINTF parser_fprintf

-int yyparse (void);
+int yyparse (struct parser_state *);

-static int yylex (void);
+static int yylex (struct parser_state *);

-void yyerror (char *);
+void yyerror (struct parser_state *, char *);

%}

+%parse-param {struct parser_state *ps}
+%lex-param {struct parser_state *ps}
+
/* Although the yacc "value" of an expression is not used,
since the result is stored in the structure being created,
other node types do have values. */
@@ -155,7 +158,8 @@ void yyerror (char *);

%{
/* YYSTYPE gets defined by %union */
-static int parse_number (char *, int, int, YYSTYPE *);
+static int parse_number (struct parser_state *ps, char *, int, int,
+ YYSTYPE *);
static struct stoken operator_stoken (const char *);
%}

@@ -252,134 +256,134 @@ start : exp1
;

type_exp: type
- { write_exp_elt_opcode(OP_TYPE);
- write_exp_elt_type($1);
- write_exp_elt_opcode(OP_TYPE);}
+ { write_exp_elt_opcode (ps, OP_TYPE);
+ write_exp_elt_type (ps, $1);
+ write_exp_elt_opcode (ps, OP_TYPE);}
;

/* Expressions, including the comma operator. */
exp1 : exp
| exp1 ',' exp
- { write_exp_elt_opcode (BINOP_COMMA); }
+ { write_exp_elt_opcode (ps, BINOP_COMMA); }
;

/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_IND); }
+ { write_exp_elt_opcode (ps, UNOP_IND); }
;

exp : '&' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_ADDR); }
+ { write_exp_elt_opcode (ps, UNOP_ADDR); }
;

exp : '-' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_NEG); }
+ { write_exp_elt_opcode (ps, UNOP_NEG); }
;

exp : '+' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PLUS); }
+ { write_exp_elt_opcode (ps, UNOP_PLUS); }
;

exp : '!' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
+ { write_exp_elt_opcode (ps, UNOP_LOGICAL_NOT); }
;

exp : '~' exp %prec UNARY
- { write_exp_elt_opcode (UNOP_COMPLEMENT); }
+ { write_exp_elt_opcode (ps, UNOP_COMPLEMENT); }
;

exp : INCREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREINCREMENT); }
+ { write_exp_elt_opcode (ps, UNOP_PREINCREMENT); }
;

exp : DECREMENT exp %prec UNARY
- { write_exp_elt_opcode (UNOP_PREDECREMENT); }
+ { write_exp_elt_opcode (ps, UNOP_PREDECREMENT); }
;

exp : exp INCREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
+ { write_exp_elt_opcode (ps, UNOP_POSTINCREMENT); }
;

exp : exp DECREMENT %prec UNARY
- { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
+ { write_exp_elt_opcode (ps, UNOP_POSTDECREMENT); }
;

exp : SIZEOF exp %prec UNARY
- { write_exp_elt_opcode (UNOP_SIZEOF); }
+ { write_exp_elt_opcode (ps, 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 (ps, STRUCTOP_PTR);
+ write_exp_string (ps, $3);
+ write_exp_elt_opcode (ps, 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 (ps);
+ write_exp_elt_opcode (ps, STRUCTOP_PTR);
+ write_exp_string (ps, $3);
+ write_exp_elt_opcode (ps, STRUCTOP_PTR); }
;

exp : exp ARROW COMPLETE
{ struct stoken s;
- mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_PTR);
+ mark_struct_expression (ps);
+ write_exp_elt_opcode (ps, STRUCTOP_PTR);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_PTR); }
+ write_exp_string (ps, s);
+ write_exp_elt_opcode (ps, 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 (ps, UNOP_ADDR);
+ write_exp_elt_opcode (ps, STRUCTOP_MPTR); }
;

exp : exp ARROW_STAR exp
- { write_exp_elt_opcode (STRUCTOP_MPTR); }
+ { write_exp_elt_opcode (ps, 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 (ps, STRUCTOP_STRUCT);
+ write_exp_string (ps, $3);
+ write_exp_elt_opcode (ps, 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 (ps);
+ write_exp_elt_opcode (ps, STRUCTOP_STRUCT);
+ write_exp_string (ps, $3);
+ write_exp_elt_opcode (ps, STRUCTOP_STRUCT); }
;

exp : exp '.' COMPLETE
{ struct stoken s;
- mark_struct_expression ();
- write_exp_elt_opcode (STRUCTOP_STRUCT);
+ mark_struct_expression (ps);
+ write_exp_elt_opcode (ps, STRUCTOP_STRUCT);
s.ptr = "";
s.length = 0;
- write_exp_string (s);
- write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ write_exp_string (ps, s);
+ write_exp_elt_opcode (ps, 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 (ps, UNOP_ADDR);
+ write_exp_elt_opcode (ps, STRUCTOP_MEMBER); }
;

exp : exp DOT_STAR exp
- { write_exp_elt_opcode (STRUCTOP_MEMBER); }
+ { write_exp_elt_opcode (ps, STRUCTOP_MEMBER); }
;

exp : exp '[' exp1 ']'
- { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
+ { write_exp_elt_opcode (ps, BINOP_SUBSCRIPT); }
;

exp : exp '('
@@ -387,20 +391,20 @@ exp : exp '('
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 (ps, OP_FUNCALL);
+ write_exp_elt_longcst (ps, (LONGEST) end_arglist ());
+ write_exp_elt_opcode (ps, 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 (ps, OP_ADL_FUNC);
+ write_exp_elt_block (ps, expression_context_block);
+ write_exp_elt_sym (ps, NULL); /* Placeholder. */
+ write_exp_string (ps, $1.stoken);
+ write_exp_elt_opcode (ps, OP_ADL_FUNC);

/* This is to save the value of arglist_len
being accumulated by an outer function call. */
@@ -409,9 +413,9 @@ exp : UNKNOWN_CPP_NAME '('
}
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 (ps, OP_FUNCALL);
+ write_exp_elt_longcst (ps, (LONGEST) end_arglist ());
+ write_exp_elt_opcode (ps, OP_FUNCALL);
}
;

@@ -432,12 +436,12 @@ arglist : arglist ',' exp %prec ABOVE_COMMA

exp : exp '(' nonempty_typelist ')' const_or_volatile
{ int i;
- write_exp_elt_opcode (TYPE_INSTANCE);
- write_exp_elt_longcst ((LONGEST) $<ivec>3[0]);
+ write_exp_elt_opcode (ps, TYPE_INSTANCE);
+ write_exp_elt_longcst (ps, (LONGEST) $<ivec>3[0]);
for (i = 0; i < $<ivec>3[0]; ++i)
- write_exp_elt_type ($<tvec>3[i + 1]);
- write_exp_elt_longcst((LONGEST) $<ivec>3[0]);
- write_exp_elt_opcode (TYPE_INSTANCE);
+ write_exp_elt_type (ps, $<tvec>3[i + 1]);
+ write_exp_elt_longcst (ps, (LONGEST) $<ivec>3[0]);
+ write_exp_elt_opcode (ps, TYPE_INSTANCE);
free ($3);
}
;
@@ -446,22 +450,22 @@ rcurly : '}'
{ $$ = 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 (ps, OP_ARRAY);
+ write_exp_elt_longcst (ps, (LONGEST) 0);
+ write_exp_elt_longcst (ps, (LONGEST) $3);
+ write_exp_elt_opcode (ps, OP_ARRAY); }
;

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 (ps, UNOP_MEMVAL);
+ write_exp_elt_type (ps, $2);
+ write_exp_elt_opcode (ps, UNOP_MEMVAL); }
;

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 (ps, UNOP_CAST);
+ write_exp_elt_type (ps, $2);
+ write_exp_elt_opcode (ps, UNOP_CAST); }
;

exp : '(' exp1 ')'
@@ -471,100 +475,100 @@ exp : '(' exp1 ')'
/* Binary operators in order of decreasing precedence. */

exp : exp '@' exp
- { write_exp_elt_opcode (BINOP_REPEAT); }
+ { write_exp_elt_opcode (ps, BINOP_REPEAT); }
;

exp : exp '*' exp
- { write_exp_elt_opcode (BINOP_MUL); }
+ { write_exp_elt_opcode (ps, BINOP_MUL); }
;

exp : exp '/' exp
- { write_exp_elt_opcode (BINOP_DIV); }
+ { write_exp_elt_opcode (ps, BINOP_DIV); }
;

exp : exp '%' exp
- { write_exp_elt_opcode (BINOP_REM); }
+ { write_exp_elt_opcode (ps, BINOP_REM); }
;

exp : exp '+' exp
- { write_exp_elt_opcode (BINOP_ADD); }
+ { write_exp_elt_opcode (ps, BINOP_ADD); }
;

exp : exp '-' exp
- { write_exp_elt_opcode (BINOP_SUB); }
+ { write_exp_elt_opcode (ps, BINOP_SUB); }
;

exp : exp LSH exp
- { write_exp_elt_opcode (BINOP_LSH); }
+ { write_exp_elt_opcode (ps, BINOP_LSH); }
;

exp : exp RSH exp
- { write_exp_elt_opcode (BINOP_RSH); }
+ { write_exp_elt_opcode (ps, BINOP_RSH); }
;

exp : exp EQUAL exp
- { write_exp_elt_opcode (BINOP_EQUAL); }
+ { write_exp_elt_opcode (ps, BINOP_EQUAL); }
;

exp : exp NOTEQUAL exp
- { write_exp_elt_opcode (BINOP_NOTEQUAL); }
+ { write_exp_elt_opcode (ps, BINOP_NOTEQUAL); }
;

exp : exp LEQ exp
- { write_exp_elt_opcode (BINOP_LEQ); }
+ { write_exp_elt_opcode (ps, BINOP_LEQ); }
;

exp : exp GEQ exp
- { write_exp_elt_opcode (BINOP_GEQ); }
+ { write_exp_elt_opcode (ps, BINOP_GEQ); }
;

exp : exp '<' exp
- { write_exp_elt_opcode (BINOP_LESS); }
+ { write_exp_elt_opcode (ps, BINOP_LESS); }
;

exp : exp '>' exp
- { write_exp_elt_opcode (BINOP_GTR); }
+ { write_exp_elt_opcode (ps, BINOP_GTR); }
;

exp : exp '&' exp
- { write_exp_elt_opcode (BINOP_BITWISE_AND); }
+ { write_exp_elt_opcode (ps, BINOP_BITWISE_AND); }
;

exp : exp '^' exp
- { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
+ { write_exp_elt_opcode (ps, BINOP_BITWISE_XOR); }
;

exp : exp '|' exp
- { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
+ { write_exp_elt_opcode (ps, BINOP_BITWISE_IOR); }
;

exp : exp ANDAND exp
- { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
+ { write_exp_elt_opcode (ps, BINOP_LOGICAL_AND); }
;

exp : exp OROR exp
- { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
+ { write_exp_elt_opcode (ps, BINOP_LOGICAL_OR); }
;

exp : exp '?' exp ':' exp %prec '?'
- { write_exp_elt_opcode (TERNOP_COND); }
+ { write_exp_elt_opcode (ps, TERNOP_COND); }
;

exp : exp '=' exp
- { write_exp_elt_opcode (BINOP_ASSIGN); }
+ { write_exp_elt_opcode (ps, 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 (ps, BINOP_ASSIGN_MODIFY);
+ write_exp_elt_opcode (ps, $2);
+ write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+ write_exp_elt_type (ps, $1.type);
+ write_exp_elt_longcst (ps, (LONGEST) ($1.val));
+ write_exp_elt_opcode (ps, OP_LONG); }
;

exp : CHAR
@@ -572,33 +576,34 @@ exp : CHAR
struct stoken_vector vec;
vec.len = 1;
vec.tokens = &$1;
- write_exp_string_vector ($1.type, &vec);
+ write_exp_string_vector (ps, $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 (ps, $1.stoken.ptr, $1.stoken.length,
+ 0, &val);
+ write_exp_elt_opcode (ps, OP_LONG);
+ write_exp_elt_type (ps, val.typed_val_int.type);
+ write_exp_elt_longcst (ps, (LONGEST) val.typed_val_int.val);
+ write_exp_elt_opcode (ps, 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 (ps, OP_DOUBLE);
+ write_exp_elt_type (ps, $1.type);
+ write_exp_elt_dblcst (ps, $1.dval);
+ write_exp_elt_opcode (ps, 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 (ps, OP_DECFLOAT);
+ write_exp_elt_type (ps, $1.type);
+ write_exp_elt_decfloatcst (ps, $1.val);
+ write_exp_elt_opcode (ps, OP_DECFLOAT); }
;

exp : variable
@@ -606,44 +611,45 @@ exp : variable

exp : VARIABLE
{
- write_dollar_variable ($1);
+ write_dollar_variable (ps, $1);
}
;

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 (ps, OP_LONG);
+ write_exp_elt_type (ps, lookup_signed_typename
+ (parse_language (ps),
+ parse_gdbarch (ps),
"int"));
CHECK_TYPEDEF ($3);
- write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
- write_exp_elt_opcode (OP_LONG); }
+ write_exp_elt_longcst (ps, (LONGEST) TYPE_LENGTH ($3));
+ write_exp_elt_opcode (ps, OP_LONG); }
;

exp : REINTERPRET_CAST '<' type '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_REINTERPRET_CAST);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_REINTERPRET_CAST); }
+ { write_exp_elt_opcode (ps, UNOP_REINTERPRET_CAST);
+ write_exp_elt_type (ps, $3);
+ write_exp_elt_opcode (ps, UNOP_REINTERPRET_CAST); }
;

exp : STATIC_CAST '<' type '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_CAST); }
+ { write_exp_elt_opcode (ps, UNOP_CAST);
+ write_exp_elt_type (ps, $3);
+ write_exp_elt_opcode (ps, UNOP_CAST); }
;

exp : DYNAMIC_CAST '<' type '>' '(' exp ')' %prec UNARY
- { write_exp_elt_opcode (UNOP_DYNAMIC_CAST);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_DYNAMIC_CAST); }
+ { write_exp_elt_opcode (ps, UNOP_DYNAMIC_CAST);
+ write_exp_elt_type (ps, $3);
+ write_exp_elt_opcode (ps, UNOP_DYNAMIC_CAST); }
;

exp : CONST_CAST '<' type '>' '(' exp ')' %prec UNARY
{ /* We could do more error checking here, but
it doesn't seem worthwhile. */
- write_exp_elt_opcode (UNOP_CAST);
- write_exp_elt_type ($3);
- write_exp_elt_opcode (UNOP_CAST); }
+ write_exp_elt_opcode (ps, UNOP_CAST);
+ write_exp_elt_type (ps, $3);
+ write_exp_elt_opcode (ps, UNOP_CAST); }
;

string_exp:
@@ -708,7 +714,7 @@ exp : string_exp
}
}

- write_exp_string_vector (type, &$1);
+ write_exp_string_vector (ps, type, &$1);
for (i = 0; i < $1.len; ++i)
free ($1.tokens[i].ptr);
free ($1.tokens);
@@ -717,17 +723,17 @@ exp : string_exp

/* 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 (ps, OP_LONG);
+ write_exp_elt_type (ps, parse_type (ps)->builtin_bool);
+ write_exp_elt_longcst (ps, (LONGEST) 1);
+ write_exp_elt_opcode (ps, 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 (ps, OP_LONG);
+ write_exp_elt_type (ps, parse_type (ps)->builtin_bool);
+ write_exp_elt_longcst (ps, (LONGEST) 0);
+ write_exp_elt_opcode (ps, OP_LONG); }
;

/* end of C++. */
@@ -765,9 +771,9 @@ 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 (ps, OP_VAR_ENTRY_VALUE);
+ write_exp_elt_sym (ps, sym);
+ write_exp_elt_opcode (ps, OP_VAR_ENTRY_VALUE);
}
;

@@ -786,11 +792,11 @@ variable: block COLONCOLON name
innermost_block = block_found;
}

- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (ps, 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 (ps, block_found);
+ write_exp_elt_sym (ps, sym);
+ write_exp_elt_opcode (ps, OP_VAR_VALUE); }
;

qualified_name: TYPENAME COLONCOLON name
@@ -803,10 +809,10 @@ qualified_name: TYPENAME 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 (ps, OP_SCOPE);
+ write_exp_elt_type (ps, type);
+ write_exp_string (ps, $3);
+ write_exp_elt_opcode (ps, OP_SCOPE);
}
| TYPENAME COLONCOLON '~' name
{
@@ -827,10 +833,10 @@ qualified_name: 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 (ps, OP_SCOPE);
+ write_exp_elt_type (ps, type);
+ write_exp_string (ps, tmp_token);
+ write_exp_elt_opcode (ps, OP_SCOPE);
}
| TYPENAME COLONCOLON name COLONCOLON name
{
@@ -853,16 +859,16 @@ variable: qualified_name
VAR_DOMAIN, (int *) 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 (ps, OP_VAR_VALUE);
+ write_exp_elt_block (ps, NULL);
+ write_exp_elt_sym (ps, sym);
+ write_exp_elt_opcode (ps, OP_VAR_VALUE);
break;
}

msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (ps, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
@@ -883,13 +889,13 @@ variable: name_not_typename
innermost_block = block_found;
}

- write_exp_elt_opcode (OP_VAR_VALUE);
+ write_exp_elt_opcode (ps, 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 (ps, NULL);
+ write_exp_elt_sym (ps, sym);
+ write_exp_elt_opcode (ps, OP_VAR_VALUE);
}
else if ($1.is_a_field_of_this)
{
@@ -900,11 +906,11 @@ variable: name_not_typename
|| 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 (ps, OP_THIS);
+ write_exp_elt_opcode (ps, OP_THIS);
+ write_exp_elt_opcode (ps, STRUCTOP_PTR);
+ write_exp_string (ps, $1.stoken);
+ write_exp_elt_opcode (ps, STRUCTOP_PTR);
}
else
{
@@ -914,7 +920,7 @@ variable: name_not_typename
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
if (msymbol != NULL)
- write_exp_msymbol (msymbol);
+ write_exp_msymbol (ps, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
else
@@ -925,7 +931,7 @@ variable: name_not_typename
;

space_identifier : '@' NAME
- { push_type_address_space (copy_name ($2.stoken));
+ { push_type_address_space (ps, copy_name ($2.stoken));
push_type (tp_space_identifier);
}
;
@@ -1004,115 +1010,115 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
: TYPENAME
{ $$ = $1.type; }
| INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"int"); }
| LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| SHORT
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| LONG SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| SIGNED_KEYWORD LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| UNSIGNED LONG INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| LONG UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| LONG UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long"); }
| LONG LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| LONG LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| LONG LONG SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| LONG LONG SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| SIGNED_KEYWORD LONG LONG
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| SIGNED_KEYWORD LONG LONG INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| UNSIGNED LONG LONG
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| UNSIGNED LONG LONG INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| LONG LONG UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| LONG LONG UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long long"); }
| SHORT INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| SHORT SIGNED_KEYWORD INT_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| SHORT SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| UNSIGNED SHORT INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| SHORT UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| SHORT UNSIGNED INT_KEYWORD
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short"); }
| DOUBLE_KEYWORD
- { $$ = lookup_typename (parse_language, parse_gdbarch,
+ { $$ = lookup_typename (parse_language (ps), parse_gdbarch (ps),
"double", (struct block *) NULL,
0); }
| LONG DOUBLE_KEYWORD
- { $$ = lookup_typename (parse_language, parse_gdbarch,
+ { $$ = lookup_typename (parse_language (ps), parse_gdbarch (ps),
"long double",
(struct block *) NULL, 0); }
| STRUCT name
@@ -1128,20 +1134,20 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */
{ $$ = lookup_enum (copy_name ($2),
expression_context_block); }
| UNSIGNED typename
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
TYPE_NAME($2.type)); }
| UNSIGNED
- { $$ = lookup_unsigned_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_unsigned_typename (parse_language (ps),
+ parse_gdbarch (ps),
"int"); }
| SIGNED_KEYWORD typename
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
- { $$ = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ { $$ = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"int"); }
/* It appears that this rule for templates is never
reduced; template recognition happens by lookahead
@@ -1161,24 +1167,24 @@ typename: TYPENAME
{
$$.stoken.ptr = "int";
$$.stoken.length = 3;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"int");
}
| LONG
{
$$.stoken.ptr = "long";
$$.stoken.length = 4;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"long");
}
| SHORT
{
$$.stoken.ptr = "short";
$$.stoken.length = 5;
- $$.type = lookup_signed_typename (parse_language,
- parse_gdbarch,
+ $$.type = lookup_signed_typename (parse_language (ps),
+ parse_gdbarch (ps),
"short");
}
;
@@ -1388,7 +1394,8 @@ operator_stoken (const char *op)
/*** Needs some error checking for the float case ***/

static int
-parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
+parse_number (struct parser_state *ps, 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. */
@@ -1423,9 +1430,9 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_decfloat;
+ = parse_type (ps)->builtin_decfloat;
decimal_from_string (putithere->typed_val_decfloat.val, 4,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (ps)), p);
p[len - 2] = 'd';
return DECFLOAT;
}
@@ -1434,9 +1441,9 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_decdouble;
+ = parse_type (ps)->builtin_decdouble;
decimal_from_string (putithere->typed_val_decfloat.val, 8,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (ps)), p);
p[len - 2] = 'd';
return DECFLOAT;
}
@@ -1445,14 +1452,14 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
{
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
- = parse_type->builtin_declong;
+ = parse_type (ps)->builtin_declong;
decimal_from_string (putithere->typed_val_decfloat.val, 16,
- gdbarch_byte_order (parse_gdbarch), p);
+ gdbarch_byte_order (parse_gdbarch (ps)), p);
p[len - 2] = 'd';
return DECFLOAT;
}

- if (! parse_c_float (parse_gdbarch, p, len,
+ if (! parse_c_float (parse_gdbarch (ps), p, len,
&putithere->typed_val_float.dval,
&putithere->typed_val_float.type))
return ERROR;
@@ -1568,9 +1575,9 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)

un = (ULONGEST)n >> 2;
if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_int_bit (parse_gdbarch (ps)) - 2)) == 0)
{
- high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (ps)) - 1);

/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -1578,28 +1585,28 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
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 (ps)->builtin_unsigned_int;
+ signed_type = parse_type (ps)->builtin_int;
}
else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
+ && (un >> (gdbarch_long_bit (parse_gdbarch (ps)) - 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 (ps)) - 1);
+ unsigned_type = parse_type (ps)->builtin_unsigned_long;
+ signed_type = parse_type (ps)->builtin_long;
}
else
{
int shift;
if (sizeof (ULONGEST) * HOST_CHAR_BIT
- < gdbarch_long_long_bit (parse_gdbarch))
+ < gdbarch_long_long_bit (parse_gdbarch (ps)))
/* 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 (ps)) - 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 (ps)->builtin_unsigned_long_long;
+ signed_type = parse_type (ps)->builtin_long_long;
}

putithere->typed_val_int.val = n;
@@ -2066,7 +2073,7 @@ static int last_was_structop;
/* Read one token, getting characters through lexptr. */

static int
-lex_one_token (void)
+lex_one_token (struct parser_state *ps)
{
int c;
int namelen;
@@ -2098,7 +2105,7 @@ lex_one_token (void)
if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
{
if (tokentab3[i].cxx_only
- && parse_language->la_language != language_cplus)
+ && parse_language (ps)->la_language != language_cplus)
break;

lexptr += 3;
@@ -2111,7 +2118,7 @@ lex_one_token (void)
if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
{
if (tokentab2[i].cxx_only
- && parse_language->la_language != language_cplus)
+ && parse_language (ps)->la_language != language_cplus)
break;

lexptr += 2;
@@ -2233,7 +2240,8 @@ lex_one_token (void)
&& (*p < 'A' || *p > 'Z')))
break;
}
- toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
+ toktype = parse_number (ps, tokstart, p - tokstart, got_dot|got_e,
+ &yylval);
if (toktype == ERROR)
{
char *err_copy = (char *) alloca (p - tokstart + 1);
@@ -2385,7 +2393,7 @@ lex_one_token (void)
if (strcmp (copy, ident_tokens[i].operator) == 0)
{
if (ident_tokens[i].cxx_only
- && parse_language->la_language != language_cplus)
+ && parse_language (ps)->la_language != language_cplus)
break;

/* It is ok to always set this, even though we don't always
@@ -2427,7 +2435,7 @@ static struct obstack name_obstack;
in which lookups start; this can be NULL to mean the global
scope. */
static int
-classify_name (struct block *block)
+classify_name (struct parser_state *ps, struct block *block)
{
struct symbol *sym;
char *copy;
@@ -2436,7 +2444,7 @@ classify_name (struct block *block)
copy = copy_name (yylval.sval);

sym = lookup_symbol (copy, block, VAR_DOMAIN,
- parse_language->la_language == language_cplus
+ parse_language (ps)->la_language == language_cplus
? &is_a_field_of_this : (int *) NULL);

if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
@@ -2465,8 +2473,8 @@ classify_name (struct block *block)
}

yylval.tsym.type
- = language_lookup_primitive_type_by_name (parse_language,
- parse_gdbarch, copy);
+ = language_lookup_primitive_type_by_name (parse_language (ps),
+ parse_gdbarch (ps), copy);
if (yylval.tsym.type != NULL)
return TYPENAME;

@@ -2478,7 +2486,7 @@ classify_name (struct block *block)
|| (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 (ps, copy, yylval.sval.length, 0, &newlval);
if (hextype == INT)
{
yylval.ssym.sym = sym;
@@ -2492,7 +2500,7 @@ classify_name (struct block *block)
yylval.ssym.is_a_field_of_this = is_a_field_of_this;

if (sym == NULL
- && parse_language->la_language == language_cplus
+ && parse_language (ps)->la_language == language_cplus
&& !is_a_field_of_this
&& !lookup_minimal_symbol (copy, NULL, NULL))
return UNKNOWN_CPP_NAME;
@@ -2506,13 +2514,14 @@ classify_name (struct block *block)
this function returns NAME, it might not have updated `yylval'.
This is ok because the caller only cares about TYPENAME. */
static int
-classify_inner_name (struct block *block, int first_name)
+classify_inner_name (struct parser_state *ps, struct block *block,
+ int first_name)
{
struct type *type, *new_type;
char *copy;

if (first_name)
- return classify_name (block);
+ return classify_name (ps, block);

type = check_typedef (yylval.tsym.type);
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
@@ -2544,7 +2553,7 @@ classify_inner_name (struct block *block, int first_name)
this is still an improvement over the earlier approach, and will
suffice until we move to better parsing technology. */
static int
-yylex (void)
+yylex (struct parser_state *ps)
{
token_and_value current;
int first_was_coloncolon, last_was_coloncolon, first_iter;
@@ -2558,10 +2567,10 @@ yylex (void)
}
popping = 0;

- current.token = lex_one_token ();
+ current.token = lex_one_token (ps);
if (current.token == NAME)
- current.token = classify_name (expression_context_block);
- if (parse_language->la_language != language_cplus
+ current.token = classify_name (ps, expression_context_block);
+ if (parse_language (ps)->la_language != language_cplus
|| (current.token != TYPENAME && current.token != COLONCOLON))
return current.token;

@@ -2576,14 +2585,14 @@ yylex (void)
{
token_and_value next;

- next.token = lex_one_token ();
+ next.token = lex_one_token (ps);
next.value = yylval;

if (next.token == NAME && last_was_coloncolon)
{
int classification;

- classification = classify_inner_name (first_was_coloncolon
+ classification = classify_inner_name (ps, first_was_coloncolon
? NULL
: expression_context_block,
first_iter);
@@ -2648,7 +2657,7 @@ yylex (void)
}

int
-c_parse (void)
+c_parse (struct parser_state *ps)
{
int result;
struct cleanup *back_to = make_cleanup (free_current_contents,
@@ -2682,14 +2691,14 @@ c_parse (void)
obstack_init (&name_obstack);
make_cleanup_obstack_free (&name_obstack);

- result = yyparse ();
+ result = yyparse (ps);
do_cleanups (back_to);
return result;
}

void
-yyerror (char *msg)
+yyerror (struct parser_state *ps, char *msg)
{
if (prev_lexptr)
lexptr = prev_lexptr;
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index e8c632f..1003b8d 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -24,6 +24,7 @@

struct ui_file;
struct language_arch_info;
+struct parser_state;

#include "value.h"
#include "macroexp.h"
@@ -57,9 +58,9 @@ enum c_string_type

/* Defined in c-exp.y. */

-extern int c_parse (void);
+extern int c_parse (struct parser_state *);

-extern void c_error (char *);
+extern void c_error (struct parser_state *, char *);

extern int c_parse_escape (char **, struct obstack *);