Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Rewriting UNIX in Caml and getting rid of the C disease
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Berke Durak <berke@a...>
Subject: Re: [Caml-list] GCCXML: don't write your own C parser. (WAS: Rewriting UNIX . . .)
On Mon, Nov 12, 2001 at 12:33:47PM -0500, Jeff Henrikson wrote:
> > You may be interested in a project I am implementing at the moment:
> > The idea is to automatically translate any C program into a
> > memory-safe language. . .

Sounds particularly interesting.

> You're obviously going to need a parser and I presume you don't want
> to write one.  Make sure to check out this extenion to GCC which
> prints out an XML abstract syntax tree of anything GCC can parse.

> 
> http://public.kitware.com/GCC_XML/
> 

Very good idea. Indeed I got that idea about rewriting UNIX in Caml last
day when I was trying to Camlify a YACC grammar for ANSI C. And most
programs are far from being ANSI C (everyone has certainly used GNU
extensions ?). So, since we're fighting against C, and since GNU C is
the most widespread GNU compiler, directly using GNU C's output
seems to be the most useful approach. Since Caml is dependent on C,
it would be fair enough to be able to easily manipulate C programs
in Caml.

> I'm going to write such a thing Real Soon Now, as I think it would
> be especally interestng to do other sorts of C/C++ metalingustic
> hacking on account of the vast amount of available code.  (But if
> you really need it, don't wait for me, as I get busy often)

A well-designed C syntax module, both parsing and unparsing, would be really
great. It would be very useful for :

1) Emitting C code (could be applied to FFTW or CamlIDL)
2) Creating automatic code obfuscators
3) Playing with C semantics (experiments in model-checking etc.)

A C ``interpreter'' could be thus written. I've already seen a Java course
taught using Caml. It could be useful for teaching (eg. ``Exercice. Write
a Caml program that removes for-loops from C programs'')...
--
Berke
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr