summaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y43
1 files changed, 21 insertions, 22 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index a9ccbdcb65e..0326ee090e1 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2854,17 +2854,15 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
}
/* An object of this type is pushed on a FIFO by the "outer" lexer. */
-typedef struct
+struct token_and_value
{
int token;
YYSTYPE value;
-} token_and_value;
-
-DEF_VEC_O (token_and_value);
+};
/* A FIFO of tokens that have been read but not yet returned to the
parser. */
-static VEC (token_and_value) *token_fifo;
+static std::vector<token_and_value> token_fifo;
/* Non-zero if the lexer should return tokens from the FIFO. */
static int popping;
@@ -3089,7 +3087,7 @@ yylex (void)
const struct block *search_block;
bool is_quoted_name, last_lex_was_structop;
- if (popping && !VEC_empty (token_and_value, token_fifo))
+ if (popping && !token_fifo.empty ())
goto do_pop;
popping = 0;
@@ -3110,7 +3108,7 @@ yylex (void)
/* Read any sequence of alternating "::" and name-like tokens into
the token FIFO. */
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, &current);
+ token_fifo.push_back (current);
last_was_coloncolon = current.token == COLONCOLON;
while (1)
{
@@ -3120,7 +3118,7 @@ yylex (void)
Subsequent ones do not have any special meaning. */
current.token = lex_one_token (pstate, &ignore);
current.value = yylval;
- VEC_safe_push (token_and_value, token_fifo, &current);
+ token_fifo.push_back (current);
if ((last_was_coloncolon && current.token != NAME)
|| (!last_was_coloncolon && current.token != COLONCOLON))
@@ -3131,10 +3129,10 @@ yylex (void)
/* We always read one extra token, so compute the number of tokens
to examine accordingly. */
- last_to_examine = VEC_length (token_and_value, token_fifo) - 2;
+ last_to_examine = token_fifo.size () - 2;
next_to_examine = 0;
- current = *VEC_index (token_and_value, token_fifo, next_to_examine);
+ current = token_fifo[next_to_examine];
++next_to_examine;
name_obstack.clear ();
@@ -3158,16 +3156,16 @@ yylex (void)
while (next_to_examine <= last_to_examine)
{
- token_and_value *next;
+ token_and_value next;
- next = VEC_index (token_and_value, token_fifo, next_to_examine);
+ next = token_fifo[next_to_examine];
++next_to_examine;
- if (next->token == NAME && last_was_coloncolon)
+ if (next.token == NAME && last_was_coloncolon)
{
int classification;
- yylval = next->value;
+ yylval = next.value;
classification = classify_inner_name (pstate, search_block,
context_type);
/* We keep going until we either run out of names, or until
@@ -3184,8 +3182,8 @@ yylex (void)
/* We don't want to put a leading "::" into the name. */
obstack_grow_str (&name_obstack, "::");
}
- obstack_grow (&name_obstack, next->value.sval.ptr,
- next->value.sval.length);
+ obstack_grow (&name_obstack, next.value.sval.ptr,
+ next.value.sval.length);
yylval.sval.ptr = (const char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
@@ -3199,7 +3197,7 @@ yylex (void)
context_type = yylval.tsym.type;
}
- else if (next->token == COLONCOLON && !last_was_coloncolon)
+ else if (next.token == COLONCOLON && !last_was_coloncolon)
last_was_coloncolon = 1;
else
{
@@ -3217,14 +3215,15 @@ yylex (void)
current.value.sval.ptr,
current.value.sval.length);
- VEC_replace (token_and_value, token_fifo, 0, &current);
+ token_fifo[0] = current;
if (checkpoint > 1)
- VEC_block_remove (token_and_value, token_fifo, 1, checkpoint - 1);
+ token_fifo.erase (token_fifo.begin () + 1,
+ token_fifo.begin () + checkpoint);
}
do_pop:
- current = *VEC_index (token_and_value, token_fifo, 0);
- VEC_ordered_remove (token_and_value, token_fifo, 0);
+ current = token_fifo[0];
+ token_fifo.erase (token_fifo.begin ());
yylval = current.value;
return current.token;
}
@@ -3266,7 +3265,7 @@ c_parse (struct parser_state *par_state)
last_was_structop = false;
saw_name_at_eof = 0;
- VEC_free (token_and_value, token_fifo);
+ token_fifo.clear ();
popping = 0;
name_obstack.clear ();