12#ifndef MCRL2_CORE_BUILDER_H
13#define MCRL2_CORE_BUILDER_H
15#include "mcrl2/atermpp/aterm_list.h"
23#ifdef MCRL2_DEBUG_EXPRESSION_BUILDER
34
35
36
37
38
39
40template <
typename Derived>
54 void update(T& x,
typename atermpp::disable_if_container<T>::type* =
nullptr)
56 msg(
"non-container visit");
58 static_cast<Derived*>(
this)->apply(result, x);
64 void update(T& x,
typename atermpp::enable_if_container<T>::type* =
nullptr)
66 msg(
"container visit");
69 static_cast<Derived*>(
this)->update(v);
81 static_cast<Derived*>(
this)->update(v);
88 template <
typename T,
typename U>
91 msg(
"term_list traversal");
95 [&](T& result,
const U& v) {
static_cast<Derived*>(
this)->apply(result, v); } );
101template <
template <
class>
class Builder>
114template <
template <
class>
class Builder>
118 return apply_builder<Builder>();
122template <
template <
class>
class Builder,
class Arg1>
138template <
template <
class>
class Builder,
class Arg1>
142 return apply_builder_arg1<Builder, Arg1>(arg1);
146template <
template <
class>
class Builder,
class Arg1,
class Arg2>
162template <
template <
class>
class Builder,
class Arg1,
class Arg2>
166 return apply_builder_arg2<Builder, Arg1, Arg2>(arg1, arg2);
171template <
template <
class>
class Builder,
class Function>
181 using argument_type =
typename Function::argument_type;
182 using result_type =
typename Function::result_type;
186 void apply(T& result,
const argument_type& x)
189 result =
static_cast<T>(
f_(x
));
197template <
template <
class>
class Builder,
class Function>
201 return update_apply_builder<Builder, Function>(f);
205template <
template <
class>
class Builder,
class Function,
class Arg1>
215 using argument_type =
typename Function::argument_type;
216 using result_type =
typename Function::result_type;
220 void apply(T& result,
const argument_type& x)
231template <
template <
class>
class Builder,
class Function,
class Arg1>
235 return update_apply_builder_arg1<Builder, Function, Arg1>(f);
const aterm & operator[](const size_type i) const
Returns the i-th argument.
Builder< apply_builder_arg1< Builder, Arg1 > > super
apply_builder_arg1(const Arg1 &arg1)
apply_builder_arg2(const Arg1 &arg1, const Arg2 &arg2)
Builder< apply_builder_arg2< Builder, Arg1, Arg2 > > super
Builder< apply_builder< Builder > > super
update_apply_builder_arg1(const Function &f, const Arg1 &arg1)
Builder< update_apply_builder_arg1< Builder, Function, Arg1 > > super
void apply(T &result, const argument_type &x)
An abstraction expression.
const variable_list & variables() const
const data_expression & body() const
const basic_sort & name() const
const sort_expression & reference() const
\brief Assignment expression
\brief Assignment of a data expression to a variable
const data_expression & rhs() const
const variable & lhs() const
\brief Binder for bag comprehension
universal quantification.
\brief Container type for bags
container_sort(const container_type &container_name, const sort_expression &element_sort)
\brief Constructor Z14.
const container_type & container_name() const
const sort_expression & element_sort() const
container_sort(const atermpp::aterm &term)
const data_expression & lhs() const
const data_expression & condition() const
const data_expression & rhs() const
const variable_list & variables() const
sort_expression sort() const
Returns the sort of the data expression.
\brief Binder for existential quantification
existential quantification.
\brief Container type for finite bags
\brief Binder for universal quantification
universal quantification.
\brief Container type for finite sets
const sort_expression & codomain() const
const sort_expression_list & domain() const
const core::identifier_string & name() const
const sort_expression & sort() const
\brief Binder for lambda abstraction
\brief Container type for lists
\brief Binder for set comprehension
universal quantification.
\brief Container type for sets
sort_expression & operator=(sort_expression &&) noexcept=default
\brief An argument of a constructor of a structured sort
const core::identifier_string & name() const
const sort_expression & sort() const
\brief A constructor for a structured sort
const core::identifier_string & name() const
const core::identifier_string & recogniser() const
const structured_sort_constructor_argument_list & arguments() const
const structured_sort_constructor_list & constructors() const
\brief An untyped parameter
const core::identifier_string & name() const
const data_expression_list & arguments() const
\brief Assignment of a data expression to a string
const core::identifier_string & lhs() const
const data_expression & rhs() const
\brief An untyped identifier
\brief Multiple possible sorts
const sort_expression_list & sorts() const
\brief Binder for untyped set or bag comprehension
universal quantification.
\brief Untyped sort variable
\brief Unknown sort expression
untyped_sort()
\brief Default constructor X3.
const core::identifier_string & name() const
const sort_expression & sort() const
\brief A where expression
const data_expression & body() const
const assignment_expression_list & declarations() const
D_ParserTables parser_tables_mcrl2
The main namespace for the aterm++ library.
void syntax_error_fn(struct D_Parser *ap)
Custom syntax error function that prints both the line number and the column.
D_ParseNode * ambiguity_fn(struct D_Parser *, int n, struct D_ParseNode **v)
Function for resolving parser ambiguities.
apply_builder< Builder > make_apply_builder()
update_apply_builder_arg1< Builder, Function, Arg1 > make_update_apply_builder_arg1(const Function &f)
void warn_and_or(const parse_node &)
Prints a warning for each occurrence of 'x && y || z' in the parse tree.
apply_builder_arg1< Builder, Arg1 > make_apply_builder_arg1(const Arg1 &arg1)
void msg(const std::string &)
update_apply_builder< Builder, Function > make_update_apply_builder(const Function &f)
apply_builder_arg2< Builder, Arg1, Arg2 > make_apply_builder_arg2(const Arg1 &arg1, const Arg2 &arg2)
data_expression parse_data_expression(const std::string &text)
data_specification parse_data_specification_new(const std::string &text)
variable_list parse_variable_declaration_list(const std::string &text)
variable_list parse_variables(const std::string &text)
sort_expression parse_sort_expression(const std::string &text)
Namespace for system defined sort bool_.
const basic_sort & bool_()
Constructor for sort expression Bool.
Namespace for all data library functionality.
atermpp::term_list< assignment_expression > assignment_expression_list
\brief list of assignment_expressions
std::vector< assignment > assignment_vector
\brief vector of assignments
data::data_equation normalize_sorts(const data::data_equation &x, const data::sort_specification &sortspec)
std::string pp(const data::untyped_set_or_bag_comprehension_binder &x)
std::string pp(const data::set_comprehension_binder &x)
void normalize_sorts(data::data_equation_vector &x, const data::sort_specification &sortspec)
std::string pp(const data::exists &x)
std::string pp(const data::untyped_sort_variable &x)
std::string pp(const data::untyped_set_or_bag_comprehension &x)
std::string pp(const data::assignment_expression &x)
bool is_structured_sort(const atermpp::aterm &x)
Returns true if the term t is a structured sort.
data::data_equation_list normalize_sorts(const data::data_equation_list &x, const data::sort_specification &sortspec)
std::string pp(const data::function_symbol_list &x)
void normalize_sorts(T &x, const data::sort_specification &sort_spec, typename std::enable_if< !std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
variable_list free_variables(const data_expression &x)
std::string pp(const data::set_container &x)
std::string pp(const data::abstraction &x)
std::string pp(const data::application &x)
std::string pp(const data::bag_comprehension_binder &x)
std::set< data::variable > find_all_variables(const data::data_expression_list &x)
std::string pp(const data::fbag_container &x)
std::vector< sort_expression > sort_expression_vector
\brief vector of sort_expressions
std::set< data::sort_expression > find_sort_expressions(const data::data_expression &x)
data::data_equation translate_user_notation(const data::data_equation &x)
std::string pp(const data::untyped_data_parameter &x)
std::string pp(const data::fset_container &x)
bool is_application(const data_expression &t)
Returns true if the term t is an application.
std::vector< alias > alias_vector
\brief vector of aliass
atermpp::term_list< function_symbol > function_symbol_list
\brief list of function_symbols
std::set< data::variable > find_all_variables(const data::data_expression &x)
std::string pp(const data::untyped_identifier_assignment &x)
std::string pp(const data::lambda &x)
std::string pp(const data::container_sort &x)
bool is_where_clause(const atermpp::aterm &x)
Returns true if the term t is a where clause.
bool is_untyped_possible_sorts(const atermpp::aterm &x)
Returns true if the term t is an expression for multiple possible sorts.
bool is_untyped_sort(const atermpp::aterm &x)
Returns true if the term t is the unknown sort.
std::string pp(const data::variable &x)
std::string pp(const data::untyped_sort &x)
std::string pp(const data::machine_number &x)
std::string pp(const data::lambda_binder &x)
data::data_expression translate_user_notation(const data::data_expression &x)
bool is_abstraction(const atermpp::aterm &x)
Returns true if the term t is an abstraction.
std::vector< data_equation > data_equation_vector
\brief vector of data_equations
std::vector< variable > variable_vector
\brief vector of variables
atermpp::term_list< structured_sort_constructor_argument > structured_sort_constructor_argument_list
\brief list of structured_sort_constructor_arguments
bool is_untyped_identifier(const atermpp::aterm &x)
Returns true if the term t is an identifier.
std::string pp(const data::data_equation_list &x)
std::string pp(const data::data_equation &x)
std::string pp(const data::function_sort &x)
atermpp::term_list< sort_expression > sort_expression_list
\brief list of sort_expressions
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::set< data::variable > find_all_variables(const data::function_symbol &x)
std::string pp(const data::bag_comprehension &x)
std::string pp(const data::exists_binder &x)
std::string pp(const data::forall_binder &x)
std::string pp(const data::structured_sort_constructor_list &x)
std::string pp(const data::untyped_possible_sorts &x)
std::string pp(const data::data_expression_list &x)
std::vector< structured_sort_constructor > structured_sort_constructor_vector
\brief vector of structured_sort_constructors
bool is_container_sort(const atermpp::aterm &x)
Returns true if the term t is a container sort.
std::string pp(const data::assignment_list &x)
bool is_forall(const atermpp::aterm &x)
Returns true if the term t is a universal quantification.
bool is_function_symbol(const atermpp::aterm &x)
Returns true if the term t is a function symbol.
atermpp::term_list< data_equation > data_equation_list
\brief list of data_equations
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
std::string pp(const data::structured_sort_constructor &x)
std::string pp(const data::assignment &x)
bool is_basic_sort(const atermpp::aterm &x)
Returns true if the term t is a basic sort.
bool is_untyped_sort_variable(const atermpp::aterm &x)
std::set< data::sort_expression > find_sort_expressions(const data::data_equation &x)
std::set< data::function_symbol > find_function_symbols(const data::data_equation &x)
std::set< data::variable > find_free_variables(const data::data_expression &x)
std::string pp(const data::bag_container &x)
std::set< data::variable > find_all_variables(const data::variable_list &x)
bool is_untyped_set_or_bag_comprehension(const atermpp::aterm &x)
Returns true if the term t is a set/bag comprehension.
T normalize_sorts(const T &x, const data::sort_specification &sort_spec, typename std::enable_if< std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
bool is_assignment(const atermpp::aterm &x)
std::string pp(const data::structured_sort &x)
std::set< data::sort_expression > find_sort_expressions(const data::sort_expression &x)
atermpp::term_list< variable > variable_list
\brief list of variables
std::pair< basic_sort_vector, alias_vector > parse_sort_specification(const std::string &text)
std::string pp(const data::data_specification &x)
data::sort_expression normalize_sorts(const data::sort_expression &x, const data::sort_specification &sortspec)
bool is_exists(const atermpp::aterm &x)
Returns true if the term t is an existential quantification.
std::string pp(const data::container_type &x)
std::string pp(const data::function_symbol &x)
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
std::set< data::variable > find_free_variables(const data::data_expression_list &x)
std::string pp(const data::basic_sort &x)
std::string pp(const data::alias &x)
std::string pp(const data::list_container &x)
std::string pp(const data::forall &x)
atermpp::term_list< assignment > assignment_list
\brief list of assignments
bool is_bag_comprehension(const atermpp::aterm &x)
Returns true if the term t is a bag comprehension.
std::string pp(const data::sort_expression &x)
bool is_set_comprehension(const atermpp::aterm &x)
Returns true if the term t is a set comprehension.
bool is_machine_number(const atermpp::aterm &x)
Returns true if the term t is a machine_number.
data::variable_list normalize_sorts(const data::variable_list &x, const data::sort_specification &sortspec)
data::data_expression normalize_sorts(const data::data_expression &x, const data::sort_specification &sortspec)
std::string pp(const data::structured_sort_constructor_argument &x)
bool is_lambda(const atermpp::aterm &x)
Returns true if the term t is a lambda abstraction.
bool is_untyped_identifier_assignment(const atermpp::aterm &x)
std::set< data::variable > find_all_variables(const data::variable &x)
std::set< core::identifier_string > find_identifiers(const data::variable_list &x)
std::vector< basic_sort > basic_sort_vector
vector of basic sorts
bool search_variable(const data::data_expression &x, const data::variable &v)
std::string pp(const data::set_comprehension &x)
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
std::string pp(const data::variable_list &x)
std::set< data::variable > substitution_variables(const mutable_map_substitution<> &sigma)
std::string pp(const data::where_clause &x)
std::string pp(const data::data_expression &x)
std::string pp(const data::untyped_identifier &x)
bool is_variable(const atermpp::aterm &x)
Returns true if the term t is a variable.
std::string pp(const data::sort_expression_vector &x)
std::string pp(const data::binder_type &x)
atermpp::term_list< structured_sort_constructor > structured_sort_constructor_list
\brief list of structured_sort_constructors
std::string pp(const data::sort_expression_list &x)
expression builder that visits all sub expressions
void update(T &x, typename atermpp::disable_if_container< T >::type *=nullptr)
void apply(atermpp::term_list< T > &result, const atermpp::term_list< U > &x)
void update(std::set< T > &x)
Wrapper for D_Parser and its corresponding D_ParserTables.
parse_node parse(const std::string &text, unsigned int start_symbol_index=0, bool partial_parses=false)
Parses a string. N.B. The user is responsible for destruction of the returned value by calling destro...
parser(D_ParserTables &tables, D_AmbiguityFn ambiguity_fn=nullptr, D_SyntaxErrorFn syntax_error_fn=nullptr, std::size_t max_error_message_count=1)
unsigned int start_symbol_index(const std::string &name) const
void apply(T &result, const argument_type &x)
Builder< update_apply_builder< Builder, Function > > super
update_apply_builder(const Function &f)
void apply(T &result, const data::bag_comprehension &x)
void apply(T &result, const data::machine_number &x)
void apply(T &result, const data::untyped_identifier_assignment &x)
void apply(T &result, const data::assignment_expression &x)
void apply(T &result, const data::untyped_set_or_bag_comprehension &x)
void apply(T &result, const data::untyped_identifier &x)
void apply(T &result, const data::data_equation &x)
void apply(T &result, const data::function_symbol &x)
void apply(T &result, const data::assignment &x)
void apply(T &result, const data::abstraction &x)
void apply(T &result, const data::forall &x)
void apply(T &result, const data::untyped_data_parameter &x)
void apply(T &result, const data::exists &x)
void apply(T &result, const data::where_clause &x)
void apply(T &result, const data::application &x)
void apply(T &result, const data::variable &x)
void apply(T &result, const data::data_expression &x)
void apply(T &result, const data::set_comprehension &x)
void apply(T &result, const data::lambda &x)
void apply(T &result, const data::assignment &x)
void apply(T &result, const data::set_comprehension &x)
void apply(T &result, const data::structured_sort_constructor_argument &x)
void apply(T &result, const data::container_sort &x)
void apply(T &result, const data::alias &x)
void apply(T &result, const data::exists &x)
void apply(T &result, const data::machine_number &x)
void apply(T &result, const data::function_symbol &x)
void apply(T &result, const data::untyped_possible_sorts &x)
void apply(T &result, const data::forall &x)
void apply(T &result, const data::basic_sort &x)
void apply(T &result, const data::data_equation &x)
void apply(T &result, const data::untyped_sort &x)
void apply(T &result, const data::abstraction &x)
void apply(T &result, const data::application &x)
void apply(T &result, const data::variable &x)
void apply(T &result, const data::structured_sort &x)
void apply(T &result, const data::untyped_identifier_assignment &x)
void apply(T &result, const data::untyped_data_parameter &x)
void apply(T &result, const data::function_sort &x)
void apply(T &result, const data::untyped_identifier &x)
void apply(T &result, const data::structured_sort_constructor &x)
void apply(T &result, const data::lambda &x)
void apply(T &result, const data::untyped_set_or_bag_comprehension &x)
void apply(T &result, const data::where_clause &x)
void apply(T &result, const data::assignment_expression &x)
void apply(T &result, const data::data_expression &x)
void apply(T &result, const data::sort_expression &x)
void apply(T &result, const data::untyped_sort_variable &x)
void apply(T &result, const data::bag_comprehension &x)
void apply(T &result, const data::abstraction &x)
void apply(T &result, const data::application &x)
void apply(T &result, const data::untyped_data_parameter &x)
void apply(T &result, const data::untyped_identifier &x)
void apply(T &result, const data::data_expression &x)
void apply(T &result, const data::assignment_expression &x)
void apply(T &result, const data::where_clause &x)
void apply(T &result, const data::forall &x)
void apply(T &result, const data::function_symbol &x)
void apply(T &result, const data::exists &x)
void apply(T &result, const data::lambda &x)
void apply(T &result, const data::variable &x)
void apply(T &result, const data::assignment &x)
void apply(T &result, const data::untyped_identifier_assignment &x)
void apply(T &result, const data::untyped_set_or_bag_comprehension &x)
void apply(T &result, const data::set_comprehension &x)
void apply(T &result, const data::bag_comprehension &x)
void apply(T &result, const data::machine_number &x)
void apply(T &result, const data::data_equation &x)
data_expression_actions(const core::parser &parser_)
data::data_expression parse_DataExpr(const core::parse_node &node) const
data_specification_actions(const core::parser &parser_)
untyped_data_specification parse_DataSpec(const core::parse_node &node) const
normalize_sorts_function(const sort_specification &sort_spec)
sort_expression operator()(const sort_expression &e) const
Normalise sorts.
const std::map< sort_expression, sort_expression > & m_normalised_aliases
data::sort_expression parse_SortExpr(const core::parse_node &node, data::sort_expression_list *product=nullptr) const
data_specification construct_data_specification() const
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const