aboutsummaryrefslogtreecommitdiff
path: root/gdb/p-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-24 21:30:56 -0600
committerTom Tromey <tom@tromey.com>2019-04-04 19:55:11 -0600
commit5776fca307b8af3d852525b77e9b917a9aa97370 (patch)
treeac923aa97349376a076996f5f8db12b44e728cb5 /gdb/p-exp.y
parent8621b685bfdcb8773b8177fb2b89e45499902868 (diff)
downloadfsf-binutils-gdb-5776fca307b8af3d852525b77e9b917a9aa97370.zip
fsf-binutils-gdb-5776fca307b8af3d852525b77e9b917a9aa97370.tar.gz
fsf-binutils-gdb-5776fca307b8af3d852525b77e9b917a9aa97370.tar.bz2
Move lexptr and prev_lexptr to parser_state
This removes the lexptr and prev_lexptr globals, in favor of members of parser_state. prev_lexptr could be isolated to each parser, but since every parser uses it, that did not seem necessary. gdb/ChangeLog 2019-04-04 Tom Tromey <tom@tromey.com> * rust-exp.y (struct rust_parser) <lex_hex, lex_escape, lex_operator, push_back>: New methods. Update all rules. (rust_parser::lex_hex, lex_escape): Rename and update. (rust_parser::lex_string, rust_parser::lex_identifier): Update. (rust_parser::lex_operator): Rename and update. (rust_parser::lex_number, rustyylex, rustyyerror) (rust_lex_test_init, rust_lex_test_sequence) (rust_lex_test_push_back, rust_lex_tests): Update. * parser-defs.h (struct parser_state) <parser_state>: Add "input" parameter. <lexptr, prev_lexptr>: New members. (lexptr, prev_lexptr): Don't declare. * parse.c (lexptr, prev_lexptr): Remove globals. (parse_exp_in_context): Update. * p-exp.y (yylex, yyerror): Update. * m2-exp.y (parse_number, yylex, yyerror): Update. * go-exp.y (lex_one_token, yyerror): Update. * f-exp.y (match_string_literal, yylex, yyerror): Update. * d-exp.y (lex_one_token, yyerror): Update. * c-exp.y (scan_macro_expansion, finished_macro_expansion) (lex_one_token, yyerror): Update. * ada-lex.l (YY_INPUT): Update. (rewind_to_char): Update. * ada-exp.y (yyerror): Update.
Diffstat (limited to 'gdb/p-exp.y')
-rw-r--r--gdb/p-exp.y50
1 files changed, 25 insertions, 25 deletions
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 65874c6..4487899 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -1128,10 +1128,10 @@ 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)
@@ -1141,7 +1141,7 @@ yylex (void)
|| (!isalpha (tokstart[3])
&& !isdigit (tokstart[3]) && tokstart[3] != '_')))
{
- lexptr += 3;
+ pstate->lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
return tokentab3[i].token;
}
@@ -1154,7 +1154,7 @@ yylex (void)
|| (!isalpha (tokstart[2])
&& !isdigit (tokstart[2]) && tokstart[2] != '_')))
{
- lexptr += 2;
+ pstate->lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
return tokentab2[i].token;
}
@@ -1170,31 +1170,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 (pstate->gdbarch (), &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++;
@@ -1207,25 +1207,25 @@ 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 (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. */
}
@@ -1293,7 +1293,7 @@ yylex (void)
err_copy[p - tokstart] = 0;
error (_("Invalid number \"%s\"."), err_copy);
}
- lexptr = p;
+ pstate->lexptr = p;
return toktype;
}
@@ -1317,7 +1317,7 @@ yylex (void)
case '{':
case '}':
symbol:
- lexptr++;
+ pstate->lexptr++;
return c;
case '"':
@@ -1369,7 +1369,7 @@ yylex (void)
tempbuf[tempbufindex] = '\0'; /* See note above. */
yylval.sval.ptr = tempbuf;
yylval.sval.length = tempbufindex;
- lexptr = tokptr;
+ pstate->lexptr = tokptr;
return (STRING);
}
@@ -1420,7 +1420,7 @@ yylex (void)
return 0;
}
- lexptr += namelen;
+ pstate->lexptr += namelen;
tryname:
@@ -1616,7 +1616,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)
{
@@ -1661,7 +1661,7 @@ yylex (void)
if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
{
best_sym = cur_sym;
- lexptr = p;
+ pstate->lexptr = p;
}
else
break;
@@ -1734,8 +1734,8 @@ pascal_parse (struct parser_state *par_state)
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, lexptr);
+ error (_("A %s in expression, near `%s'."), msg, pstate->lexptr);
}