public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* syntax errors
@ 2022-05-10 22:18 André Coelho
  2022-05-10 22:23 ` Andrew Pinski
  2022-05-10 22:32 ` Mohamed Atef
  0 siblings, 2 replies; 5+ messages in thread
From: André Coelho @ 2022-05-10 22:18 UTC (permalink / raw)
  To: gcc

Hey...if the compiler can check syntax errors...why can't it fixed them?


thanks


andre coelho


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax errors
  2022-05-10 22:18 syntax errors André Coelho
@ 2022-05-10 22:23 ` Andrew Pinski
  2022-05-10 22:32 ` Mohamed Atef
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Pinski @ 2022-05-10 22:23 UTC (permalink / raw)
  To: André Coelho; +Cc: GCC Mailing List

On Tue, May 10, 2022 at 3:19 PM André Coelho via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hey...if the compiler can check syntax errors...why can't it fixed them?

In some cases it does recommend ways of fixing it. But not all syntax
errors are fixable.
Also not all syntax errors might be the wrong behavior vs what the user wanted.

Thanks,
Andrew Pinski



>
>
> thanks
>
>
> andre coelho
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax errors
  2022-05-10 22:18 syntax errors André Coelho
  2022-05-10 22:23 ` Andrew Pinski
@ 2022-05-10 22:32 ` Mohamed Atef
  1 sibling, 0 replies; 5+ messages in thread
From: Mohamed Atef @ 2022-05-10 22:32 UTC (permalink / raw)
  To: André Coelho; +Cc: gcc

Because the fixed code may output results that you don't want.

int x 5;

Should it be int x = 5; or int x5;
The parsing operation is very hard and takes some time. There is a method
called Global correction to implement a compiler that changes the code but
besides the reason above it's too costly to implement.

Thanks
Mohamed

في الأربعاء، ١١ مايو، ٢٠٢٢ ١٢:٢٠ ص André Coelho via Gcc <gcc@gcc.gnu.org>
كتب:

> Hey...if the compiler can check syntax errors...why can't it fixed them?
>
>
> thanks
>
>
> andre coelho
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax errors
  2019-01-03 17:03 Daniel Marjamäki
@ 2019-01-03 17:39 ` Jonathan Wakely
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Wakely @ 2019-01-03 17:39 UTC (permalink / raw)
  To: Daniel Marjamäki; +Cc: David Malcolm, gcc

On Thu, 3 Jan 2019 at 17:03, Daniel Marjamäki
<daniel.marjamaki@gmail.com> wrote:
>
> Thank you for the quick reply.
>
> > how about "stray %qs token"?
>
> I will change.
>
> > I wonder how much we want to special-case this. Are you thinking about
> > the case where there's a stray symbol in the code (perhaps due to a
> > stray keypress, or unfinished manual edits)?
>
> At the moment I only think about ) } ]
>
> I would like to focus on only those 3 to start with. but it sounds
> good to prepare for more stray tokens later.

It doesn't scale to write a custom diagnostic for every invalid input
character in every context.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: syntax errors
@ 2019-01-03 17:03 Daniel Marjamäki
  2019-01-03 17:39 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Marjamäki @ 2019-01-03 17:03 UTC (permalink / raw)
  To: David Malcolm, gcc

Thank you for the quick reply.

> how about "stray %qs token"?

I will change.

> I wonder how much we want to special-case this. Are you thinking about
> the case where there's a stray symbol in the code (perhaps due to a
> stray keypress, or unfinished manual edits)?

At the moment I only think about ) } ]

I would like to focus on only those 3 to start with. but it sounds
good to prepare for more stray tokens later.

> if (c_parser_next_token_is_meaningless_p (parser))
>   complain_about_stray_token (parser);
> else
>   ...

sure!

> It might make sense to emit a fix-it hint suggesting the removal of the
> stray token.

It is 50% chance that the closing paranthesis should be removed. Maybe
there is a missing "(".

Maybe the error message should indicate that.. something like "either
there is missing "(" or this ")" is a stray token".

Best regards,
Daniel Marjamäki

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-05-10 22:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 22:18 syntax errors André Coelho
2022-05-10 22:23 ` Andrew Pinski
2022-05-10 22:32 ` Mohamed Atef
  -- strict thread matches above, loose matches on Subject: below --
2019-01-03 17:03 Daniel Marjamäki
2019-01-03 17:39 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).