index.js
function (cmd, parentCmd, pos) {
    var S  = 'Somme';
    var D  = 'Diff';
    var P  = 'Produit';
    var Q  = 'Quotient';
    var O  = 'Opposé';
    var I  = 'Inverse';
    var C  = 'Carré';
    var Pu = 'Puissance';
    var R  = 'Racine';
    if (belongsTo(parentCmd, [C,Pu]) && pos == 0) {
        return belongsTo(cmd, [S,D,O,P,Q,I,C,Pu]);
    }
    if (parentCmd == P) {
        return belongsTo(cmd, [S,D,O]);
    }
    if ((parentCmd == O) || (parentCmd == D && pos == 1)) {
        return belongsTo(cmd, [S,D,O]);
    }
    if (parentCmd == S && cmd == O && pos == 1) {
        return true;
    }
    return false;
}
function (cmd, parentCmd, pos) {
    var S  = 'Somme';
    var D  = 'Diff';
    var P  = 'Produit';
    var Q  = 'Quotient';
    var O  = 'Opposé';
    var I  = 'Inverse';
    var C  = 'Carré';
    var Pu = 'Puissance';
    var R  = 'Racine';
    if (belongsTo(parentCmd, [C,Pu]) && pos == 0) {
        return belongsTo(cmd, [S,D,O,P,Q,I,C,Pu]);
    }
    if (parentCmd == P) {
        return belongsTo(cmd, [S,D,O]);
    }
    if ((parentCmd == O) || (parentCmd == D && pos == 1)) {
        return belongsTo(cmd, [S,D,O]);
    }
    if (parentCmd == S && cmd == O && pos == 1) {
        return true;
    }
    return false;
}
@summary Tests if the sub-expr should be surrounded with parens.

@param cmd The current type of expr, aka command
@param parentCmd The parent command
@pos Position in the list of args, starting with 0
@return a boolean