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] Unknows Pragma
- Subject: [Frama-c-discuss] Unknows Pragma
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- Date: Wed, 2 Jun 2010 10:20:23 +0200
- In-reply-to: <4C05F087.8000300@tke.fi>
- References: <4BFF8109.10903@tke.fi> <AANLkTinL1AJ0k0C_7D6wqlIEe3uBWvLTy5IxzKzc7lIU@mail.gmail.com> <4C038E06.902@tke.fi> <20100531124550.4fa8f086@is010235> <4C05F087.8000300@tke.fi>
Hello,
> I got the command to work. But obviously I have several other pragmas that
> should be ignored. Seems like I will need the perlscript anyway.
It is a little longer in OCaml than in Perl, but it was faster for me
to write this way
(and it doesn't add dependencies since you already have OCaml now).
___
let description = "\\(#pragma LINK_INFO.*\\)"
^ "\\|" ^ "\\(#pragma foo\\)"
let regexp = Str.regexp description
let () =
try
while true; do
let line = input_line stdin in
if Str.string_match regexp line 0
then print_newline ()
else print_endline line
done;
with End_of_file -> ()
___
Name the file gr.ml.
Compile with:
ocamlc -o gr str.cma gr.ml
or even better, if you have ocamlopt, use instead:
ocamlopt -o gr str.cmxa gr.ml
The command gr reads from its standard input and emits a filtered file
on its standard output.
___
#pragma bar
#pragma foo
#pragma zut
#pragma LINK_INFO blah, blah
int main()
{
return 0; /* hopefully all goes well. */
}
___
gr < test.c
___
#pragma bar
#pragma zut
int main()
{
return 0; /* hopefully all goes well. */
}
___
Use frama-c with the option:
-cpp-command "gcc -C -E -I. - < %1 | gr > %2"
The syntax for regular expressions is at:
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html
Note that unlike grep, you must use regexps that match the entire line
that you wish to me removed. Use .* at the beginning and end of your
regexps if appropriate.
Pascal
- Follow-Ups:
- [Frama-c-discuss] Unknows Pragma
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] Unknows Pragma
- From: pascal.cuoq at gmail.com (Pascal Cuoq)
- [Frama-c-discuss] Unknows Pragma
- References:
- [Frama-c-discuss] Unknows Pragma
- From: patrik.nylund at tke.fi (Patrik Nylund)
- [Frama-c-discuss] Unknows Pragma
- Prev by Date: [Frama-c-discuss] Unknows Pragma
- Next by Date: [Frama-c-discuss] Unknows Pragma
- Previous by thread: [Frama-c-discuss] Unknows Pragma
- Next by thread: [Frama-c-discuss] Unknows Pragma
- Index(es):
