git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Paul Smith <psmith@gnu.org>
Cc: Junio C Hamano <gitster@pobox.com>, Taylor Blau <me@ttaylorr.com>,
	git@vger.kernel.org,
	Dario Gjorgjevski <dario.gjorgjevski@gmail.com>
Subject: Re: [PATCH] Makefile(s): avoid recipe prefix in conditional statements
Date: Mon, 8 Apr 2024 20:17:28 -0400	[thread overview]
Message-ID: <20240409001728.GB1647304@coredump.intra.peff.net> (raw)
In-Reply-To: <20240409000414.GA1647304@coredump.intra.peff.net>

On Mon, Apr 08, 2024 at 08:04:14PM -0400, Jeff King wrote:

> I do find it curious that in:
> 
> ifdef FOO
> 	SOME_VAR += bar
> endif
> 
> the tab is significant for "ifdef" but not for SOME_VAR (at least that
> is implied by Taylor's patch, which does not touch the bodies within the
> conditionals).
> 
> I may just be showing my ignorance of the parsing issue, though. For
> anybody else digging into the details, I think the correct link is:
> 
>   https://savannah.gnu.org/bugs/index.php?64185
> 
> (the commit has the wrong bug number, 64815).

Answering my own question (at least what I think the answer is): there's
basically two levels of parsing going on. The outer layer is respecting
conditionals to decide which lines to care about at all, and the inner
one is figuring what are assignments, rules, recipes, etc.

So the outer parser cares about things that look like conditionals, but
nothing else. The inner one has more context and can more easily realize
that "\tSOME_VAR += bar" is not part of a recipe.

I'd guess it's _possible_ to fix the case discussed in the bug by
letting the outer parser know more of the inner-parser context (i.e.,
whatever rules it uses to decide that the assignment line is not a
recipe line could similarly be used for a line like "\telse"). But I
also wouldn't be at all surprised if it would involve a substantial
rewrite.  At any rate, I'd certainly defer to you on such matters. I'm
mostly just thinking out loud from my peanut-gallery perspective.

-Peff


  reply	other threads:[~2024-04-09  0:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-08 10:44 Makefiles are broken as of GNU Make commit 07fcee35f058a876447c8a021f9eb1943f902534 Dario Gjorgjevski
2024-04-08 15:51 ` [PATCH] Makefile(s): avoid recipe prefix in conditional statements Taylor Blau
2024-04-08 21:41   ` Junio C Hamano
2024-04-08 23:24     ` Paul Smith
2024-04-08 23:34       ` Junio C Hamano
2024-04-09 20:41         ` Paul Smith
2024-04-08 23:44       ` Junio C Hamano
2024-04-09 20:42         ` Paul Smith
2024-04-09 21:23           ` Junio C Hamano
2024-04-09  0:04       ` Jeff King
2024-04-09  0:17         ` Jeff King [this message]
2024-04-09 20:44         ` Paul Smith
2024-04-08 23:28     ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240409001728.GB1647304@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=dario.gjorgjevski@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=psmith@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).