Re: parsing C function declarations to generate code to serialize the formal arguments

Eliot Miranda <eliotm@pacbell.net>
14 Dec 2006 17:27:38 -0500

          From comp.compilers

Related articles
parsing C function declarations to generate code to serialize the form einatbg@zahav.net.il (Moshe Pfeffer) (2006-12-14)
Re: parsing C function declarations to generate code to serialize the eliotm@pacbell.net (Eliot Miranda) (2006-12-14)
Re: parsing C function declarations to generate code to serialize the DrDiettrich1@aol.com (Hans-Peter Diettrich) (2006-12-14)
Re: parsing C function declarations to generate code to serialize the alex_mcd@btopenworld.com (Alex McDonald) (2006-12-15)
Re: parsing C function declarations to generate code to serialize the idbaxter@semdesigns.com (Ira Baxter) (2006-12-24)
| List of all articles for this month |
From: Eliot Miranda <eliotm@pacbell.net>
Newsgroups: comp.compilers
Date: 14 Dec 2006 17:27:38 -0500
Organization: SBC http://yahoo.sbc.com
References: 06-12-056
Keywords: C, parse
Posted-Date: 14 Dec 2006 17:27:38 EST

Moshe Pfeffer wrote:
> I am looking for an elegant method to do the following. Are there
> tools available to help? Have you done something like this that I may
> also try?
>
> I wish to take a C header file consisting of a list of function
> declarations, parse the function declaration to obtain a
> representation of the formal parameters from which to generate C
> code. Each argument must be processable as a tree, since it may be a
> struct, or pointer to a struct, with further structs/pointer to
> structs as it's members, or member's members, etc. If it is a simple
> type, the tree has 1 node, and depth 1. If it is a pointer to a simple
> type, the tree has 2 nodes and depth 2 (one for the pointer and one
> for the data pointed to).


Every language platform that provides tools to automatically generate
interfaces to a given OS's ABI (since so many are implemented in C) do
this. But they may not do it in exactly the way you anticipate. For
example, these tools may generate machine code to perform argument
marshalling for call-outs and call-backs to/from C. They may include
implementations of platform-specific structure member alignment rules so
that structures are correct across OSs. They will probably include (or
use) a C preprocessor to correctly parse arbitrary header files.


I am familiar with such tools in the Smalltalk world where they're used
to interface Smalltalk virtual machines to some forms of external code.
    But you'd find similar technologies in Lisp (CLOS), Java and other
development systems.


--
The surest sign that intelligent life exists elsewhere in Calvin &
the universe is that none of it has tried to contact us. Hobbes.
--
Eliot ,,,^..^,,, Smalltalk - scene not herd


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.