gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / p-exp.y
index 95a6924adfc6ca658b339e2395b932862d3f98a7..6403e410571656d971faea7f3a6ce1bc17467995 100644 (file)
@@ -1,5 +1,5 @@
 /* YACC parser for Pascal expressions, for GDB.
-   Copyright (C) 2000-2018 Free Software Foundation, Inc.
+   Copyright (C) 2000-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -56,7 +56,7 @@
 #include "block.h"
 #include "completer.h"
 
-#define parse_type(ps) builtin_type (parse_gdbarch (ps))
+#define parse_type(ps) builtin_type (ps->gdbarch ())
 
 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
    etc).  */
 
 static struct parser_state *pstate = NULL;
 
+/* Depth of parentheses.  */
+static int paren_depth;
+
 int yyparse (void);
 
 static int yylex (void);
 
-void yyerror (const char *);
+static void yyerror (const char *);
 
 static char *uptok (const char *, int);
 %}
@@ -158,7 +161,7 @@ static int search_field;
 /* Special type cases, put in to allow the parser to distinguish different
    legal basetypes.  */
 
-%token <voidval> VARIABLE
+%token <voidval> DOLLAR_VARIABLE
 
 
 /* Object pascal */
@@ -254,7 +257,7 @@ exp :       field_exp FIELDNAME
                          search_field = 0;
                          if (current_type)
                            {
-                             while (TYPE_CODE (current_type)
+                             while (current_type->code ()
                                     == TYPE_CODE_PTR)
                                current_type =
                                  TYPE_TARGET_TYPE (current_type);
@@ -272,7 +275,7 @@ exp :       field_exp name
                          search_field = 0;
                          if (current_type)
                            {
-                             while (TYPE_CODE (current_type)
+                             while (current_type->code ()
                                     == TYPE_CODE_PTR)
                                current_type =
                                  TYPE_TARGET_TYPE (current_type);
@@ -282,14 +285,14 @@ exp       :       field_exp name
                        }
        ;
 exp    :       field_exp  name COMPLETE
-                       { mark_struct_expression (pstate);
+                       { pstate->mark_struct_expression ();
                          write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
                          write_exp_string (pstate, $2);
                          write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
        ;
 exp    :       field_exp COMPLETE
                        { struct stoken s;
-                         mark_struct_expression (pstate);
+                         pstate->mark_struct_expression ();
                          write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
                          s.ptr = "";
                          s.length = 0;
@@ -331,11 +334,11 @@ exp       :       exp '('
                        /* This is to save the value of arglist_len
                           being accumulated by an outer function call.  */
                        { push_current_type ();
-                         start_arglist (); }
+                         pstate->start_arglist (); }
                arglist ')'     %prec ARROW
                        { write_exp_elt_opcode (pstate, OP_FUNCALL);
                          write_exp_elt_longcst (pstate,
-                                                (LONGEST) end_arglist ());
+                                                pstate->end_arglist ());
                          write_exp_elt_opcode (pstate, OP_FUNCALL);
                          pop_current_type ();
                          if (current_type)
@@ -345,18 +348,18 @@ exp       :       exp '('
 
 arglist        :
          | exp
-                       { arglist_len = 1; }
+                       { pstate->arglist_len = 1; }
         | arglist ',' exp   %prec ABOVE_COMMA
-                       { arglist_len++; }
+                       { pstate->arglist_len++; }
        ;
 
 exp    :       type '(' exp ')' %prec UNARY
                        { if (current_type)
                            {
                              /* Allow automatic dereference of classes.  */
-                             if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
-                                 && (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_STRUCT)
-                                 && (TYPE_CODE ($1) == TYPE_CODE_STRUCT))
+                             if ((current_type->code () == TYPE_CODE_PTR)
+                                 && (TYPE_TARGET_TYPE (current_type)->code () == TYPE_CODE_STRUCT)
+                                 && (($1)->code () == TYPE_CODE_STRUCT))
                                write_exp_elt_opcode (pstate, UNOP_IND);
                            }
                          write_exp_elt_opcode (pstate, UNOP_CAST);
@@ -521,14 +524,14 @@ exp       :       FLOAT
 exp    :       variable
        ;
 
-exp    :       VARIABLE
+exp    :       DOLLAR_VARIABLE
                        /* Already written by write_dollar_variable.
                           Handle current_type.  */
                        {  if (intvar) {
                             struct value * val, * mark;
 
                             mark = value_mark ();
-                            val = value_of_internalvar (parse_gdbarch (pstate),
+                            val = value_of_internalvar (pstate->gdbarch (),
                                                         intvar);
                             current_type = value_type (val);
                             value_release_to_mark (mark);
@@ -591,14 +594,14 @@ exp       :       THIS
                          write_exp_elt_opcode (pstate, OP_THIS);
                          /* We need type of this.  */
                          this_val
-                           = value_of_this_silent (parse_language (pstate));
+                           = value_of_this_silent (pstate->language ());
                          if (this_val)
                            this_type = value_type (this_val);
                          else
                            this_type = NULL;
                          if (this_type)
                            {
-                             if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
+                             if (this_type->code () == TYPE_CODE_PTR)
                                {
                                  this_type = TYPE_TARGET_TYPE (this_type);
                                  write_exp_elt_opcode (pstate, UNOP_IND);
@@ -617,37 +620,41 @@ block     :       BLOCKNAME
                              $$ = SYMBOL_BLOCK_VALUE ($1.sym.symbol);
                          else
                            {
+                             std::string copy = copy_name ($1.stoken);
                              struct symtab *tem =
-                                 lookup_symtab (copy_name ($1.stoken));
+                                 lookup_symtab (copy.c_str ());
                              if (tem)
                                $$ = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (tem),
                                                        STATIC_BLOCK);
                              else
                                error (_("No file or function \"%s\"."),
-                                      copy_name ($1.stoken));
+                                      copy.c_str ());
                            }
                        }
        ;
 
 block  :       block COLONCOLON name
-                       { struct symbol *tem
-                           = lookup_symbol (copy_name ($3), $1,
+                       {
+                         std::string copy = copy_name ($3);
+                         struct symbol *tem
+                           = lookup_symbol (copy.c_str (), $1,
                                             VAR_DOMAIN, NULL).symbol;
 
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
                            error (_("No function \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
                          $$ = SYMBOL_BLOCK_VALUE (tem); }
        ;
 
 variable:      block COLONCOLON name
                        { struct block_symbol sym;
 
-                         sym = lookup_symbol (copy_name ($3), $1,
+                         std::string copy = copy_name ($3);
+                         sym = lookup_symbol (copy.c_str (), $1,
                                               VAR_DOMAIN, NULL);
                          if (sym.symbol == 0)
                            error (_("No symbol \"%s\" in specified context."),
-                                  copy_name ($3));
+                                  copy.c_str ());
 
                          write_exp_elt_opcode (pstate, OP_VAR_VALUE);
                          write_exp_elt_block (pstate, sym.block);
@@ -659,10 +666,10 @@ qualified_name:   typebase COLONCOLON name
                        {
                          struct type *type = $1;
 
-                         if (TYPE_CODE (type) != TYPE_CODE_STRUCT
-                             && TYPE_CODE (type) != TYPE_CODE_UNION)
+                         if (type->code () != TYPE_CODE_STRUCT
+                             && type->code () != TYPE_CODE_UNION)
                            error (_("`%s' is not defined as an aggregate type."),
-                                  TYPE_NAME (type));
+                                  type->name ());
 
                          write_exp_elt_opcode (pstate, OP_SCOPE);
                          write_exp_elt_type (pstate, type);
@@ -674,12 +681,13 @@ qualified_name:   typebase COLONCOLON name
 variable:      qualified_name
        |       COLONCOLON name
                        {
-                         char *name = copy_name ($2);
+                         std::string name = copy_name ($2);
                          struct symbol *sym;
                          struct bound_minimal_symbol msymbol;
 
                          sym =
-                           lookup_symbol (name, (const struct block *) NULL,
+                           lookup_symbol (name.c_str (),
+                                          (const struct block *) NULL,
                                           VAR_DOMAIN, NULL).symbol;
                          if (sym)
                            {
@@ -690,7 +698,8 @@ variable:   qualified_name
                              break;
                            }
 
-                         msymbol = lookup_bound_minimal_symbol (name);
+                         msymbol
+                           = lookup_bound_minimal_symbol (name.c_str ());
                          if (msymbol.minsym != NULL)
                            write_exp_msymbol (pstate, msymbol);
                          else if (!have_full_symbols ()
@@ -699,7 +708,7 @@ variable:   qualified_name
                                   "Use the \"file\" command."));
                          else
                            error (_("No symbol \"%s\" in current context."),
-                                  name);
+                                  name.c_str ());
                        }
        ;
 
@@ -709,12 +718,7 @@ variable:  name_not_typename
                          if (sym.symbol)
                            {
                              if (symbol_read_needs_frame (sym.symbol))
-                               {
-                                 if (innermost_block == 0
-                                     || contained_in (sym.block,
-                                                      innermost_block))
-                                   innermost_block = sym.block;
-                               }
+                               pstate->block_tracker->update (sym);
 
                              write_exp_elt_opcode (pstate, OP_VAR_VALUE);
                              write_exp_elt_block (pstate, sym.block);
@@ -728,10 +732,7 @@ variable:  name_not_typename
                              /* Object pascal: it hangs off of `this'.  Must
                                 not inadvertently convert from a method call
                                 to data ref.  */
-                             if (innermost_block == 0
-                                 || contained_in (sym.block,
-                                                  innermost_block))
-                               innermost_block = sym.block;
+                             pstate->block_tracker->update (sym);
                              write_exp_elt_opcode (pstate, OP_THIS);
                              write_exp_elt_opcode (pstate, OP_THIS);
                              write_exp_elt_opcode (pstate, STRUCTOP_PTR);
@@ -739,7 +740,7 @@ variable:   name_not_typename
                              write_exp_elt_opcode (pstate, STRUCTOP_PTR);
                              /* We need type of this.  */
                              this_val
-                               = value_of_this_silent (parse_language (pstate));
+                               = value_of_this_silent (pstate->language ());
                              if (this_val)
                                this_type = value_type (this_val);
                              else
@@ -747,17 +748,17 @@ variable: name_not_typename
                              if (this_type)
                                current_type = lookup_struct_elt_type (
                                  this_type,
-                                 copy_name ($1.stoken), 0);
+                                 copy_name ($1.stoken).c_str (), 0);
                              else
                                current_type = NULL;
                            }
                          else
                            {
                              struct bound_minimal_symbol msymbol;
-                             char *arg = copy_name ($1.stoken);
+                             std::string arg = copy_name ($1.stoken);
 
                              msymbol =
-                               lookup_bound_minimal_symbol (arg);
+                               lookup_bound_minimal_symbol (arg.c_str ());
                              if (msymbol.minsym != NULL)
                                write_exp_msymbol (pstate, msymbol);
                              else if (!have_full_symbols ()
@@ -766,7 +767,7 @@ variable:   name_not_typename
                                       "Use the \"file\" command."));
                              else
                                error (_("No symbol \"%s\" in current context."),
-                                      copy_name ($1.stoken));
+                                      arg.c_str ());
                            }
                        }
        ;
@@ -792,11 +793,15 @@ typebase  /* Implements (approximately): (type-qualifier)* type-specifier */
        |       TYPENAME
                        { $$ = $1.type; }
        |       STRUCT name
-                       { $$ = lookup_struct (copy_name ($2),
-                                             expression_context_block); }
+                       { $$
+                           = lookup_struct (copy_name ($2).c_str (),
+                                            pstate->expression_context_block);
+                       }
        |       CLASS name
-                       { $$ = lookup_struct (copy_name ($2),
-                                             expression_context_block); }
+                       { $$
+                           = lookup_struct (copy_name ($2).c_str (),
+                                            pstate->expression_context_block);
+                       }
        /* "const" and "volatile" are curently ignored.  A type qualifier
           after the type is handled in the ptype rule.  I think these could
           be too.  */
@@ -981,10 +986,10 @@ parse_number (struct parser_state *par_state,
 
   un = (ULONGEST)n >> 2;
   if (long_p == 0
-      && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
+      && (un >> (gdbarch_int_bit (par_state->gdbarch ()) - 2)) == 0)
     {
       high_bit
-       = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
+       = ((ULONGEST)1) << (gdbarch_int_bit (par_state->gdbarch ()) - 1);
 
       /* A large decimal (not hex or octal) constant (between INT_MAX
         and UINT_MAX) is a long or unsigned long, according to ANSI,
@@ -996,10 +1001,10 @@ parse_number (struct parser_state *par_state,
       signed_type = parse_type (par_state)->builtin_int;
     }
   else if (long_p <= 1
-          && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
+          && (un >> (gdbarch_long_bit (par_state->gdbarch ()) - 2)) == 0)
     {
       high_bit
-       = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
+       = ((ULONGEST)1) << (gdbarch_long_bit (par_state->gdbarch ()) - 1);
       unsigned_type = parse_type (par_state)->builtin_unsigned_long;
       signed_type = parse_type (par_state)->builtin_long;
     }
@@ -1007,11 +1012,11 @@ parse_number (struct parser_state *par_state,
     {
       int shift;
       if (sizeof (ULONGEST) * HOST_CHAR_BIT
-         < gdbarch_long_long_bit (parse_gdbarch (par_state)))
+         < gdbarch_long_long_bit (par_state->gdbarch ()))
        /* A long long does not fit in a LONGEST.  */
        shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
       else
-       shift = (gdbarch_long_long_bit (parse_gdbarch (par_state)) - 1);
+       shift = (gdbarch_long_long_bit (par_state->gdbarch ()) - 1);
       high_bit = (ULONGEST) 1 << shift;
       unsigned_type = parse_type (par_state)->builtin_unsigned_long_long;
       signed_type = parse_type (par_state)->builtin_long_long;
@@ -1120,7 +1125,6 @@ yylex (void)
 {
   int c;
   int namelen;
-  unsigned int i;
   const char *tokstart;
   char *uptokstart;
   const char *tokptr;
@@ -1130,33 +1134,33 @@ yylex (void)
 
  retry:
 
-  prev_lexptr = lexptr;
+  pstate->prev_lexptr = pstate->lexptr;
 
-  tokstart = lexptr;
-  explen = strlen (lexptr);
+  tokstart = pstate->lexptr;
+  explen = strlen (pstate->lexptr);
 
   /* See if it is a special token of length 3.  */
   if (explen > 2)
-    for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
+    for (int i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
       if (strncasecmp (tokstart, tokentab3[i].oper, 3) == 0
           && (!isalpha (tokentab3[i].oper[0]) || explen == 3
               || (!isalpha (tokstart[3])
                  && !isdigit (tokstart[3]) && tokstart[3] != '_')))
         {
-          lexptr += 3;
+          pstate->lexptr += 3;
           yylval.opcode = tokentab3[i].opcode;
           return tokentab3[i].token;
         }
 
   /* See if it is a special token of length 2.  */
   if (explen > 1)
-  for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
+  for (int i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
       if (strncasecmp (tokstart, tokentab2[i].oper, 2) == 0
           && (!isalpha (tokentab2[i].oper[0]) || explen == 2
               || (!isalpha (tokstart[2])
                  && !isdigit (tokstart[2]) && tokstart[2] != '_')))
         {
-          lexptr += 2;
+          pstate->lexptr += 2;
           yylval.opcode = tokentab2[i].opcode;
           return tokentab2[i].token;
         }
@@ -1164,7 +1168,7 @@ yylex (void)
   switch (c = *tokstart)
     {
     case 0:
-      if (search_field && parse_completion)
+      if (search_field && pstate->parse_completion)
        return COMPLETE;
       else
        return 0;
@@ -1172,31 +1176,31 @@ yylex (void)
     case ' ':
     case '\t':
     case '\n':
-      lexptr++;
+      pstate->lexptr++;
       goto retry;
 
     case '\'':
       /* We either have a character constant ('0' or '\177' for example)
         or we have a quoted symbol reference ('foo(int,int)' in object pascal
         for example).  */
-      lexptr++;
-      c = *lexptr++;
+      pstate->lexptr++;
+      c = *pstate->lexptr++;
       if (c == '\\')
-       c = parse_escape (parse_gdbarch (pstate), &lexptr);
+       c = parse_escape (pstate->gdbarch (), &pstate->lexptr);
       else if (c == '\'')
        error (_("Empty character constant."));
 
       yylval.typed_val_int.val = c;
       yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
 
-      c = *lexptr++;
+      c = *pstate->lexptr++;
       if (c != '\'')
        {
          namelen = skip_quoted (tokstart) - tokstart;
          if (namelen > 2)
            {
-             lexptr = tokstart + namelen;
-             if (lexptr[-1] != '\'')
+             pstate->lexptr = tokstart + namelen;
+             if (pstate->lexptr[-1] != '\'')
                error (_("Unmatched single quote."));
              namelen -= 2;
               tokstart++;
@@ -1209,30 +1213,30 @@ yylex (void)
 
     case '(':
       paren_depth++;
-      lexptr++;
+      pstate->lexptr++;
       return c;
 
     case ')':
       if (paren_depth == 0)
        return 0;
       paren_depth--;
-      lexptr++;
+      pstate->lexptr++;
       return c;
 
     case ',':
-      if (comma_terminates && paren_depth == 0)
+      if (pstate->comma_terminates && paren_depth == 0)
        return 0;
-      lexptr++;
+      pstate->lexptr++;
       return c;
 
     case '.':
       /* Might be a floating point number.  */
-      if (lexptr[1] < '0' || lexptr[1] > '9')
+      if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9')
        {
          goto symbol;          /* Nope, must be a symbol.  */
        }
 
-      /* FALL THRU into number case.  */
+      /* FALL THRU.  */
 
     case '0':
     case '1':
@@ -1295,7 +1299,7 @@ yylex (void)
            err_copy[p - tokstart] = 0;
            error (_("Invalid number \"%s\"."), err_copy);
          }
-       lexptr = p;
+       pstate->lexptr = p;
        return toktype;
       }
 
@@ -1319,7 +1323,7 @@ yylex (void)
     case '{':
     case '}':
     symbol:
-      lexptr++;
+      pstate->lexptr++;
       return c;
 
     case '"':
@@ -1352,7 +1356,7 @@ yylex (void)
            break;
          case '\\':
            ++tokptr;
-           c = parse_escape (parse_gdbarch (pstate), &tokptr);
+           c = parse_escape (pstate->gdbarch (), &tokptr);
            if (c == -1)
              {
                continue;
@@ -1371,7 +1375,7 @@ yylex (void)
       tempbuf[tempbufindex] = '\0';    /* See note above.  */
       yylval.sval.ptr = tempbuf;
       yylval.sval.length = tempbufindex;
-      lexptr = tokptr;
+      pstate->lexptr = tokptr;
       return (STRING);
     }
 
@@ -1422,7 +1426,7 @@ yylex (void)
       return 0;
     }
 
-  lexptr += namelen;
+  pstate->lexptr += namelen;
 
   tryname:
 
@@ -1472,7 +1476,7 @@ yylex (void)
              inserted in FPC stabs debug info.  */
          static const char this_name[] = "this";
 
-         if (lookup_symbol (this_name, expression_context_block,
+         if (lookup_symbol (this_name, pstate->expression_context_block,
                             VAR_DOMAIN, NULL).symbol)
            {
              free (uptokstart);
@@ -1501,7 +1505,7 @@ yylex (void)
       tmp[namelen] = '\0';
       intvar = lookup_only_internalvar (tmp + 1);
       free (uptokstart);
-      return VARIABLE;
+      return DOLLAR_VARIABLE;
     }
 
   /* Use token-type BLOCKNAME for symbols that happen to be defined as
@@ -1510,7 +1514,7 @@ yylex (void)
      currently as names of types; NAME for other symbols.
      The caller is not constrained to care about the distinction.  */
   {
-    char *tmp = copy_name (yylval.sval);
+    std::string tmp = copy_name (yylval.sval);
     struct symbol *sym;
     struct field_of_this_result is_a_field_of_this;
     int is_a_field = 0;
@@ -1518,32 +1522,34 @@ yylex (void)
 
     is_a_field_of_this.type = NULL;
     if (search_field && current_type)
-      is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+      is_a_field = (lookup_struct_elt_type (current_type,
+                                           tmp.c_str (), 1) != NULL);
     if (is_a_field)
       sym = NULL;
     else
-      sym = lookup_symbol (tmpexpression_context_block,
+      sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                           VAR_DOMAIN, &is_a_field_of_this).symbol;
     /* second chance uppercased (as Free Pascal does).  */
     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
       {
-       for (i = 0; i <= namelen; i++)
+       for (int i = 0; i <= namelen; i++)
          {
            if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
              tmp[i] -= ('a'-'A');
          }
        if (search_field && current_type)
-        is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+        is_a_field = (lookup_struct_elt_type (current_type,
+                                              tmp.c_str (), 1) != NULL);
        if (is_a_field)
         sym = NULL;
        else
-        sym = lookup_symbol (tmpexpression_context_block,
+        sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                              VAR_DOMAIN, &is_a_field_of_this).symbol;
       }
     /* Third chance Capitalized (as GPC does).  */
     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
       {
-       for (i = 0; i <= namelen; i++)
+       for (int i = 0; i <= namelen; i++)
          {
            if (i == 0)
              {
@@ -1555,18 +1561,19 @@ yylex (void)
              tmp[i] -= ('A'-'a');
           }
        if (search_field && current_type)
-        is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
+        is_a_field = (lookup_struct_elt_type (current_type,
+                                              tmp.c_str (), 1) != NULL);
        if (is_a_field)
         sym = NULL;
        else
-        sym = lookup_symbol (tmpexpression_context_block,
+        sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
                              VAR_DOMAIN, &is_a_field_of_this).symbol;
       }
 
     if (is_a_field || (is_a_field_of_this.type != NULL))
       {
        tempbuf = (char *) realloc (tempbuf, namelen + 1);
-       strncpy (tempbuf, tmp, namelen);
+       strncpy (tempbuf, tmp.c_str (), namelen);
        tempbuf [namelen] = 0;
        yylval.sval.ptr = tempbuf;
        yylval.sval.length = namelen;
@@ -1583,7 +1590,7 @@ yylex (void)
        no psymtabs (coff, xcoff, or some future change to blow away the
        psymtabs once once symbols are read).  */
     if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
-        || lookup_symtab (tmp))
+        || lookup_symtab (tmp.c_str ()))
       {
        yylval.ssym.sym.symbol = sym;
        yylval.ssym.sym.block = NULL;
@@ -1618,7 +1625,7 @@ yylex (void)
             us whether a type is nested), we just ignore the
             containing type.  */
 
-         p = lexptr;
+         p = pstate->lexptr;
          best_sym = sym;
          while (1)
            {
@@ -1643,25 +1650,27 @@ yylex (void)
                      /* As big as the whole rest of the expression, which is
                         at least big enough.  */
                      char *ncopy
-                       = (char *) alloca (strlen (tmp) + strlen (namestart)
+                       = (char *) alloca (tmp.size () + strlen (namestart)
                                           + 3);
                      char *tmp1;
 
                      tmp1 = ncopy;
-                     memcpy (tmp1, tmp, strlen (tmp));
-                     tmp1 += strlen (tmp);
+                     memcpy (tmp1, tmp.c_str (), tmp.size ());
+                     tmp1 += tmp.size ();
                      memcpy (tmp1, "::", 2);
                      tmp1 += 2;
                      memcpy (tmp1, namestart, p - namestart);
                      tmp1[p - namestart] = '\0';
-                     cur_sym = lookup_symbol (ncopy, expression_context_block,
-                                              VAR_DOMAIN, NULL).symbol;
+                     cur_sym
+                       = lookup_symbol (ncopy,
+                                        pstate->expression_context_block,
+                                        VAR_DOMAIN, NULL).symbol;
                      if (cur_sym)
                        {
                          if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
                            {
                              best_sym = cur_sym;
-                             lexptr = p;
+                             pstate->lexptr = p;
                            }
                          else
                            break;
@@ -1684,8 +1693,8 @@ yylex (void)
          return TYPENAME;
         }
     yylval.tsym.type
-      = language_lookup_primitive_type (parse_language (pstate),
-                                       parse_gdbarch (pstate), tmp);
+      = language_lookup_primitive_type (pstate->language (),
+                                       pstate->gdbarch (), tmp.c_str ());
     if (yylval.tsym.type != NULL)
       {
        free (uptokstart);
@@ -1726,15 +1735,16 @@ pascal_parse (struct parser_state *par_state)
   scoped_restore pstate_restore = make_scoped_restore (&pstate);
   gdb_assert (par_state != NULL);
   pstate = par_state;
+  paren_depth = 0;
 
   return yyparse ();
 }
 
-void
+static void
 yyerror (const char *msg)
 {
-  if (prev_lexptr)
-    lexptr = prev_lexptr;
+  if (pstate->prev_lexptr)
+    pstate->lexptr = pstate->prev_lexptr;
 
-  error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr);
+  error (_("A %s in expression, near `%s'."), msg, pstate->lexptr);
 }
This page took 0.038391 seconds and 4 git commands to generate.