FewPP.rkt is a C preprocessor, which has only one directive, but this directive is powerful enough: it adds a Fork-Exec-Wait loop function to the program text.
If you wish to know what FEWLs are, please read my other Gist -> here
This preprocessor has only one directive, as stated above, and accepts text only via STDIN and outputs only to STDOUT. You should feed it text annoted with #fewl
directives, like this simple program:
(CAREFUL, WARNING, PAY ATTENTION, THIS IS NO JOKE!) -> Never pass it the rm
command!
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#fewl (#n exec_ls) (#p [char* path]) (#f ls) (#a "-a" path)
int main() { exec_ls("/"); }
The arguments to the directive are in S-Expression syntax (except #p, as we'll see).
#n -> Name of the function
#p -> Function parameters (which you can use in #a)
#f -> The command program name (for example ls, echo or your own program or script)
#a -> The arguments
You need to separate multiple parameters with comman, like:
(#p [int a, char*b])
In #a
, you need to enclose non-parameter arguments in quotes, as you can clealy see in the example.
Also, you need to either include unistd.h
and stdlib.h
and also sys/wait.h
, or define pid_t
, NULL
and EXIT_FAILURE
via the -D
directive.
Enjoy!