/* * Copyright (C) 2020 Weber Yann * * This file is part of pyrpn. * * pyrpn is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * pyrpn is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with pyrpn. If not, see . */ #include "rpn_mutation.h" /**@file rpn_mutation.c * @todo continue implementation */ const rpn_mutation_profile_t rpn_default_mutprof = {16, { RPN_del, RPN_del, RPN_add, RPN_add, RPN_chg, RPN_chg, RPN_chg, RPN_chg, RPN_chg, RPN_chg, RPN_upd, RPN_upd, RPN_upd, RPN_upd, RPN_upd, RPN_upd} }; rpn_expr_t* rpn_expr_mutation(rpn_expr_t *src, size_t mutations) { return rpn_expr_mutation_p(src, mutations, &rpn_default_mutprof); } rpn_expr_t* rpn_expr_mutation_p(rpn_expr_t *src, size_t mutations, const rpn_mutation_profile_t *prof) { unsigned char op; prof = prof?prof:&rpn_default_mutprof; op = prof->mods[(int)(drand48() / (1.0 / prof->mods_sz))]; switch(op) { case 0: // add a token break; case 1: // delete a token break; case 2: // update token type break; default: // update token, same type break; } return NULL; }