/*
* 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 .
*/
#ifndef __rpn_mutation__h__
#define __rpn_mutation__h__
#include
#include "rpn_jit.h"
/**@defgroup mutation RPN expression mutation
* @ingroup rpn
*/
/**@file rpn_mutation.h
* @brief Contains structures and function to mutate RPN epxressions
*/
/**@brief Defines mutation actions types */
enum rpn_mutation_op_e {
/**@brief Mutation action : delete a token */
RPN_del,
/**@brief Mutation action : add a token */
RPN_add,
/**@brief Mutation action : change a token */
RPN_chg,
/**@brief Mutation action : update a token (same type, different value) */
RPN_upd
};
/**@brief Shortcut for struct @ref rpn_mutation_profile_s */
typedef struct rpn_mutation_profile_s rpn_mutation_profile_t;
/**@brief Stores mutation informations
* @ingroup mutation
*/
struct rpn_mutation_profile_s
{
/**@brief Size of @ref rpn_mutation_profile_s::mods attribute */
size_t mods_sz;
/**@brief Modification possibilities
*
* One value is picked up randomly from this list to determine
* the type of mutation : addition, deletion, modification, value change
*/
unsigned char mods[];
};
/**@brief Default mutation profile */
extern const rpn_mutation_profile_t rpn_default_mutprof;
/**@brief Shortcut for @ref rpn_expr_mutation_p with a @ref rpn_default_mutprof
* @ingroup mutation */
rpn_expr_t* rpn_expr_mutation(rpn_expr_t *src, size_t mutations);
/**@brief Generate a new expression by applying mutations to a source
* expression
* @param src Source expression
* @param mutations number of mutations
* @param prof Mutation profile
* @return A new instance of rpn_expr_t ready to be evaluate
* @ingroup mutation
*/
rpn_expr_t* rpn_expr_mutation_p(rpn_expr_t *src, size_t mutations,
const rpn_mutation_profile_t *prof);
#endif