Hi! Pike team.
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:
$ cat hello.spear
#! /usr/bin/env spear
void main()
{
C.INCLUDE("#include <stdio.h>");
C.CC("gcc -shared -fPIC");
string s="pike";
int n=2008;
float pi=3.1415926535;
C{
char* str="c string";
int m=514;
double e=1.41421;
printf("hello world!\n");
printf("printf %s string\n",STRING{s});
printf("printf pike int: %d\n",INT{n});
printf("printf pike float: %f\n",FLOAT{pi});
P{s="modify";}
printf("%s pike var\n",STRING{s});
P{write("write %s\n",STRING{str});}
P{write("write c int: %d\n",INT{m});}
P{write("write c float: %f\n",FLOAT{e});}
}
}
$ pike -x spear hello.spear
hello world!
printf pike string
printf pike int: 2008
printf pike float: 3.141593
modify pike var
write c string
write c int: 514
write c float: 1.414
How to install:
Extract the attachment in Pike-v7.7-snapshot and make. Please see the README-spear:
$ cat README-spear
Install:
tar xzvf snapshot.tar.gz
cd Pike-v7.7-snapshot
tar xzvf ../Pike-Spear-vN.N.NNNNNNNNN.tar.gz
Note:
* src/Makefile.in is base on Pike-v7.7.44-20080421, do a vimdiff before use with a diffrent version of Pike.