Re: S-expr form of C



Rob Warnock wrote:
I'd like to ask the inverse of this, namely, is there any
generally-accepted "best style" in the Lisp community for
representing C source code in s-expr form? I know about
Aubrey Jaffer's "Schlep"[1], but it's really more a "translator"
from Scheme to C -- historical versions of it used a kind
of Hungarian mangling of function & variable names (based
on suffixes) to convey type information[2]. I'm more looking
for a more literal "representation" of C source in s-expr form,
with a view towards writing a sort of "LAP" which targets C,
with the ability to wrap CL macros around the "LAP". Anybody
got any pointers to prior art?

In my own S-exp to C system, the objective is to be able to generate (almost) all the possible C/C++ syntax from S-exp. I actually generate it from CLOS objects, and have macros defined to build these CLOS objects from the corresponding S-exp.

But this is only the lowest level of that system. (You could call it "CLAP", for "C Level Assembler Program").

Right away, I implement a macro system and progressively implement more and more of Common Lisp-alike features, generating C code. Soon enough we don't write (for ...) loops, but dotime or dolist loops...


So there's not much point in having a "generally-accepted best style" for this kind of things, since with macros you will develop your own DSL anyways.


--
__Pascal Bourguignon__
http://www.informatimago.com
.



Relevant Pages

  • Re: Data Type Converter
    ... >> in C is done with macros. ... Without such methods the source code ... My primary goal is a C to Delphi converter, ... But there exist no restrictions on the number of back-ends for that converter, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Runtime macros
    ... Since other people have complained that macros in Common Lisp are already first class, I wonder what term they would like us to use for macros that may be passed around as functions may be and used in that way? ... use") the runtime constraints are never violated and I never ... But the minute somebody assigns to source code I have to throw out everything that depended on the constant-sourcecode constraint and fall back on the unoptimized versions. ... And, unfortunately, I haven't got any optimizations working ...
    (comp.lang.lisp)
  • Re: The Mark of a Serious programmer.
    ... > it simplifies the source code and reduces complexity. ... Macros may be ok for addressing portability issues. ... In a given scoop you can create a container full of trolls and never ...
    (comp.os.linux.development.apps)
  • Re: Masm32 error line number limit
    ... source code line numbers higher than 65535. ... I'm guessing this must be a holdover from 16-bit days. ... the limit when making heavy use of macros in an HLA program of ...
    (comp.lang.asm.x86)
  • Re: The Advantage of Macros
    ... Yeah, yeah, tired old insult. ... you *might* try learning about macros sometime. ... those who were making a living at it back in the days when you were ... by the bytes of source code they've produced, take a look at the HLA ...
    (alt.lang.asm)

Loading