From: Michael Snyder <msnyder@redhat.com>
To: Michael Snyder <msnyder@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] Change to parse error reporting
Date: Fri, 19 Apr 2002 11:54:00 -0000 [thread overview]
Message-ID: <3CC0650E.35464D1B@redhat.com> (raw)
In-Reply-To: <200204121931.g3CJVae12068@reddwarf.sfbay.redhat.com>
Michael Snyder wrote:
>
> Folks,
>
> I've never liked the way in which "parse error" messages in gdb
> always point to the token _after_ the error, instead of at the
> token _causing_ the error.
>
> This change (implemented for the c/c++ parser only) will make it
> point at the error token instead of the following token.
> Extending the change to the other languages will be trivial,
> if you agree with this.
>
> OK to commit?
Does anybody have any opinion about this?
If not I'll check it in next week.
>
> 2002-04-12 Michael Snyder <msnyder@redhat.com>
>
> * 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.
>
> Index: parse.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/parse.c,v
> retrieving revision 1.22
> diff -p -r1.22 parse.c
> *** parse.c 9 Apr 2002 22:14:39 -0000 1.22
> --- parse.c 12 Apr 2002 19:40:35 -0000
> *************** int arglist_len;
> *** 76,81 ****
> --- 76,82 ----
> 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;
> *************** parse_exp_1 (char **stringptr, struct bl
> *** 1126,1131 ****
> --- 1127,1133 ----
> struct cleanup *old_chain;
>
> lexptr = *stringptr;
> + prev_lexptr = NULL;
>
> paren_depth = 0;
> type_stack_depth = 0;
> Index: parser-defs.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/parser-defs.h,v
> retrieving revision 1.7
> diff -p -r1.7 parser-defs.h
> *** parser-defs.h 9 Apr 2002 22:14:39 -0000 1.7
> --- parser-defs.h 12 Apr 2002 19:40:35 -0000
> *************** extern struct type *follow_types (struct
> *** 150,155 ****
> --- 150,159 ----
>
> 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.
>
> Index: c-exp.y
> ===================================================================
> RCS file: /cvs/src/src/gdb/c-exp.y,v
> retrieving revision 1.7
> diff -p -r1.7 c-exp.y
> *** c-exp.y 15 Nov 2001 01:55:59 -0000 1.7
> --- c-exp.y 12 Apr 2002 19:40:35 -0000
> *************** yylex ()
> *** 1218,1223 ****
> --- 1218,1224 ----
>
> retry:
>
> + prev_lexptr = lexptr;
> unquoted_expr = 1;
>
> tokstart = lexptr;
> *************** void
> *** 1738,1742 ****
> --- 1739,1746 ----
> yyerror (msg)
> char *msg;
> {
> + if (prev_lexptr)
> + lexptr = prev_lexptr;
> +
> error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
> }
next prev parent reply other threads:[~2002-04-19 18:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-04-12 12:43 Michael Snyder
2002-04-13 2:05 ` [RFA] lin-lwp.c change to avoid obscure hanging Paul N. Hilfinger
2002-04-15 18:10 ` Michael Snyder
2002-04-17 2:52 ` Paul N. Hilfinger
2002-04-19 11:53 ` Michael Snyder
2002-04-19 11:54 ` Michael Snyder [this message]
2002-04-24 15:23 ` [RFA] Change to parse error reporting Michael Snyder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CC0650E.35464D1B@redhat.com \
--to=msnyder@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=msnyder@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox