At the moment I have some PHP which sets a single variable based on the value of other independent variables in a linear format, like so:
$result = 0;
if ($var1 == 'X') {
$result += 10;
}
if ($var2 < 10) {
$result += 15;
}
elseif ($var2 > 50) {
$result -= 50;
}
// more of the same
However, I’d like to be able to express these rules in a less programming-like way, mainly so that someone who doesn’t know how to program can add/edit rules, and also because I might want to use the same rules in a Python or Perl script, without having to maintain copies in multiple languages. I could write my own simple language (for want of a better word) and parser, but I’d prefer to use an existing solution as that saves work and increases the likelihood that other people will know how to write rules in it.
Is there a sensible/obvious choice for this sort of task?
I don’t think you need a language/parser for this. You could create an expression builder (similar to how one creates email message filter rules) and store the results in a database. This will also allow other languages to access the stored rules.
Users would add comparisons until satisfied, then enter the associated assignment rule.