From: Bruce Korb <bruce.korb@gmail.com>
Subject: Re: Getting source location information
Date: Wed, 30 Nov 2005 07:30:43 -0800 [thread overview]
Message-ID: <200511300730.44076.bruce.korb@gmail.com> (raw)
In-Reply-To: <878xv62o13.fsf_-_@laas.fr>
On Wednesday 30 November 2005 06:44 am, Ludovic Courtès wrote:
> Bruce Korb <bruce.korb@gmail.com> writes:
>
> > Because the file is mostly *NOT* scheme.
>
> I did say that you could use "Scheme constructs", "be it from Scheme
> o[r] C code". In other words, you can either write `(read)' in a piece
> of Scheme code, or call `scm_read ()' from your C code: both are
> strictly equivalent (well, almost).
>
> The point is: do not rewrite what already exists because *this* is hard
> to maintain.
>
> Actually, what you want is `primitive-load' + `read' (which handles
> piggy-backing of source location information as I said). It is true,
> however, that `primitive-load' (or, rather, `open-input-file') is not
> guaranteed to use `mmap ()' the way you do it currently[*]. So if you
> do want to make sure that the input file is `mmap'd the way you like,
> then you may want to write your own variant of `primitive-load' (see
> `libguile/load.c').
>
> In any case, I can hardly imagine how Guile itself could be more helpful
> than this. ;-)
Hi,
I am completely certain that this makes sense to you. To me, it does
not. If I call ``scm_read(port)'' I have to attach the input file
as a port. That read function reads an s-expr. How can that work if
the non-Scheme text in the file is not an s-expr? I don't see another
function for getting text from a port. Am I missing something?
Especially troubling is the phrase, "Any whitespace before the
next token is discarded." I do not want tokenized input. I want raw
text. I have my own methods for determining when something needs
a Scheme evaluation. I will certainly have a more authoritative idea
about what is discardable white space and what is not. Here, take
a look at an example template file:
http://autogen.sourceforge.net/doc/autogen_3.html#SEC3
It is about halfway down, after the phrase "It looks something like this".
Oh, here it is anyway, but there is some discussion describing it on
that page:
[+ AutoGen5 template h c +]
[+ CASE (suffix) +][+
== h +]
typedef enum {[+
FOR list "," +]
IDX_[+ (string-upcase! (get "list_element")) +][+
ENDFOR list +] } list_enum;
extern const char* az_name_list[ [+ (count "list") +] ];
[+
== c +]
#include "list.h"
const char* az_name_list[] = {[+
FOR list "," +]
"[+list_info+]"[+
ENDFOR list +] };[+
ESAC +]
That example text contains 3 scheme phrases to be evaluated by Guile:
(suffix)
(string-upcase! (get "list_element"))
(count "list")
"get", "count" and "suffix" are my own functions defined in other ways.
The file name should be "list.tpl" in all cases and the line numbers
be 2, 6 and 9 respectively. Everything else is handled by my program.
So, I can hardly imagine how Guile would be able to do what you say it
can. Likely, I am just missing something, but nevertheless, it is
escaping me. BTW, the expression on line 6 gets evaluated three times.
Each time, ``(get "list_element")'' returns a different value. Likewise,
``(suffix)'' is evaluated twice and returns "h" the first time and "c"
the second time.
Sorry to be such a bother. Thanks - Bruce
_______________________________________________
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 15:30 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 [this message]
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
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=200511300730.44076.bruce.korb@gmail.com \
--to=bruce.korb@gmail.com \
/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).