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] |
On Wed, Jun 03, 1998 at 01:58:32PM -0400, you <Andrew> wrote: Andrew> What would be involved in using guile? The ideal way for a new Andrew> project is to write a parser in scheme. You could either write one Andrew> from string-manipulation primitives or the lex and yacc modules for Andrew> guile. Or, if you've got the parser written already, you could Andrew> persuade it to emit scheme code. This would translate your input Andrew> syntax into scheme code, transparently to the user (no parens!). Andrew> Then, anything your input syntax allows can be converted to scheme and Andrew> run. One way to make sure that your syntax is as powerful as guile is Andrew> to allow scheme expressions verbatim, but there are many other Andrew> ways. CTAX provides a C-like syntax for guile. Think of it as a Andrew> compiler that produces LISP machine opcodes. Thanks for the prompt reply! 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... Taking part of Bruces example: Bruce> [=_SETENV HDROUT _outfile=] Bruce> typedef struct { Bruce> int stuff; Bruce> } t[=type _cap=]Stuff; Bruce> [=_FOR foo=] Bruce> #define [=bar=]_STUFF [=_eval _index=][= Bruce> /foo "end of 'foo' loop" =] Bruce> Bruce> extern t[=type _cap=]Stuff [=type _down=]Array[ [= Bruce> _EVAL foo _hilim 1 +=] ]; Bruce> #define [=type _up=](n) [=type _down=]Array[ n ## _STUFF ] 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")) 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? 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? 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? Thankyou for allowing me to field so many questions, Gary V. Vaughan. -- ___ _ ___ __ _ / __|__ _ _ ___ _| | / / | / /_ _ _ _ __ _| |_ __ _ ___ | (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \ \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/ PGP Key from/___/ /___/ http://www.cl.cam.ac.uk/PGP/pks-commands.html#extract http://pgp.ai.mit.edu/~bal/pks-commands.html#extract