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/lps/parse_impl.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_LPS_PARSE_IMPL_H
13#define MCRL2_LPS_PARSE_IMPL_H
14
15#include "mcrl2/lps/detail/linear_process_conversion_traverser.h"
16#include "mcrl2/lps/typecheck.h"
17#include "mcrl2/process/parse.h"
18#include "mcrl2/process/parse_impl.h"
19
20namespace mcrl2::lps::detail
21{
22
24{
25 explicit multi_action_actions(const core::parser& parser_)
27 {}
28
29 process::untyped_multi_action parse_MultAct(const core::parse_node& node) const
30 {
31 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "tau")) { return process::untyped_multi_action(); }
32 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "ActionList"))
33 {
34 return process::untyped_multi_action(parse_ActionList(node.child(0)));
35 }
37 }
38};
39
41{
42 explicit action_rename_actions(const core::parser& parser_)
44 {}
45
46 // create an action with an incomplete action label
47 process::action parse_Action_as_action(const core::parse_node& node) const
48 {
49 process::action_label label(parse_Id(node.child(0)), {});
50 return process::action(label, parse_DataExprList(node.child(1)));
51 }
52
54 {
55 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Action")) { return parse_Action_as_action(node.child(0)); }
56 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "tau")) { return process::tau(); }
57 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "delta")) { return process::delta(); }
59 }
60
61 lps::action_rename_rule parse_ActionRenameRule(const core::parse_node& node) const
62 {
64 if (node.child(0).child(0))
65 {
66 condition = parse_DataExpr(node.child(0).child(0).child(0));
67 }
68 return action_rename_rule(data::variable_list(), condition, parse_Action_as_action(node.child(1)), parse_ActionRenameRuleRHS(node.child(3)));
69 }
70
72 {
73 return parse_vector<lps::action_rename_rule>(node, "ActionRenameRule", [&](const core::parse_node& node) { return parse_ActionRenameRule(node); });
74 }
75
77 {
78 data::variable_list variables = parse_VarSpec(node.child(0));
79 std::vector<lps::action_rename_rule> rules = parse_ActionRenameRuleList(node.child(2));
80 for (lps::action_rename_rule& rule: rules)
81 {
82 rule.variables() = variables;
83 }
84 return rules;
85 }
86
87 bool callback_ActionRenameSpec(const core::parse_node& node, data::untyped_data_specification& dataspec_result, lps::action_rename_specification& result) const
88 {
89 if (symbol_name(node) == "SortSpec")
90 {
91 return callback_DataSpecElement(node, dataspec_result);
92 }
93 else if (symbol_name(node) == "ConsSpec")
94 {
95 return callback_DataSpecElement(node, dataspec_result);
96 }
97 else if (symbol_name(node) == "MapSpec")
98 {
99 return callback_DataSpecElement(node, dataspec_result);
100 }
101 else if (symbol_name(node) == "EqnSpec")
102 {
103 return callback_DataSpecElement(node, dataspec_result);
104 }
105 else if (symbol_name(node) == "ActSpec")
106 {
107 result.action_labels() = result.action_labels() + parse_ActSpec(node);
108 return true;
109 }
110 else if (symbol_name(node) == "ActionRenameRuleSpec")
111 {
112 std::vector<lps::action_rename_rule> rules = parse_ActionRenameRuleSpec(node);
113 result.rules().insert(result.rules().end(), rules.begin(), rules.end());
114 return true;
115 }
116 return false;
117 }
118
120 {
121 data::untyped_data_specification dataspec_result;
123 traverse(node, [&](const core::parse_node& node) { return callback_ActionRenameSpec(node, dataspec_result, result); });
124 result.data() = dataspec_result.construct_data_specification();
125 return result;
126 }
127};
128
129} // namespace mcrl2::lps::detail
130
131#endif // MCRL2_LPS_PARSE_IMPL_H
parse_node_unexpected_exception(const parser &p, const parse_node &node)
Definition parse.h:76
\brief Assignment of a data expression to a variable
Definition assignment.h:88
const data_expression & rhs() const
Definition assignment.h:119
const variable & lhs() const
Definition assignment.h:114
data_expression & operator=(data_expression &&) noexcept=default
sort_expression sort() const
Returns the sort of the data expression.
Definition data.cpp:107
\brief A sort expression
\brief A data variable
Definition variable.h:25
const sort_expression & sort() const
Definition variable.h:40
action_rename_rule(const data::variable_list &variables, const data::data_expression &condition, const process::action &lhs, const process::process_expression &rhs)
Constructor.
Action rename specification.
process::action_label_list & action_labels()
Returns the sequence of action labels.
LPS summand containing a multi-action.
data::data_expression_list next_state(const data::variable_list &process_parameters) const
Returns the next state corresponding to this summand.
Definition lps.cpp:71
LPS summand containing a deadlock.
Represents a deadlock.
Definition deadlock.h:23
bool has_time() const
Returns true if time is available.
Definition deadlock.h:39
\brief A timed multi-action
bool has_time() const
Returns true if time is available.
multi_action & operator=(multi_action &&) noexcept=default
Linear process specification.
\brief An action label
\brief The value delta
delta()
\brief Default constructor X3.
\brief A process expression
\brief The value tau
tau()
\brief Default constructor X3.
\brief An untyped multi action or data application
untyped_multi_action()
\brief Default constructor X3.
D_ParserTables parser_tables_mcrl2
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:435
static data_specification const & default_specification()
Definition parse.h:28
bool check_assignment_variables(assignment_list const &assignments, variable_list const &variables)
Returns true if the left hand sides of assignments are contained in variables.
Namespace for system defined sort bool_.
Definition bool.h:29
bool is_bool(const sort_expression &e)
Recogniser for sort expression Bool.
Definition bool.h:51
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:74
Namespace for system defined sort real_.
bool is_real(const sort_expression &e)
Recogniser for sort expression Real.
Definition real1.h:55
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
bool is_well_typed(const T &x)
Checks well typedness of an LPS object.
bool check_action_labels(const process::action_list &actions, const std::set< process::action_label > &labels)
Returns true if the labels of the given actions are contained in labels.
multi_action complete_multi_action(process::untyped_multi_action &x, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Definition lps.cpp:148
bool check_action_label_sorts(const process::action_label_list &action_labels, const std::set< data::sort_expression > &sorts)
Returns true if the sorts of the given action labels are contained in sorts.
bool check_well_typedness(const T &x)
Checks well typedness of an LPS object, and will print error messages to stderr.
bool check_action_sorts(const process::action_list &actions, const std::set< data::sort_expression > &sorts)
Returns true if the sorts of the given actions are contained in sorts.
void complete_action_rename_specification(action_rename_specification &x, const lps::stochastic_specification &spec)
Definition lps.cpp:166
process::untyped_multi_action parse_multi_action_new(const std::string &text)
Definition lps.cpp:130
multi_action complete_multi_action(process::untyped_multi_action &x, multi_action_type_checker &typechecker, const data::data_specification &data_spec=data::detail::default_specification())
Definition lps.cpp:140
action_rename_specification parse_action_rename_specification_new(const std::string &text)
Definition lps.cpp:156
The main namespace for the LPS library.
Definition constelm.h:18
std::string pp(const lps::stochastic_specification &x, bool arg0)
Definition lps.cpp:40
std::set< data::variable > find_all_variables(const lps::linear_process &x)
Definition lps.cpp:47
std::string pp(const lps::specification &x, bool arg0)
Definition lps.cpp:35
std::set< data::sort_expression > find_sort_expressions(const lps::stochastic_specification &x)
Definition lps.cpp:46
std::string pp_extended(const lps::stochastic_specification &x, const std::string &process_name, bool precedence_aware=true)
Definition lps.cpp:79
std::set< process::action_label > find_action_labels(const lps::stochastic_specification &x)
Definition lps.cpp:68
std::set< data::variable > find_free_variables(const lps::stochastic_specification &x)
Definition lps.cpp:56
std::string pp(const lps::stochastic_distribution &x, bool arg0)
Definition lps.cpp:37
std::string pp_extended(const stochastic_specification &x, const std::string &process_name, bool precedence_aware, bool summand_numbers)
Definition lps.cpp:98
std::set< data::variable > find_all_variables(const lps::multi_action &x)
Returns all variables inside a multi-action.
Definition lps.cpp:52
std::set< data::variable > find_all_variables(const lps::stochastic_specification &x)
Definition lps.cpp:50
bool check_well_typedness(const specification &x)
Definition lps.cpp:118
std::set< data::variable > find_free_variables(const lps::linear_process &x)
Definition lps.cpp:53
bool check_well_typedness(const linear_process &x)
Definition lps.cpp:108
std::set< data::function_symbol > find_function_symbols(const lps::stochastic_specification &x)
Definition lps.cpp:62
std::string pp_extended(const specification &x, const std::string &process_name, bool precedence_aware, bool summand_numbers)
Definition lps.cpp:88
std::set< process::action_label > find_action_labels(const lps::process_initializer &x)
Definition lps.cpp:66
std::set< data::variable > find_free_variables(const lps::specification &x)
Definition lps.cpp:55
multi_action typecheck_multi_action(process::untyped_multi_action &mult_act, const data::data_specification &data_spec, const process::action_label_list &action_decls)
Type check a multi action Throws an exception if something went wrong.
Definition typecheck.h:125
void normalize_sorts(lps::specification &x, const data::sort_specification &)
Definition lps.cpp:42
std::set< data::variable > find_free_variables(const lps::deadlock &x)
Definition lps.cpp:57
std::string pp(const lps::deadlock_summand &x, bool arg0)
Definition lps.cpp:31
std::set< process::action_label > find_action_labels(const lps::linear_process &x)
Definition lps.cpp:65
lps::multi_action normalize_sorts(const lps::multi_action &x, const data::sort_specification &sortspec)
Definition lps.cpp:41
std::set< data::variable > find_free_variables(const lps::stochastic_linear_process &x)
Definition lps.cpp:54
multi_action typecheck_multi_action(process::untyped_multi_action &mult_act, multi_action_type_checker &typechecker)
Type check a multi action Throws an exception if something went wrong.
Definition typecheck.h:141
std::set< data::function_symbol > find_function_symbols(const lps::specification &x)
Definition lps.cpp:61
std::string pp(const lps::stochastic_linear_process &x, bool arg0)
Definition lps.cpp:38
std::set< data::variable > find_free_variables(const lps::stochastic_process_initializer &x)
Definition lps.cpp:60
std::set< data::variable > find_free_variables(const lps::multi_action &x)
Definition lps.cpp:58
std::string pp(const lps::deadlock &x, bool arg0)
Definition lps.cpp:30
void normalize_sorts(lps::stochastic_specification &x, const data::sort_specification &)
Definition lps.cpp:43
std::set< data::variable > find_free_variables(const lps::process_initializer &x)
Definition lps.cpp:59
std::string pp(const lps::stochastic_action_summand &x, bool arg0)
Definition lps.cpp:36
std::string pp(const lps::stochastic_process_initializer &x, bool arg0)
Definition lps.cpp:39
std::string pp(const lps::linear_process &x, bool arg0)
Definition lps.cpp:32
std::string pp(const lps::multi_action &x, bool arg0)
Definition lps.cpp:33
std::set< data::sort_expression > find_sort_expressions(const lps::specification &x)
Definition lps.cpp:45
std::string pp(const lps::action_summand &x, bool arg0)
Definition lps.cpp:29
std::set< data::variable > find_all_variables(const lps::specification &x)
Definition lps.cpp:49
bool check_well_typedness(const stochastic_specification &x)
Definition lps.cpp:123
std::set< data::variable > find_all_variables(const lps::deadlock &x)
Definition lps.cpp:51
action_rename_specification typecheck_action_rename_specification(const action_rename_specification &arspec, const lps::stochastic_specification &lpsspec)
Type checks an action rename specification.
Definition typecheck.h:154
std::set< data::variable > find_all_variables(const lps::stochastic_linear_process &x)
Definition lps.cpp:48
bool check_well_typedness(const stochastic_linear_process &x)
Definition lps.cpp:113
lps::multi_action translate_user_notation(const lps::multi_action &x)
Definition lps.cpp:44
std::set< core::identifier_string > find_identifiers(const lps::stochastic_specification &x)
Definition lps.cpp:64
std::set< core::identifier_string > find_identifiers(const lps::specification &x)
Definition lps.cpp:63
std::set< process::action_label > find_action_labels(const lps::specification &x)
Definition lps.cpp:67
std::string pp(const lps::process_initializer &x, bool arg0)
Definition lps.cpp:34
The main namespace for the Process library.
core::identifier_string parse_Id(const parse_node &node) const
Definition parse.h:231
const parser & m_parser
Definition parse.h:83
data::data_expression parse_DataExpr(const core::parse_node &node) const
Definition parse_impl.h:208
bool callback_DataSpecElement(const core::parse_node &node, untyped_data_specification &result) const
Definition parse_impl.h:410
std::vector< lps::action_rename_rule > parse_ActionRenameRuleList(const core::parse_node &node) const
Definition parse_impl.h:71
process::action parse_Action_as_action(const core::parse_node &node) const
Definition parse_impl.h:47
bool callback_ActionRenameSpec(const core::parse_node &node, data::untyped_data_specification &dataspec_result, lps::action_rename_specification &result) const
Definition parse_impl.h:87
std::vector< lps::action_rename_rule > parse_ActionRenameRuleSpec(const core::parse_node &node) const
Definition parse_impl.h:76
lps::action_rename_specification parse_ActionRenameSpec(const core::parse_node &node) const
Definition parse_impl.h:119
process::process_expression parse_ActionRenameRuleRHS(const core::parse_node &node) const
Definition parse_impl.h:53
action_rename_actions(const core::parser &parser_)
Definition parse_impl.h:42
lps::action_rename_rule parse_ActionRenameRule(const core::parse_node &node) const
Definition parse_impl.h:61
Function object for applying a substitution to LPS data types.
bool is_well_typed(const linear_process_base< ActionSummand > &p) const
Checks well typedness of a linear process.
bool is_well_typed(const process::action &a) const
Traverses an action.
bool is_well_typed(const action_summand &s) const
Checks well typedness of a summand.
bool check_time(const data::data_expression &t, const std::string &type) const
Checks if the sort of t has type real.
bool is_well_typed(const data::assignment &a) const
Traverses an assignment.
bool check_condition(const data::data_expression &t, const std::string &type) const
Checks if the sort of t has type bool.
bool is_well_typed(const stochastic_specification &spec) const
bool is_well_typed(const data::variable &d) const
Checks well typedness of a variable.
bool check_assignments(const data::assignment_list &l, const std::string &type) const
Checks if the assignments are well typed and have unique left hand sides.
bool is_well_typed(const specification &spec) const
bool is_well_typed(const data::sort_expression &d) const
Checks well typedness of a sort expression.
bool is_well_typed_container(const Container &c) const
Checks well typedness of the elements of a container.
bool is_well_typed(const process::action_label &d) const
Traverses an action label.
bool is_well_typed(const specification_base< LinearProcess, InitialProcessExpression > &spec, const std::set< data::variable > &free_variables) const
Checks well typedness of a linear process specification.
bool is_well_typed(const deadlock &d) const
Checks well typedness of a deadlock.
bool is_well_typed(const data::data_expression &d) const
Checks well typedness of a data expression.
bool is_well_typed(const deadlock_summand &s) const
Checks well typedness of a summand.
bool is_well_typed(const multi_action &a) const
Checks well typedness of a multi-action.
process::untyped_multi_action parse_MultAct(const core::parse_node &node) const
Definition parse_impl.h:29
multi_action_actions(const core::parser &parser_)
Definition parse_impl.h:25
action_actions(const core::parser &parser_)
Definition parse_impl.h:46