The main code is in lib/modules/Tools.pmod/Standalone.pmod/spear.pike.
precpp() handled the source before pass it to cpp().
precpp() use Parser.Pike to parse the source, and recognize C{},P{},INT{},FLOAT{},STRING{}.
C{} block will be translate to a temporary c source file and mod "C" will be use to compile the it to a .so file, it will be call later.
If you want left the temporary c source for check, delete the follow lines in spear.pike .
Process.system(sprintf("rm -f /tmp/__c__%d_*.c",getpid())); Process.system(sprintf("rm -f /tmp/__c__%d_*.so",getpid()));
P{} block will be translate to a lambda function which will be send to the C{} block as argument.
The INT{},FLOAT{},STRING{} in the C{} block, will be translate to a lambda function wich return the resulte of the expression.
The INT{},FLOAT{},STRING{} in the Pike{} block, will be translate as parameters of P{} block.
pmod "C" use cmod "Dll" to call dlopen() etc.
you can't use cmod "Dll" directly, it is just for pmod "C".
----- Original Message ----- From: "Martin Stjernholm, Roxen IS @ Pike developers forum" 10353@lyskom.lysator.liu.se To: pike-devel@lists.lysator.liu.se Sent: Thursday, May 01, 2008 9:20 PM Subject: Spear !
I hooked Pike's compile_string() and compile_file(), and got a "new" language. I named it "Spear". In Spear, you can embed C code in Pike, and reference the variables each other. see the example:
That's cute. Can you please tell more what happens behind the scenes there?