diff options
author | Tom Tromey <tom@tromey.com> | 2019-03-24 21:30:56 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2019-04-04 19:55:11 -0600 |
commit | 5776fca307b8af3d852525b77e9b917a9aa97370 (patch) | |
tree | ac923aa97349376a076996f5f8db12b44e728cb5 /gdb/f-exp.y | |
parent | 8621b685bfdcb8773b8177fb2b89e45499902868 (diff) | |
download | gdb-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/f-exp.y')
-rw-r--r-- | gdb/f-exp.y | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y index 522751d..fce90b4 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -1005,14 +1005,14 @@ growbuf_by_size (int count) static int match_string_literal (void) { - const char *tokptr = lexptr; + const char *tokptr = pstate->lexptr; for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++) { CHECKBUF (1); - if (*tokptr == *lexptr) + if (*tokptr == *pstate->lexptr) { - if (*(tokptr + 1) == *lexptr) + if (*(tokptr + 1) == *pstate->lexptr) tokptr++; else break; @@ -1027,7 +1027,7 @@ match_string_literal (void) tempbuf[tempbufindex] = '\0'; yylval.sval.ptr = tempbuf; yylval.sval.length = tempbufindex; - lexptr = ++tokptr; + pstate->lexptr = ++tokptr; return STRING_LITERAL; } } @@ -1044,21 +1044,21 @@ yylex (void) retry: - prev_lexptr = lexptr; + pstate->prev_lexptr = pstate->lexptr; - tokstart = lexptr; + tokstart = pstate->lexptr; /* First of all, let us make sure we are not dealing with the special tokens .true. and .false. which evaluate to 1 and 0. */ - if (*lexptr == '.') + if (*pstate->lexptr == '.') { for (int i = 0; i < ARRAY_SIZE (boolean_values); i++) { if (strncasecmp (tokstart, boolean_values[i].name, strlen (boolean_values[i].name)) == 0) { - lexptr += strlen (boolean_values[i].name); + pstate->lexptr += strlen (boolean_values[i].name); yylval.lval = boolean_values[i].value; return BOOLEAN_LITERAL; } @@ -1071,7 +1071,7 @@ yylex (void) strlen (dot_ops[i].oper)) == 0) { gdb_assert (!dot_ops[i].case_sensitive); - lexptr += strlen (dot_ops[i].oper); + pstate->lexptr += strlen (dot_ops[i].oper); yylval.opcode = dot_ops[i].opcode; return dot_ops[i].token; } @@ -1080,7 +1080,7 @@ yylex (void) if (strncmp (tokstart, "**", 2) == 0) { - lexptr += 2; + pstate->lexptr += 2; yylval.opcode = BINOP_EXP; return STARSTAR; } @@ -1093,7 +1093,7 @@ yylex (void) case ' ': case '\t': case '\n': - lexptr++; + pstate->lexptr++; goto retry; case '\'': @@ -1104,25 +1104,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. */ /* FALL THRU. */ @@ -1186,7 +1186,7 @@ yylex (void) err_copy[p - tokstart] = 0; error (_("Invalid number \"%s\"."), err_copy); } - lexptr = p; + pstate->lexptr = p; return toktype; } @@ -1211,7 +1211,7 @@ yylex (void) case '{': case '}': symbol: - lexptr++; + pstate->lexptr++; return c; } @@ -1232,7 +1232,7 @@ yylex (void) if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') return 0; - lexptr += namelen; + pstate->lexptr += namelen; /* Catch specific keywords. */ @@ -1339,8 +1339,8 @@ f_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); } |