I think it might depend on the eventual use of the library. If the goal is to have something that you could link with some other program and have it execute a string containing JavaScript, it may be possible.
You can look at targets/linux/main.c: line 276. This is the location where the interpreter executes a file of JavaScript. You could take what you need from this file/location and create an interface for running an arbitrary string of JS.
However, all it would do is execute the JS.. you would still need to find a way to get data back out to the running program if you want any feedback from the JS.
I am not saying it is the cleanest way to do it, just that it is a way to do it.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@Gordon, @rm:
I think it might depend on the eventual use of the library. If the goal is to have something that you could link with some other program and have it execute a string containing JavaScript, it may be possible.
You can look at targets/linux/main.c: line 276. This is the location where the interpreter executes a file of JavaScript. You could take what you need from this file/location and create an interface for running an arbitrary string of JS.
However, all it would do is execute the JS.. you would still need to find a way to get data back out to the running program if you want any feedback from the JS.
I am not saying it is the cleanest way to do it, just that it is a way to do it.