Not sure if MPs is the right tool

Hello :)

So I basically want to create a small dsl that is capable of creating new rules and removing old runs from some java object that manages them. Those should be some kind of script that can be re-loaded at runtime after the user modified them. They would look something like this:

 

 

recipes.remove(house)

recipes.add(house, transform(house -> return transformed_house), bool_condition) 

 

but they can get as compex as containing functions that caluclate the result based on the current state. Basic control statements need to be present (like for loops and if cases). 

I thought about using just plain old js and use nashorn to load the js files but it would create a big security hole since anything can be loaded within the js file. I need to restrict the language usage to just the basic functions and that is really painful using nashorn (currently). Since there are some specific rules under which scripts from websites can be loaded. 

 

I would basically want to ship a jar file that holds everything needed for the language to get parsed and interpreted at runtime. Users would then write scripts and reload them.

 

Is MPS the right tool for this?

As far as I could see it will only generate class files of the AST I created, meaning that my programs will get directly translate (which is not what I want to achieve ^^). I want them to be dynamically interpreted (like python or ruby). Is there some way to tell MPS to export the language generator as a Java ScriptEngine? So it could get interpreted at runtime?

0
1 comment

This would be quite off the beaten path, I'm afraid. MPS can help you with the language definition part and then also assist the users to edit your rules. Handling the generated (Java, JavaScript, XML or whatever you choose) code is beyond what MPS could do for you. The MPS generator has not been designed to be separately embeddable in server processes. 

0

Please sign in to leave a comment.