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] Whether could I know in advance it would have errors before adding a file (Kernel.Files.add)?



Hello,

2013/9/15 David Yang <abiao.yang at gmail.com>:
> 1. Overall, My question is:  Whether could I know in advance it would have
> errors before adding a file (Kernel.Files.add)?
>

you can try to parse the file alone in an independent project and
catch the exception that is raised by the parser in case of user
error. e.g. something like (not tested)

...
let prepare_file f = try File.init_from_c_files [File.from_filename
f]; true with Log.AbortError s -> MyPlugin.warning "Not adding %s
because of %s" f s; false in
let prj = Project.create "tmp" in
let is_ok = Project.on prj prepare_file "foo.c" in
Project.remove prj;
if is_ok then Kernel.Files.add "foo.c";
...

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