mCRL2
Loading...
Searching...
No Matches
parse_impl.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
9/// \file mcrl2/pbes/parse_impl.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_PARSE_IMPL_H
13#define MCRL2_PBES_PARSE_IMPL_H
14
15#include "mcrl2/data/detail/parse_substitution.h"
16#include "mcrl2/data/parse_impl.h"
17#include "mcrl2/pbes/typecheck.h"
18#include "mcrl2/pbes/untyped_pbes.h"
19
20namespace mcrl2 {
21
22namespace pbes_system {
23
24namespace detail
25{
26
28{
29 explicit pbes_actions(const core::parser& parser_)
31 {}
32
34 {
35 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "DataValExpr")) { return parse_DataValExpr(node.child(0)); }
36 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "DataExpr")) { return parse_DataExpr(node.child(0)); }
37 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "true")) { return pbes_system::true_(); }
38 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "false")) { return pbes_system::false_(); }
39 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "forall") && (symbol_name(node.child(1)) == "VarsDeclList") && (symbol_name(node.child(2)) == ".") && (symbol_name(node.child(3)) == "PbesExpr")) { return pbes_system::forall(parse_VarsDeclList(node.child(1)), parse_PbesExpr(node.child(3))); }
40 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "exists") && (symbol_name(node.child(1)) == "VarsDeclList") && (symbol_name(node.child(2)) == ".") && (symbol_name(node.child(3)) == "PbesExpr")) { return pbes_system::exists(parse_VarsDeclList(node.child(1)), parse_PbesExpr(node.child(3))); }
41 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "!") && (symbol_name(node.child(1)) == "PbesExpr")) { return pbes_system::not_(parse_PbesExpr(node.child(1))); }
42 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "PbesExpr") && (node.child(1).string() == "=>") && (symbol_name(node.child(2)) == "PbesExpr")) { return pbes_system::imp(parse_PbesExpr(node.child(0)), parse_PbesExpr(node.child(2))); }
43 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "PbesExpr") && (node.child(1).string() == "&&") && (symbol_name(node.child(2)) == "PbesExpr")) { return pbes_system::and_(parse_PbesExpr(node.child(0)), parse_PbesExpr(node.child(2))); }
44 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "PbesExpr") && (node.child(1).string() == "||") && (symbol_name(node.child(2)) == "PbesExpr")) { return pbes_system::or_(parse_PbesExpr(node.child(0)), parse_PbesExpr(node.child(2))); }
45 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "(") && (symbol_name(node.child(1)) == "PbesExpr") && (symbol_name(node.child(2)) == ")")) { return parse_PbesExpr(node.child(1)); }
46 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "PropVarInst")) { return parse_PropVarInst(node.child(0)); }
47 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "Id")) { return data::untyped_data_parameter(parse_Id(node.child(0)), parse_DataExprList(node.child(1))); }
49 }
50
52 {
53 return pbes_system::propositional_variable(parse_Id(node.child(0)), parse_VarsDeclList(node.child(1)));
54 }
55
57 {
58 return pbes_system::propositional_variable_instantiation(parse_Id(node.child(0)), parse_DataExprList(node.child(1)));
59 }
60
62 {
64 }
65
67 {
68 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "mu")) { return fixpoint_symbol::mu(); }
69 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "nu")) { return fixpoint_symbol::nu(); }
71 }
72
74 {
76 }
77
79 {
80 return parse_vector<pbes_equation>(node, "PbesEqnDecl", [&](const core::parse_node& node) { return parse_PbesEqnDecl(node); });
81 }
82
84 {
85 return parse_PbesEqnDeclList(node.child(1));
86 }
87
89 {
90 untyped_pbes result;
91 result.dataspec = parse_DataSpec(node.child(0));
92 result.global_variables = parse_GlobVarSpec(node.child(1));
93 result.equations = parse_PbesEqnSpec(node.child(2));
95 return result;
96 }
97};
98
99} // namespace detail
100
101} // namespace pbes_system
102
103} // namespace mcrl2
104
105#endif // MCRL2_PBES_PARSE_IMPL_H
bool operator!=(const unprotected_aterm_core &t) const
Inequality operator on two unprotected aterms.
Definition aterm_core.h:92
parse_node_unexpected_exception(const parser &p, const parse_node &node)
Definition parse.h:78
Components for generating an arbitrary element of a sort.
representative_generator(const data_specification &specification)
Constructor with data specification as context.
\brief A data variable
Definition variable.h:28
logger(const log_level_t l)
Default constructor.
Definition logger.h:164
\brief The and operator for pbes expressions
and_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
\brief The existential quantification operator for pbes expressions
const data::variable_list & variables() const
static fixpoint_symbol nu()
Returns the nu symbol.
static fixpoint_symbol mu()
Returns the mu symbol.
\brief The universal quantification operator for pbes expressions
const data::variable_list & variables() const
\brief The implication operator for pbes expressions
imp(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
\brief The not operator for pbes expressions
not_(const pbes_expression &operand)
\brief Constructor Z14.
\brief The or operator for pbes expressions
or_(const pbes_expression &left, const pbes_expression &right)
\brief Constructor Z14.
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
pbes_equation(const fixpoint_symbol &symbol, const propositional_variable &variable, const pbes_expression &expr)
Constructor.
bool is_solved() const
Returns true if the predicate formula on the right hand side contains no predicate variables.
Definition pbes.cpp:103
const propositional_variable & variable() const
Returns the pbes variable of the equation.
parameterized boolean equation system
Definition pbes.h:58
std::set< propositional_variable_instantiation > occurring_variable_instantiations() const
Returns the set of occurring propositional variable instantiations of the pbes. This is the set of va...
Definition pbes.cpp:108
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
propositional_variable_instantiation & operator=(propositional_variable_instantiation &&) noexcept=default
\brief A propositional variable declaration
const data::variable_list & parameters() const
const core::identifier_string & name() const
D_ParserTables parser_tables_mcrl2
Definition dparser.cpp:20
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
void syntax_error_fn(struct D_Parser *ap)
Custom syntax error function that prints both the line number and the column.
Definition dparser.cpp:463
D_ParseNode * ambiguity_fn(struct D_Parser *, int n, struct D_ParseNode **v)
Function for resolving parser ambiguities.
Definition dparser.cpp:332
atermpp::aterm_string identifier_string
String type of the LPS library. Identifier strings are represented internally as ATerms.
void warn_and_or(const parse_node &)
Prints a warning for each occurrence of 'x && y || z' in the parse tree.
bool equal_sorts(const data::variable_list &v, const data::data_expression_list &w, const data::data_specification &data_spec)
Checks if the sorts of the variables/expressions in both lists are equal.
Definition equal_sorts.h:28
Namespace for all data library functionality.
Definition data.cpp:22
const data_expression & false_()
Definition consistency.h:99
const data_expression & true_()
Definition consistency.h:92
atermpp::term_list< variable > variable_list
\brief list of variables
void instantiate_global_variables(pbes &p)
Attempts to eliminate the free variables of a PBES, by substituting a constant value for them....
Definition pbes.cpp:65
bool is_bes(const pbes &x)
Returns true if a PBES is in BES form.
Definition pbes.cpp:70
untyped_pbes parse_pbes_new(const std::string &text)
Definition pbes.cpp:133
bool has_quantifier_name_clashes(const pbes_expression &x)
void replace_global_variables(pbes &p, const data::mutable_map_substitution<> &sigma)
Applies a global variable substitution to a PBES.
void complete_pbes(pbes &x)
Definition pbes.cpp:144
data::mutable_map_substitution instantiate_global_variables(pbes &p)
Eliminates the global variables of a PBES, by substituting a constant value for them....
bool is_well_typed_pbes(const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const std::set< data::variable > &occurring_global_variables, const std::set< propositional_variable > &declared_variables, const std::set< propositional_variable_instantiation > &occ, const propositional_variable_instantiation &init, const data::data_specification &data_spec)
bool has_conflicting_type(Iter first, Iter last, const propositional_variable_instantiation &v, const data::data_specification &data_spec)
Checks if the propositional variable instantiation v has a conflict with the sequence of propositiona...
bool has_propositional_variables(const pbes_expression &x)
propositional_variable parse_propositional_variable(const std::string &text)
Definition pbes.cpp:151
std::set< data::variable > find_quantifier_variables(const pbes_expression &x)
pbes_expression parse_pbes_expression(const std::string &text)
Definition pbes.cpp:160
bool is_well_typed(const pbes_equation &eqn)
Checks if the equation is well typed.
bool is_well_typed_equation(const pbes_equation &eqn, const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const data::data_specification &data_spec)
pbes_expression parse_pbes_expression_new(const std::string &text)
Definition pbes.cpp:122
The main namespace for the PBES library.
atermpp::term_list< pbes_expression > pbes_expression_list
\brief list of pbes_expressions
std::string pp(const pbes_system::forall &x)
Definition pbes.cpp:38
std::set< data::variable > find_free_variables(const pbes_system::pbes_equation &x)
Definition pbes.cpp:56
bool is_bes(const T &x)
Returns true if a PBES object is in BES form.
Definition is_bes.h:76
std::string pp(const pbes_system::pbes_equation &x)
Definition pbes.cpp:43
std::string pp(const pbes_system::and_ &x)
Definition pbes.cpp:35
std::set< data::variable > find_free_variables(const pbes_system::pbes &x)
Definition pbes.cpp:54
void normalize_sorts(pbes_system::pbes_equation_vector &x, const data::sort_specification &sortspec)
Definition pbes.cpp:47
pbes_system::pbes_expression normalize_sorts(const pbes_system::pbes_expression &x, const data::sort_specification &sortspec)
Definition pbes.cpp:49
std::set< data::sort_expression > find_sort_expressions(const pbes_system::pbes &x)
Definition pbes.cpp:52
const pbes_expression & true_()
std::string pp(const pbes_system::propositional_variable_instantiation_list &x)
Definition pbes.cpp:33
std::string pp(const pbes_system::pbes_expression_list &x)
Definition pbes.cpp:29
std::string pp(const pbes_system::or_ &x)
Definition pbes.cpp:41
std::set< pbes_system::propositional_variable_instantiation > find_propositional_variable_instantiations(const pbes_system::pbes_expression &x)
Definition pbes.cpp:58
std::vector< propositional_variable_instantiation > propositional_variable_instantiation_vector
\brief vector of propositional_variable_instantiations
std::string pp(const pbes_system::propositional_variable &x)
Definition pbes.cpp:45
std::vector< propositional_variable > propositional_variable_vector
\brief vector of propositional_variables
void normalize_sorts(pbes_system::pbes &x, const data::sort_specification &)
Definition pbes.cpp:48
std::string pp(const pbes_system::propositional_variable_instantiation &x)
Definition pbes.cpp:46
atermpp::term_list< propositional_variable_instantiation > propositional_variable_instantiation_list
\brief list of propositional_variable_instantiations
std::string pp(const pbes_system::fixpoint_symbol &x)
Definition pbes.cpp:37
bool is_well_typed_pbes(const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const std::set< data::variable > &occurring_global_variables, const std::set< propositional_variable > &declared_variables, const std::set< propositional_variable_instantiation > &occ, const propositional_variable_instantiation &init, const data::data_specification &data_spec)
Definition pbes.cpp:91
std::string pp(const pbes_system::pbes_equation_vector &x)
Definition pbes.cpp:28
std::set< data::function_symbol > find_function_symbols(const pbes_system::pbes &x)
Definition pbes.cpp:57
std::vector< pbes_equation > pbes_equation_vector
\brief vector of pbes_equations
void typecheck_pbes(pbes &pbesspec)
Type check a parsed mCRL2 pbes specification. Throws an exception if something went wrong.
Definition typecheck.h:275
std::string pp(const pbes_system::pbes_expression &x)
Definition pbes.cpp:44
bool is_well_typed(const pbes_equation &eqn)
Definition pbes.cpp:77
std::set< data::variable > find_free_variables(const pbes_system::pbes_expression &x)
Definition pbes.cpp:55
pbes_system::pbes_expression translate_user_notation(const pbes_system::pbes_expression &x)
Definition pbes.cpp:51
std::vector< pbes_expression > pbes_expression_vector
\brief vector of pbes_expressions
std::string pp(const pbes_system::pbes &x)
Definition pbes.cpp:42
bool search_variable(const pbes_system::pbes_expression &x, const data::variable &v)
Definition pbes.cpp:60
std::string pp(const pbes_system::imp &x)
Definition pbes.cpp:39
std::set< data::variable > find_all_variables(const pbes_system::pbes &x)
Definition pbes.cpp:53
std::string pp(const pbes_system::exists &x)
Definition pbes.cpp:36
atermpp::term_list< propositional_variable > propositional_variable_list
\brief list of propositional_variables
void complete_data_specification(pbes &)
Adds all sorts that appear in the PBES p to the data specification of p.
Definition pbes.h:314
std::set< core::identifier_string > find_identifiers(const pbes_system::pbes_expression &x)
Definition pbes.cpp:59
bool is_well_typed_equation(const pbes_equation &eqn, const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const data::data_specification &data_spec)
Definition pbes.cpp:82
void translate_user_notation(pbes_system::pbes &x)
Definition pbes.cpp:50
std::string pp(const pbes_system::not_ &x)
Definition pbes.cpp:40
std::string pp(const pbes_system::propositional_variable_list &x)
Definition pbes.cpp:31
const pbes_expression & false_()
Wrapper for D_ParseNode.
Definition dparser.h:86
parse_node child(int i) const
Definition dparser.cpp:43
int child_count() const
Definition dparser.cpp:37
std::string symbol_name(const parse_node &node) const
Definition parse.h:205
const parser & m_parser
Definition parse.h:85
Wrapper for D_Parser and its corresponding D_ParserTables.
Definition dparser.h:148
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...
Definition dparser.cpp:209
parser(D_ParserTables &tables, D_AmbiguityFn ambiguity_fn=nullptr, D_SyntaxErrorFn syntax_error_fn=nullptr, std::size_t max_error_message_count=1)
Definition dparser.cpp:174
unsigned int start_symbol_index(const std::string &name) const
Definition dparser.cpp:204
data::data_expression parse_DataValExpr(const core::parse_node &node) const
Definition parse_impl.h:272
data::data_expression parse_DataExpr(const core::parse_node &node) const
Definition parse_impl.h:211
data_specification_actions(const core::parser &parser_)
Definition parse_impl.h:300
untyped_data_specification parse_DataSpec(const core::parse_node &node) const
Definition parse_impl.h:461
Visitor for collecting the quantifier variables that occur in a pbes expression.
pbes_expression_traverser< find_quantifier_variables_traverser > super
pbes_expression_traverser< has_propositional_variables_traverser > super
Visitor for determining if within the scope of a quantifier there are quantifier variables of free va...
void push(const data::variable_list &variables)
Adds variables to the quantifier stack, and adds replacements for the name clashes to replacements.
pbes_expression_traverser< has_quantifier_name_clashes_traverser > super
bool is_in_quantifier_stack(const core::identifier_string &name) const
Returns true if the quantifier_stack contains a data variable with the given name.
std::set< propositional_variable_instantiation > variables
pbes_expression_traverser< occurring_variable_visitor > super
void apply(const propositional_variable_instantiation &x)
pbes_system::propositional_variable_instantiation parse_PropVarInst(const core::parse_node &node) const
Definition parse_impl.h:56
pbes_system::propositional_variable parse_PropVarDecl(const core::parse_node &node) const
Definition parse_impl.h:51
pbes_system::propositional_variable_instantiation parse_PbesInit(const core::parse_node &node) const
Definition parse_impl.h:61
std::vector< pbes_equation > parse_PbesEqnSpec(const core::parse_node &node) const
Definition parse_impl.h:83
pbes_system::fixpoint_symbol parse_FixedPointOperator(const core::parse_node &node) const
Definition parse_impl.h:66
pbes_actions(const core::parser &parser_)
Definition parse_impl.h:29
untyped_pbes parse_PbesSpec(const core::parse_node &node) const
Definition parse_impl.h:88
std::vector< pbes_equation > parse_PbesEqnDeclList(const core::parse_node &node) const
Definition parse_impl.h:78
pbes_equation parse_PbesEqnDecl(const core::parse_node &node) const
Definition parse_impl.h:73
pbes_system::pbes_expression parse_PbesExpr(const core::parse_node &node) const
Definition parse_impl.h:33
propositional_variable_instantiation initial_state
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const