--- layout: fc_discuss_archives title: Message 107 from Frama-C-discuss on September 2013 ---
[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