Vcsn
2.3
Be Rational
|
Class random expression generator. More...
#include <random-expression.hh>
Public Types | |
using | expressionset_t = ExpressionSet |
using | expression_t = typename expressionset_t::value_t |
Public Member Functions | |
random_expression_impl (const expressionset_t &rs, const std::string ¶m, RandomGenerator &gen) | |
std::ostream & | print_random_expression (std::ostream &out) const |
Print a random expression string (not parsed, so there might be some syntactic sugar such as <+ ). More... | |
std::string | random_expression_string () const |
A random expression string (not parsed, so there might be some syntactic sugar such as <+ ). More... | |
expression_t | random_expression () const |
A random expression (parsed, so there cannot be syntactic sugar such as <+ ). More... | |
Private Types | |
using | operator_t = std::map< std::string, float > |
using | operator_set_t = std::unordered_set< std::string > |
using | weight_t = std::vector< float > |
Private Member Functions | |
void | parse_param_ (const std::string ¶m) |
void | print_unary_exp_ (std::ostream &out, unsigned length, const std::string &op) const |
Print expression with unary operator. More... | |
void | print_binary_exp_ (std::ostream &out, unsigned length, const std::string &op) const |
Print binary expression with binary operator. More... | |
std::ostream & | print_random_expression_ (std::ostream &out, unsigned length) const |
Private Attributes | |
expressionset_t | rs_ |
unsigned | length_ |
operator_t | operators_ |
operator_set_t | nullary_op_ = { "\\e", "\\z" } |
operator_set_t | unary_op_ = { "!", "{c}", "*", "{T}" } |
operator_set_t | binary_op_ = { "&", "&:", ":", ".", "<+", "%", "+", "{/}", "{\\}" } |
weight_t | weight_ |
RandomGenerator & | gen_ |
Class random expression generator.
Generate a random expression from a context.
ExpressionSet | the expression set type. |
RandomGenerator | the random number engine type. |
Definition at line 29 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expression_t = typename expressionset_t::value_t |
Definition at line 33 of file random-expression.hh.
using vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::expressionset_t = ExpressionSet |
Definition at line 32 of file random-expression.hh.
|
private |
Definition at line 68 of file random-expression.hh.
|
private |
Definition at line 67 of file random-expression.hh.
|
private |
Definition at line 69 of file random-expression.hh.
|
inline |
Definition at line 35 of file random-expression.hh.
|
inlineprivate |
Definition at line 71 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::binary_op_, vcsn::has(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::length_, vcsn::detail::lexical_cast(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::nullary_op_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operators_, vcsn::detail::transform(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::unary_op_, vcsn::detail::v, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_.
|
inlineprivate |
Print binary expression with binary operator.
It is composed of the left and right side, and the operator. The number of symbols is randomly distribued between both side.
Definition at line 120 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_(), vcsn::random_label(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
inline |
Print a random expression string (not parsed, so there might be some syntactic sugar such as <+
).
Definition at line 45 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::length_, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_string().
|
inlineprivate |
Definition at line 138 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::gen_, vcsn::has(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::nullary_op_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::operators_, vcsn::detail::out(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_(), vcsn::random_label(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_, vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::unary_op_, and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::weight_.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_unary_exp_().
|
inlineprivate |
Print expression with unary operator.
Definition at line 98 of file random-expression.hh.
References vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_().
|
inline |
A random expression (parsed, so there cannot be syntactic sugar such as <+
).
Definition at line 61 of file random-expression.hh.
References vcsn::conv(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression_string(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::rs_.
|
inline |
A random expression string (not parsed, so there might be some syntactic sugar such as <+
).
Definition at line 52 of file random-expression.hh.
References vcsn::detail::out(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression().
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression().
|
private |
Definition at line 174 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::parse_param_().
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 169 of file random-expression.hh.
Referenced by vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_binary_exp_(), vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::print_random_expression_(), and vcsn::detail::random_expression_impl< ExpressionSet, RandomGenerator >::random_expression().
|
private |
|
private |