Frama-C-discuss mailing list archives

This page gathers the archives of the old Frama-C-discuss archives, that was hosted by Inria's gforge before its demise at the end of 2020. To search for mails newer than September 2020, please visit the page of the new mailing list on Renater.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Frama-c-discuss] Replacing the CIL parser thru a plugin?



Hello Basile,

2012/2/8 Basile Starynkevitch <basile at starynkevitch.net>:

> Imagine I have some intermediate representation of C-like or Fortran-like
> souece code, in e.g. some JSON or YAML file -in a format I can define and
> enhance, which is produced by some generator-, and I want to code in Ocaml a
> plugin to construct in Frama-C's memory a representation of it, probably by
> calling suitable constructors from cil/src/cil_types.mli, how should I
> proceed?
>

You can use the File.add_new_file_type. This function takes two
arguments: a suffix identifying the files that have
to be treated by the external parser (say .melt for instance), and a
function taking a filename and returning a pair (Cil_types.file *
Cabs.file), that is
a normalized AST and an untyped AST. Depending on your representation,
It is of course possible to directly generate the normalized AST
(possibly using a dummy Cabs.file: it is only used by plug-ins that
depend on the exact form of the code rather than on its semantics),
but in order to ensure that all invariants expected by CIL on the AST
are met, generating an untyped AST (Cabs.fil) and converting it
through Cabs2cil.convFile seems the easiest way.

Best regards,
-- 
E tutto per oggi, a la prossima volta
Virgile