[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: gnetlist backend for xml-bom generation
On Mon, 2009-02-23 at 16:55 -0600, Mike Crowe wrote:
> Hello all
>
> I've generated a preliminary gnetlist backend for generating an xml
> based bill of materials.
>
> It seems to be working except that I have to filter the file with sed
> after generating the netlist to convert "&" to "&".
>
> Two questions
> 1) Does anyone know how to do this filter conversion directly with the
> backend toolset (guile)?
The hard question... (best ask a scheme guru).
You might find a way with the srfi13 library. There are these examples
in the docs:
;;; Convert a string to a list of chars.
(string-fold-right cons '() s)
;;; Count the number of lower-case characters in a string.
(string-fold (lambda (c count)
(if (char-lower-case? c)
(+ count 1)
count))
0
s)
;;; Double every backslash character in S.
(let* ((ans-len (string-fold (lambda (c sum)
(+ sum (if (char=? c #\\) 2 1)))
0 s))
(ans (make-string ans-len)))
(string-fold (lambda (c i)
(let ((i (if (char=? c #\\)
(begin (string-set! ans i #\\) (+ i 1))
i)))
(string-set! ans i c)
(+ i 1)))
0 s)
ans)
You might find some combination of that, and string-append is useful.
OTOH, I'm no scheme guru, and have no idea how fast either of those
would be.
You might write a procedure which searches for the & character, splits
the string on it, then makes a concationation of <before &>&<after
&>.
I suspect you could operate recursively on the split string's second
half.
Don't ask me to figure out what functions are required to find / split
the string. You might find something suitable here though:
http://srfi.schemers.org/srfi-13/srfi-13.html
If you're going to use recursion, tail-recursion is best (to avoid
running out of stack space). If I'm getting the explanation right.. the
last call (before it returns) in the the recursive procedure should be
the one which calls its-self.
http://en.wikipedia.org/wiki/Tail_recursion
> 2) Who do I contact to get my little backend into the main code
> branch? :-)
Send a patch to this list.. talk to Ales, or one of the other developers
etc..
Post a patch to sourceforge tracker (but prod us on-list if you don't
want it to get ignored / forgotten).
Best wishes,
--
Peter Clifton
Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA
Tel: +44 (0)7729 980173 - (No signal in the lab!)
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user