Search code examples
interpreter

Scripting language that cannot interact with the Outside world


I need a way of flexible defining the order certain tasks are performed. There is no parallelism, only one task is active at a time. Every task has an outcome (a set of primitive values, like Integers Floating points or Strings. Which task is performed next can depend on the outcome of previous tasks.

Most of the time these dependencies are simple, like "outcome > 5". But sometimes they are more complex. For example a certain task is performed next, if a certain word occurs multiple times in the String-output of a previous task. They can also be more complex conditions in ways I do not think of yet.

So my Idea is to use a simple scripting language to define the flow/order of tasks. Than it can look like this:

outcome1 = performTask('task1');
outcome2 = performTask('task2');
if (outcame1.value > 3 && outcome2.value == "success) {
    performTask('task3');
} else {
    performTask('task4');
}

I like the Idea. Now the questions raises which scripting language to use?

Since the end user will write the scripts and possibly exchange scripts with other users, I am worried about "viruses". The outcome data is highly confidential so there must not be a way to somehow output the data. Ideally I would limit the usage of the language to the core functionality (assuming this does not involve any IO) plus a set of functions I provide.

At first I will use the language in a C++ project, but it would be nice if the browser (javascript) could be supported in the future.

I could invent my own scripting language and write my own interpreter, but that would be much work I am hoping to avoid.

So which scripting language with which interpreter could I use to meet this requirements?


Solution

  • What one usually does for this is "sandboxing" For example lua can be sandboxed, which is described here.