From: Rob Browning <rlb@defaultvalue.org>
Cc: guile-devel@gnu.org
Subject: Re: Getting source location information
Date: Wed, 30 Nov 2005 11:00:45 -0800 [thread overview]
Message-ID: <87hd9uezaa.fsf@trouble.defaultvalue.org> (raw)
In-Reply-To: <87psoixgtv.fsf@laas.fr> (Ludovic Courtès's message of "Wed, 30 Nov 2005 17:04:28 +0100")
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
> If you want to use source locations in a Guile-friendly way (so that
> Guile can, for instance, display location information in
> backtraces), then you may want to use `scm_set_source_property_x
> (sexp, key, datum)' (where KEY may be one of SCM_SYM_FILENAME,
> SCM_SYM_LINE, SCM_SYM_COLUMN) which is defined in `srcprop.h'.
I think this is probably more along the lines of what he wants, but is
the above going to work correctly if there are multiple lines of
Scheme code? For example:
[This is an example ]
(do-something (foo) (bar))
(let ((baz bax))
(do-something-else baz)
(more-stuff baz)
(and-even-more baz))
[ ...with several lines of embedded Scheme code. ]
If I'm guesssing correctly about how scm_set_source_property_x works
(I haven't used it), then it seems like it might be a lot of work to
turn the above lines of Scheme code into a properly filename, line
(and column?) annotated set of forms.
If so, then I wondered if it might be possible to just implement the
function mentioned originally
i.e. ag_scm_c_eval_string_from_file_line, and here's what I came up
with. Note that I have no idea if this will actually work; I haven't
tested it, and I don't know the semantics of the port related
filename, line, and column bits offhand.
(define (eval-port port)
;; See strports.c inner_eval_string for similar code.
(let loop ((next-form (read port))
(any-read? #f)
(result #f))
(if (eof-object? next-form)
(if any-read? result)
(loop (read port)
#t
(primitive-eval next-form)))))
(define (eval-string-from-file str filename line column)
(call-with-input-string str
(lambda (port)
(set-port-filename! port filename)
(set-port-line! port line)
(set-port-column! port column)
(eval-port port))))
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2005-11-30 19:00 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-28 4:25 I don't want to maintain this Bruce Korb
2005-11-29 8:16 ` Ludovic Courtès
2005-11-29 20:14 ` Bruce Korb
2005-11-30 8:39 ` Ludovic Courtès
2005-11-30 12:30 ` Bruce Korb
2005-11-30 13:46 ` Ludovic Courtès
2005-11-30 14:00 ` Bruce Korb
2005-11-30 14:44 ` Getting source location information Ludovic Courtès
2005-11-30 15:30 ` Bruce Korb
2005-11-30 16:04 ` Ludovic Courtès
2005-11-30 16:58 ` Bruce Korb
2005-11-30 17:39 ` Ludovic Courtès
2005-12-01 12:19 ` Ludovic Courtès
2005-11-30 19:00 ` Rob Browning [this message]
2005-11-30 20:53 ` Bruce Korb
2005-11-30 22:35 ` Rob Browning
2005-11-30 23:30 ` Bruce Korb
2005-12-14 21:54 ` Kevin Ryde
2005-11-30 23:45 ` Han-Wen Nienhuys
2005-12-01 0:30 ` I don't want to maintain this Kevin Ryde
2005-12-01 0:38 ` Kevin Ryde
2005-12-07 0:36 ` Marius Vollmer
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=87hd9uezaa.fsf@trouble.defaultvalue.org \
--to=rlb@defaultvalue.org \
--cc=guile-devel@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.
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).