aboutsummaryrefslogtreecommitdiff
path: root/gdb/go-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/go-exp.y
parent8621b685bfdcb8773b8177fb2b89e45499902868 (diff)
downloadgdb-5776fca307b8af3d852525b77e9b917a9aa97370.zip
gdb-5776fca307b8af3d852525b77e9b917a9aa97370.tar.gz
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/go-exp.y')
-rw-r--r--gdb/go-exp.y40
1 files changed, 20 insertions, 20 deletions
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index ea1487c..6754d52 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1020,14 +1020,14 @@ lex_one_token (struct parser_state *par_state)
retry:
- prev_lexptr = lexptr;
+ par_state->prev_lexptr = par_state->lexptr;
- tokstart = lexptr;
+ tokstart = par_state->lexptr;
/* See if it is a special token of length 3. */
for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
{
- lexptr += 3;
+ par_state->lexptr += 3;
yylval.opcode = tokentab3[i].opcode;
return tokentab3[i].token;
}
@@ -1036,7 +1036,7 @@ lex_one_token (struct parser_state *par_state)
for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
{
- lexptr += 2;
+ par_state->lexptr += 2;
yylval.opcode = tokentab2[i].opcode;
/* NOTE: -> doesn't exist in Go, so we don't need to watch for
setting last_was_structop here. */
@@ -1059,13 +1059,13 @@ lex_one_token (struct parser_state *par_state)
case ' ':
case '\t':
case '\n':
- lexptr++;
+ par_state->lexptr++;
goto retry;
case '[':
case '(':
paren_depth++;
- lexptr++;
+ par_state->lexptr++;
return c;
case ']':
@@ -1073,19 +1073,19 @@ lex_one_token (struct parser_state *par_state)
if (paren_depth == 0)
return 0;
paren_depth--;
- lexptr++;
+ par_state->lexptr++;
return c;
case ',':
if (pstate->comma_terminates
&& paren_depth == 0)
return 0;
- lexptr++;
+ par_state->lexptr++;
return c;
case '.':
/* Might be a floating point number. */
- if (lexptr[1] < '0' || lexptr[1] > '9')
+ if (par_state->lexptr[1] < '0' || par_state->lexptr[1] > '9')
{
if (parse_completion)
last_was_structop = 1;
@@ -1148,7 +1148,7 @@ lex_one_token (struct parser_state *par_state)
err_copy[p - tokstart] = 0;
error (_("Invalid number \"%s\"."), err_copy);
}
- lexptr = p;
+ par_state->lexptr = p;
return toktype;
}
@@ -1162,7 +1162,7 @@ lex_one_token (struct parser_state *par_state)
if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
&& p[len] != '_')
{
- lexptr = &p[len];
+ par_state->lexptr = &p[len];
return ENTRY;
}
}
@@ -1185,7 +1185,7 @@ lex_one_token (struct parser_state *par_state)
case '{':
case '}':
symbol:
- lexptr++;
+ par_state->lexptr++;
return c;
case '\'':
@@ -1193,8 +1193,8 @@ lex_one_token (struct parser_state *par_state)
case '`':
{
int host_len;
- int result = parse_string_or_char (tokstart, &lexptr, &yylval.tsval,
- &host_len);
+ int result = parse_string_or_char (tokstart, &par_state->lexptr,
+ &yylval.tsval, &host_len);
if (result == CHAR)
{
if (host_len == 0)
@@ -1202,7 +1202,7 @@ lex_one_token (struct parser_state *par_state)
else if (host_len > 2 && c == '\'')
{
++tokstart;
- namelen = lexptr - tokstart - 1;
+ namelen = par_state->lexptr - tokstart - 1;
goto tryname;
}
else if (host_len > 1)
@@ -1255,7 +1255,7 @@ lex_one_token (struct parser_state *par_state)
return 0;
}
- lexptr += namelen;
+ par_state->lexptr += namelen;
tryname:
@@ -1276,7 +1276,7 @@ lex_one_token (struct parser_state *par_state)
if (*tokstart == '$')
return DOLLAR_VARIABLE;
- if (parse_completion && *lexptr == '\0')
+ if (parse_completion && *par_state->lexptr == '\0')
saw_name_at_eof = 1;
return NAME;
}
@@ -1581,8 +1581,8 @@ go_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);
}