a simple & lightweight interpreter
$1="I said \"Hello\" and val is 0x%x\n"
$2=0x1234
printf
Output:
I said "Hello" and val is 0x1234
A c program to run this program:
#include<stdio.h>#include"dynamic.h"structsymbolsymbols[] = {
{ "printf", &printf },
{ }
};
intmain() {
// Make sure this is mutable! (p.s. it will be destroyed after the run)charprogram[] ="$1=\"I said \\\"Hello\\\" and val is 0x%x\\n\"\n""$2=0x1234\n""printf";
if (dynamic_eval(program, symbols) !=0) {
printf("dynami_c failed to parse the program\n");
return-1;
}
return0;
}