Version française
Home     About     Download     Resources     Contact us    
Browse thread
GNU C parser prototype in Caml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pascal Brisset <Pascal.Brisset@w...>
Subject: GNU C parser prototype in Caml
There were discussions about parsing ANSI C with Caml a few weeks ago.

I recently tried to write a parser for a significant subset of GNU C.
Basically, it parses most of the Linux kernel source tree, including
the challenging GNU C "features" demonstrated in:

  int a, b;
  typedef int t, u;
  void f1() { a * b; }
  void f2() { t * u; }
  void f3() { t * b; }
  void f4() { int t; t * b; }
  void f5(t u, unsigned t) {
    switch ( t ) {
    case 0: if ( u )
    default: return;
    }
  }

(After realizing that this is legal gcc code, I gave up on fixing the
last few grammar conflicts. Also, I have no idea whether it is
actually safe to do side effects between ocaml's parser and lexer.)

The code is currently part of a larger project distributed at :
http://perso.wanadoo.fr/pascal.brisset/kernel3d/kernel3d.html
Fixes are welcome.

-- Pascal Brisset