English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Looking for C parser
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-12-14 (08:44)
From: Francois Pessaux <pessaux@m...>
Subject: Re: Looking for C parser

> I need to do some translation on a C program based on program tree
> (either abstract, or concrete). So I'm looking for a C language parser
> and lexer.

Try to have a look at: http://www.lysator.liu.se/c/
More accurately look for the line " The ANSI C grammar (Yacc and Lex) "

This will lead you at: http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
and: http://www.lysator.liu.se/c/ANSI-C-grammar-l.html

But you must know that this grammar still allows to write unconsistent C
sentences. I used it to write a .h analyzer and I needed to performs of
strong pass of consistence-verification of the tree I got this this parser
to ensure that sentences are correct. For example, this parser parses some
stuff like:
struct {
  void long short long signed int char unsigned volatile foo ;

... Unless it changed since I got it ;-)


(*                      Francois PESSAUX (Francois.Pessaux@inria.fr) *)
(*                               INRIA Rocquencourt - Projet CRISTAL *)
(*                               (http://pauillac.inria.fr/~pessaux) *)