From 665132f945eb6865fb7b86affb68c4019d46c36f Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Wed, 24 Apr 2002 22:26:32 +0000 Subject: [PATCH] 2002-04-24 Michael Snyder * parser-defs.h (prev_lexptr): New external variable. * parse.c (parse_exp_1): Set prev_lexptr to null before calling the language-specific parser. * c-exp.y (yylex): Set prev_lexptr to start of current token. (yyerror): Use prev_lexptr in error reporting. --- gdb/ChangeLog | 8 ++++++++ gdb/c-exp.y | 4 ++++ gdb/parse.c | 2 ++ gdb/parser-defs.h | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 534418e242a..ce31b8e1c7c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2002-04-24 Michael Snyder + + * parser-defs.h (prev_lexptr): New external variable. + * parse.c (parse_exp_1): Set prev_lexptr to null before + calling the language-specific parser. + * c-exp.y (yylex): Set prev_lexptr to start of current token. + (yyerror): Use prev_lexptr in error reporting. + 2002-04-24 Daniel Jacobowitz * config/i386/tm-linux.h: Define FILL_FPXREGSET. diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 0ccac03f431..a15a4456bce 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1246,6 +1246,7 @@ yylex () retry: + prev_lexptr = lexptr; unquoted_expr = 1; tokstart = lexptr; @@ -1766,5 +1767,8 @@ void yyerror (msg) char *msg; { + if (prev_lexptr) + lexptr = prev_lexptr; + error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr); } diff --git a/gdb/parse.c b/gdb/parse.c index 1a1003bc4ad..9c1f3e16d0b 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -76,6 +76,7 @@ int arglist_len; union type_stack_elt *type_stack; int type_stack_depth, type_stack_size; char *lexptr; +char *prev_lexptr; char *namecopy; int paren_depth; int comma_terminates; @@ -1126,6 +1127,7 @@ parse_exp_1 (char **stringptr, struct block *block, int comma) struct cleanup *old_chain; lexptr = *stringptr; + prev_lexptr = NULL; paren_depth = 0; type_stack_depth = 0; diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h index 5b2e47b66e1..ece28493752 100644 --- a/gdb/parser-defs.h +++ b/gdb/parser-defs.h @@ -150,6 +150,10 @@ extern struct type *follow_types (struct type *); extern char *lexptr; +/* After a token has been recognized, this variable points to it. + Currently used only for error reporting. */ +extern char *prev_lexptr; + /* Tokens that refer to names do so with explicit pointer and length, so they can share the storage that lexptr is parsing. -- 2.30.2