This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
; If I understand this correctly, converting the existing stack-machine ; (forth-like) syntax could simply be a matter of inverting the token stack as ; it is parsed, adding parens as we go, and letting guile evaluate that? ; Presumably the autogen primitives would need to be registered as guile ; functions somehow... That's about it. There's no need to produce text output; you could construct a list (scheme's internal representation of code (everything, really)). For example, suppose we wanted to translate the following C code: if (<COND>) <STMT1> else <STMT2> You would then execute the Scheme code: (list 'if (translate <COND>) (translate <STMT1>) (translate <STMT2>)) Basically constructing Scheme's internal representation directly, instead of constructing text which guile would then have to parse. There's some more wizradry you could do; CTAX does "just-in-time" translation. It has memoizing macros do the translation only the first time a piece of code needs to be executed. ; The existing parser should be rewired to pass the follwing to guile (forgive ; the crudity): ; (template ; (define HDROUT (outfile)) ; (text "\ntypedef struct {\n\tint\tstuff;\n} t") ; (cap type) ; (text "Stuff;\n") ; (for foo ; (text "\n#define ") ; bar ; (text "_STUFF ") ; (eval (index))) ; (text "\n\nextern t") ; (cap type) ; (text "Stuff ") ; (down type) ; (text "Array[ ") ; (eval (+ 1 (hilim foo))) ; (text " ];\n#define ") ; (up type) ; (text "(n) ") ; (down type) ; (text "Array[ n ## _STUFF ]\n")) That's about it. You wouldn't pass it as text, but as a list. ; and guile has had the necessary functions registered to emit text equivalent ; to the current autogen parser when it evaluates this expression... is the C ; interface to guile documented well enough to find how to do this yet? guile has a lot of text-mangling functions, but probably not exactly the ones you need. You could add these in C or scheme. The guile C interface is pretty well documented; I learned it from the tutorial and from reading code. It's really very easy to add guile functions. ; That said, how are the primitives registered with guile? Presumably a ; dynamically loaded shared library? How does one build such a beast? ; Would you need to fire up a guile runtime to pass this stuff to, or would an ; embedded guile interpreter be linked in at compile time? presumably, the ; latter... is this documented? There are a few options here. One is to build a custom guile interpreter, linking it to your program at runtime. This is portable, easy, and painless. The other is to make your program a dynamic shared library which guile links in at runtime. This is a little more complicated to do portably, although libtool should do the trick. Then autogen would just be a guile script, and users could use autogen from their guile programs. ; I can feel cries of RTFM coming here... I understand lisp well, and scheme ; badly, and read both the tutorial and reference manual around the time of ; the 1.2 release (and the r4rs docs), but was still not able to get a good ; handle on guile... I see that the dev release has thicker documentation now, ; but before I commit a week of evenings to going through it all again I ; wondered whether the docs are considered (broadly speaking) complete yet?= ; =20 ; ; Thankyou for allowing me to field so many questions, Some of this is in the manuals, but they are still in progress. Andrew aarchiba@undergrad.math.uwaterloo.ca