unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Vivien Kraus via General Guile related discussions <guile-user@gnu.org>
To: guile-user@gnu.org
Subject: Syntax locations are ambiguous: can we track source 'offset' and 'length'?
Date: Tue, 03 Aug 2021 00:50:24 +0200	[thread overview]
Message-ID: <771a6e88782e288143be269b14751b761523e4c1.camel@planete-kraus.eu> (raw)

Dear guilers,

I’m playing with syntaxes as first-class objects, and I notice that the
syntax source location is ambiguous:

(syntax-case
    (call-with-input-string "(a\r b)" read-syntax) ()
  ((a b)
   (values (syntax-source #'a) (syntax-source #'b))))

=>

$1 = ((line . 0) (column . 1))
$2 = ((line . 0) (column . 1))

This is obviously because of #\return.

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.

In (system base lalr), the source location contains a filename, line
and column, but also an offset and length. However, these last 2 get
dropped in source-location->source-properties. I could not find out
whether this is relevant to read-syntax.

So, is there a way to track source offset and length for syntax
objects?

Best regards,

Vivien




             reply	other threads:[~2021-08-02 22:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 22:50 Vivien Kraus via General Guile related discussions [this message]
2021-08-03 19:29 ` Syntax locations are ambiguous: can we track source 'offset' and 'length'? Linus Björnstam
2021-08-03 23:51   ` Vivien Kraus via General Guile related discussions
2021-08-04  1:20     ` Keith Wright
2021-08-04 10:01       ` Vivien Kraus via General Guile related discussions
2021-08-04 12:05 ` Ludovic Courtès
2021-08-04 12:25   ` Vivien Kraus via General Guile related discussions
2021-08-04 13:41     ` Ludovic Courtès
2021-08-04 14:09       ` Vivien Kraus via General Guile related discussions

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: https://www.gnu.org/software/guile/

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

  git send-email \
    --in-reply-to=771a6e88782e288143be269b14751b761523e4c1.camel@planete-kraus.eu \
    --to=guile-user@gnu.org \
    --cc=vivien@planete-kraus.eu \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).