guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Syntax locations are ambiguous: can we track source 'offset' and 'le


From: Ludovic Courtès
Subject: Re: Syntax locations are ambiguous: can we track source 'offset' and 'length'?
Date: Wed, 04 Aug 2021 15:41:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

Vivien Kraus <vivien@planete-kraus.eu> skribis:

> Ludovic Courtès writes:
>>> I am trying to use the guile reader to read scheme comments, in
>>> addition to the syntax elements. I know with syntax-source where a
>>> syntax object starts, and I can know where it ends by using a spying
>>> soft port and re-reading it. However, the #\return ambiguity makes all
>>> my efforts pointless.
>>
>> As you know, ‘read-syntax’ appeared in 3.0.7, so it’s brand new and we
>> could certainly extend (ice-9 read) with more features, including
>> reading comments.
> I did not know that, to be honest.
>
>> In the meantime, I needed the ability to read comments in Guix,
>> including with Guile < 3.0.7, so I hacked up this thing:
>>
>>   
>> https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/style.scm?h=core-updates&id=8419221620191d2988c22f6e7811d9ce1e0837bf#n50
>>
>> It can read and write while preserving comments.
> I was tempted not to use the guile reader and go and implement a new
> reader like you did, but I was too afraid to miss one important thing in
> the syntax.

This hack is layered on top of the real ‘read’, so it cannot miss
things.

> I’m happy to see this pretty-print-with-comments function. I want guile
> to have a tool that can automatically reformat scheme code, to avoid
> indentation problems with code reviews and pointless discussions about
> style. We could even tweak text editors to convert between different
> styles for viewing the source and for git commits. I’m sure wisp people
> would like it. I hope to see "guix style" one day :)

It *is* ‘guix style’.  :-)

Currently the command is focusing on one very specific style issue, but
we could certainly expand it for more general formatting.

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]