[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting source location information
From: |
Bruce Korb |
Subject: |
Re: Getting source location information |
Date: |
Wed, 30 Nov 2005 07:30:43 -0800 |
User-agent: |
KMail/1.7.1 |
On Wednesday 30 November 2005 06:44 am, Ludovic Courtès wrote:
> Bruce Korb <address@hidden> 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
- I don't want to maintain this, Bruce Korb, 2005/11/27
- I don't want to maintain this, Bruce Korb, 2005/11/28
- Re: I don't want to maintain this, Ludovic Courtès, 2005/11/29
- Re: I don't want to maintain this, Bruce Korb, 2005/11/29
- Re: I don't want to maintain this, Ludovic Courtès, 2005/11/30
- Re: I don't want to maintain this, Bruce Korb, 2005/11/30
- Re: I don't want to maintain this, Ludovic Courtès, 2005/11/30
- Re: I don't want to maintain this, Bruce Korb, 2005/11/30
- Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information,
Bruce Korb <=
- Re: Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information, Rob Browning, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Rob Browning, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Han-Wen Nienhuys, 2005/11/30
Re: I don't want to maintain this, Kevin Ryde, 2005/11/30
Re: I don't want to maintain this, Kevin Ryde, 2005/11/30