[cfe-dev] code conversion challenge
Philip Ashmore
contact at philipashmore.com
Mon Feb 27 23:21:31 PST 2012
On 28/02/12 07:01, Philip Ashmore wrote:
> Hi there.
>
> Here's the problem:
> Given the source file with this content:
>
> int main(int argc, char * argv[])
> {
> /* all ok */
> return 0;
> }
>
> I want to convert it into something like this:
>
> module
> ( function
> ( Name("main")
> , Returns("int")
> , Parameters
> ( Parameter(Type("int"), Name("argc")
> , Parameter(Type(Array(Pointer("char"), Size()), Name("argv")
> )
> , Body
> ( Comment("all ok")
> , Return(Int(0i32))
> )
> )
> )
>
> This is a description format that has a binary representation that allows for
> easy depth-first and breadth-first traversal.
>
> With it one can describe C/C++, make files, pre-processor macros etc. - the
> reader supplies the meaning to the "calls" like "module".
>
> With it I hope to be able to describe things like interfaces and be able to
> automate the glue that allows it to be called from scripting languages,
> and much more.
>
> I haven't even given this format a name, but I can convert the text above to
> and from the binary representation.
>
> So that's the challenge - any takers?
>
> Regards,
> Philip Ashmore
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
OK, maybe not this exact example - the parameters are missing ')', but
you get the idea.
Philip
More information about the cfe-dev
mailing list