--- layout: fc_discuss_archives title: Message 52 from Frama-C-discuss on February 2012 ---
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