I'm trying to figure out the best and most secure way to implement a shell that interacts with a web app. Here's the outline of an example problem:
1- There are several objects residing in a javascript array (e.g. [obj1, obj2, ...]
) and each has a set of methods (e.g. obj.setName(name), obj.getName()
).
2- I'd like to have an input field where the user can interact with the objects in a python-like language:
o = webApp.getObjByIndex(0)
print(o.getName())
As far as I can tell, my main option is to build a simple interpreter in javascript where it gets input lines one-by-one, parses it and then try to execute it. However it gets quickly complicated when implementing more features like a for
loop.
My questions are:
- Is there a better way? Are there tools for creating domain specific languages (DSL) that javascript can understand?
- Is it possible to implement two-way python-javascript interaction in a web app?
- I'm sure there must be website implementing similar ideas. Do you know any good examples?
Thanks.