问题
I am trying to build an Android app which read a txt file written in Java syntax and compile it via other language.
Skip java->script, I want to know how I can embed a script interpreter or something that would compile the script code.
So the basic functionality is: read the script code, compile it, give the result. e.g. show a Hello World screen.
I know there is "official" sl4a app, but I just want the compiling piece from it and embedded in my own app. Is it possible?
Btw is there any parser that translate the java code to a Python code or other script language? If so how should i read in the java code, as a string from txt or html or?
Thanks a lot.
Thanks to everyone helps! Sorry I don't know how I should edit my own post so just do it like this.
I explained in details why I am trying to do this in my response to Femi below so you can check that out.
Briefly I just want my app to read in java code and compile it. Since there is no java interpreter or compiler under Android i have to use other language. Don't know how.
Thank you!
回答1:
Well, its an odd choice of task, but you could always embed an expression language such as MVEL (http://mvel.codehaus.org/) into your app. I'd be VERY curious how it performs, and what you'd want to use it for. Are you looking for templating, or are you trying to do the Titanium thing where you can manipulate everything in an App with a script interpreter?
回答2:
There is an interpreter called SnapScript that will run on Android out of the box. You do not need to compile the code, it has a parallel compiler that can compile scripts quickly and has minimal overhead when run on Android.
来源:https://stackoverflow.com/questions/5862569/embedding-script-interpreter-in-android-app