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//
11
12#ifndef MCRL2_PROCESS_PARSE_IMPL_H
13#define MCRL2_PROCESS_PARSE_IMPL_H
14
18
19namespace mcrl2 {
20
21namespace process {
22
24{
27 std::vector<process::process_equation> equations;
29
31 {
34 result.global_variables() = std::set<data::variable>(global_variables.begin(), global_variables.end());
36 result.equations() = equations;
37 result.init() = init;
38 return result;
39 }
40};
41
42namespace detail
43{
44
46{
48 : data::detail::data_specification_actions(parser_)
49 {}
50
52 {
54 }
55
57 {
58 return parse_list<data::untyped_data_parameter>(node, "Action", [&](const core::parse_node& node) { return parse_Action(node); });
59 }
60
61 bool callback_ActDecl(const core::parse_node& node, action_label_vector& result) const
62 {
63 if (symbol_name(node) == "ActDecl")
64 {
67 if (node.child(1).child(0))
68 {
69 sorts = parse_SortProduct(node.child(1).child(0).child(1));
70 }
71 for (const core::identifier_string& id: ids)
72 {
73 result.push_back(action_label(id, sorts));
74 }
75 return true;
76 }
77 return false;
78 };
79
81 {
83 traverse(node, [&](const core::parse_node& node) { return callback_ActDecl(node, result); });
84 return process::action_label_list(result.begin(), result.end());
85 }
86
88 {
89 return parse_ActDeclList(node.child(1));
90 }
91};
92
94{
95 explicit process_actions(const core::parser& parser_)
96 : process::detail::action_actions(parser_)
97 {}
98
100 {
101 return parse_IdList(node.child(1));
102 }
103
105 {
107 }
108
110 {
111 return parse_list<process::action_name_multiset>(node, "MultActId", [&](const core::parse_node& node) { return parse_MultActId(node); });
112 }
113
115 {
116 return parse_MultActIdList(node.child(1));
117 }
118
120 {
123 ids.push_front(id);
124 action_name_multiset lhs(ids);
126 return process::communication_expression(lhs, rhs);
127 }
128
130 {
131 return parse_list<process::communication_expression>(node, "CommExpr", [&](const core::parse_node& node) { return parse_CommExpr(node); });
132 }
133
135 {
136 return parse_CommExprList(node.child(1));
137 }
138
140 {
141 return process::rename_expression(parse_Id(node.child(0)), parse_Id(node.child(2)));
142 }
143
145 {
146 return parse_list<process::rename_expression>(node, "RenExpr", [&](const core::parse_node& node) { return parse_RenExpr(node); });
147 }
148
150 {
151 return parse_RenExprList(node.child(1));
152 }
153
154 bool is_proc_expr_sum(const core::parse_node& node) const
155 {
156 return (symbol_name(node).find("ProcExpr") == 0) && (node.child_count() == 3) && (symbol_name(node.child(0)) == "sum") && (symbol_name(node.child(1)) == "VarsDeclList") && (symbol_name(node.child(2)) == ".");
157 }
158
159 bool is_proc_expr_if(const core::parse_node& node) const
160 {
161 return (symbol_name(node).find("ProcExpr") == 0) && (node.child_count() == 2) && (symbol_name(node.child(0)) == "DataExprUnit") && (node.child(1).string() == "->");
162 }
163
164 bool is_proc_expr_else(const core::parse_node& node) const
165 {
166 return (symbol_name(node).find("ProcExpr") == 0) && (node.child_count() == 3) && is_proc_expr_if(node.child(0)) && (symbol_name(node.child(1)) == "ProcExpr") && (node.child(2).string() == "<>");
167 }
168
170 {
171 return (symbol_name(node).find("ProcExpr") == 0) && (node.child_count() == 6) && (symbol_name(node.child(0)) == "dist") && (symbol_name(node.child(1)) == "VarsDeclList") &&
172 (symbol_name(node.child(2)) == "[") && (symbol_name(node.child(3)) == "DataExpr") && (symbol_name(node.child(4)) == "]") && (symbol_name(node.child(5)) == ".");
173 }
174
175 // override
177 {
179 }
180
182 {
183 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Action")) { return parse_Action(node.child(0)); }
184 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "Id") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(3)) == ")")) { return untyped_process_assignment(parse_Id(node.child(0)), parse_AssignmentList(node.child(2))); }
185 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "delta")) { return delta(); }
186 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "tau")) { return tau(); }
187 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "block") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "ActIdSet") && (symbol_name(node.child(3)) == ",") && (symbol_name(node.child(4)) == "ProcExpr") && (symbol_name(node.child(5)) == ")")) { return process::block(parse_ActIdSet(node.child(2)), parse_ProcExpr(node.child(4))); }
188 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "allow") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "MultActIdSet") && (symbol_name(node.child(3)) == ",") && (symbol_name(node.child(4)) == "ProcExpr") && (symbol_name(node.child(5)) == ")")) { return process::allow(parse_MultActIdSet(node.child(2)), parse_ProcExpr(node.child(4))); }
189 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "hide") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "ActIdSet") && (symbol_name(node.child(3)) == ",") && (symbol_name(node.child(4)) == "ProcExpr") && (symbol_name(node.child(5)) == ")")) { return process::hide(parse_ActIdSet(node.child(2)), parse_ProcExpr(node.child(4))); }
190 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "rename") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "RenExprSet") && (symbol_name(node.child(3)) == ",") && (symbol_name(node.child(4)) == "ProcExpr") && (symbol_name(node.child(5)) == ")")) { return process::rename(parse_RenExprSet(node.child(2)), parse_ProcExpr(node.child(4))); }
191 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "comm") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "CommExprSet") && (symbol_name(node.child(3)) == ",") && (symbol_name(node.child(4)) == "ProcExpr") && (symbol_name(node.child(5)) == ")")) { return process::comm(parse_CommExprSet(node.child(2)), parse_ProcExpr(node.child(4))); }
192 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "(") && (symbol_name(node.child(1)) == "ProcExpr") && (symbol_name(node.child(2)) == ")")) { return parse_ProcExpr(node.child(1)); }
193 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "+") && (symbol_name(node.child(2)) == "ProcExpr")) { return choice(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
194 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "||") && (symbol_name(node.child(2)) == "ProcExpr")) { return merge(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
195 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "||_") && (symbol_name(node.child(2)) == "ProcExpr")) { return left_merge(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
196 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == ".") && (symbol_name(node.child(2)) == "ProcExpr")) { return seq(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
197 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "<<") && (symbol_name(node.child(2)) == "ProcExpr")) { return bounded_init(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
198 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "@") && (symbol_name(node.child(2)) == "DataExprUnit")) { return at(parse_ProcExpr(node.child(0)), parse_DataExprUnit(node.child(2))); }
199 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "ProcExpr") && (node.child(1).string() == "|") && (symbol_name(node.child(2)) == "ProcExpr")) { return sync(parse_ProcExpr(node.child(0)), parse_ProcExpr(node.child(2))); }
200 else if ((node.child_count() == 2) && is_proc_expr_if(node.child(0)) && (symbol_name(node.child(1)) == "ProcExpr")) { return if_then(parse_DataExprUnit(node.child(0).child(0)), parse_ProcExpr(node.child(1))); }
201 else if ((node.child_count() == 2) && is_proc_expr_else(node.child(0)) && (symbol_name(node.child(1)) == "ProcExpr")) { return if_then_else(parse_DataExprUnit(node.child(0).child(0).child(0)), parse_ProcExpr(node.child(0).child(1)), parse_ProcExpr(node.child(1))); }
202 else if ((node.child_count() == 2) && is_proc_expr_sum(node.child(0)) && (symbol_name(node.child(1)) == "ProcExpr")) { return sum(parse_VarsDeclList(node.child(0).child(1)), parse_ProcExpr(node.child(1))); }
203 else if ((node.child_count() == 2) && is_proc_expr_stochastic_operator(node.child(0)) && (symbol_name(node.child(1)) == "ProcExpr")) { return stochastic_operator(parse_VarsDeclList(node.child(0).child(1)), parse_DataExpr(node.child(0).child(3)), parse_ProcExpr(node.child(1))); }
205 }
206
208 {
209 core::identifier_string name = parse_Id(node.child(0));
210 data::variable_list variables = parse_VarsDeclList(node.child(1));
211 process_identifier id(name, variables);
212 return process::process_equation(id, variables, parse_ProcExpr(node.child(3)));
213 }
214
215 std::vector<process::process_equation> parse_ProcDeclList(const core::parse_node& node) const
216 {
217 return parse_vector<process::process_equation>(node, "ProcDecl", [&](const core::parse_node& node) { return parse_ProcDecl(node); });
218 }
219
220 std::vector<process::process_equation> parse_ProcSpec(const core::parse_node& node) const
221 {
222 return parse_ProcDeclList(node.child(1));
223 }
224
226 {
227 return parse_ProcExpr(node.child(1));
228 }
229
231 {
232 if (symbol_name(node) == "SortSpec")
233 {
234 return callback_DataSpecElement(node, result);
235 }
236 else if (symbol_name(node) == "ConsSpec")
237 {
238 return callback_DataSpecElement(node, result);
239 }
240 else if (symbol_name(node) == "MapSpec")
241 {
242 return callback_DataSpecElement(node, result);
243 }
244 else if (symbol_name(node) == "EqnSpec")
245 {
246 return callback_DataSpecElement(node, result);
247 }
248 else if (symbol_name(node) == "GlobVarSpec")
249 {
250 result.global_variables = parse_GlobVarSpec(node);
251 return true;
252 }
253 else if (symbol_name(node) == "ActSpec")
254 {
255 result.action_labels = result.action_labels + parse_ActSpec(node);
256 return true;
257 }
258 else if (symbol_name(node) == "ProcSpec")
259 {
260 std::vector<process::process_equation> eqn = parse_ProcSpec(node);
261 result.equations.insert(result.equations.end(), eqn.begin(), eqn.end());
262 return true;
263 }
264 else if (symbol_name(node) == "Init")
265 {
266 result.init = parse_Init(node);
267 }
268 return false;
269 }
270
272 {
274 traverse(node, [&](const core::parse_node& node) { return callback_mCRL2Spec(node, result); });
275 return result;
276 }
277};
278
279} // namespace detail
280
281} // namespace process
282
283} // namespace mcrl2
284
285#endif // MCRL2_PROCESS_PARSE_IMPL_H
Term containing a string.
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:282
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
\brief An action label
\brief A multiset of action names
\brief The allow operator
\brief The at operator
\brief The block operator
\brief The bounded initialization
\brief The choice operator
\brief The communication operator
\brief The value delta
\brief The hide operator
\brief The if-then-else operator
\brief The if-then operator
\brief The left merge operator
\brief The merge operator
\brief A process equation
\brief A process expression
\brief A process identifier
Process specification consisting of a data specification, action labels, a sequence of process equati...
const std::vector< process_equation > & equations() const
Returns the equations of the process specification.
const process_expression & init() const
Returns the initialization of the process specification.
const data::data_specification & data() const
Returns the data specification.
const process::action_label_list & action_labels() const
Returns the action label specification.
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the process specification.
\brief A rename expression
\brief The rename operator
\brief The sequential composition
\brief The distribution operator
\brief The sum operator
\brief The synchronization operator
\brief The value tau
\brief An untyped process assginment
add your file description here.
atermpp::term_list< action_label > action_label_list
\brief list of action_labels
std::vector< action_label > action_label_vector
\brief vector of action_labels
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.
add your file description here.
core::identifier_string parse_Id(const parse_node &node) const
Definition parse.h:233
core::identifier_string_list parse_IdList(const parse_node &node) const
Definition parse.h:243
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 string() const
Definition dparser.cpp:53
std::string symbol_name(const parse_node &node) const
Definition parse.h:205
void traverse(const parse_node &node, const Function &f) const
Definition parse.h:93
const parser & m_parser
Definition parse.h:85
Wrapper for D_Parser and its corresponding D_ParserTables.
Definition dparser.h:148
data::variable_list parse_VarsDeclList(const core::parse_node &node) const
Definition parse_impl.h:204
data::data_expression_list parse_DataExprList(const core::parse_node &node) const
Definition parse_impl.h:287
data::untyped_identifier_assignment_list parse_AssignmentList(const core::parse_node &node) const
Definition parse_impl.h:282
data::data_expression parse_DataExprUnit(const core::parse_node &node) const
Definition parse_impl.h:258
data::data_expression parse_DataExpr(const core::parse_node &node) const
Definition parse_impl.h:211
data::variable_list parse_GlobVarSpec(const core::parse_node &node) const
Definition parse_impl.h:373
data_specification_actions(const core::parser &parser_)
Definition parse_impl.h:300
bool callback_DataSpecElement(const core::parse_node &node, untyped_data_specification &result) const
Definition parse_impl.h:413
data::sort_expression_list parse_SortProduct(const core::parse_node &node) const
Definition parse_impl.h:87
action_actions(const core::parser &parser_)
Definition parse_impl.h:47
action_label_list parse_ActSpec(const core::parse_node &node) const
Definition parse_impl.h:87
data::untyped_data_parameter parse_Action(const core::parse_node &node) const
Definition parse_impl.h:51
bool callback_ActDecl(const core::parse_node &node, action_label_vector &result) const
Definition parse_impl.h:61
data::untyped_data_parameter_list parse_ActionList(const core::parse_node &node) const
Definition parse_impl.h:56
action_label_list parse_ActDeclList(const core::parse_node &node) const
Definition parse_impl.h:80
process::action_name_multiset parse_MultActId(const core::parse_node &node) const
Definition parse_impl.h:104
bool callback_mCRL2Spec(const core::parse_node &node, untyped_process_specification &result) const
Definition parse_impl.h:230
process::process_equation parse_ProcDecl(const core::parse_node &node) const
Definition parse_impl.h:207
bool is_proc_expr_stochastic_operator(const core::parse_node &node) const
Definition parse_impl.h:169
bool is_proc_expr_if(const core::parse_node &node) const
Definition parse_impl.h:159
bool is_proc_expr_else(const core::parse_node &node) const
Definition parse_impl.h:164
process::rename_expression_list parse_RenExprSet(const core::parse_node &node) const
Definition parse_impl.h:149
untyped_process_specification parse_mCRL2Spec(const core::parse_node &node) const
Definition parse_impl.h:271
process::action_name_multiset_list parse_MultActIdList(const core::parse_node &node) const
Definition parse_impl.h:109
process::action_name_multiset_list parse_MultActIdSet(const core::parse_node &node) const
Definition parse_impl.h:114
data::untyped_data_parameter parse_Action(const core::parse_node &node) const
Definition parse_impl.h:176
process::communication_expression_list parse_CommExprList(const core::parse_node &node) const
Definition parse_impl.h:129
process::communication_expression_list parse_CommExprSet(const core::parse_node &node) const
Definition parse_impl.h:134
process::rename_expression parse_RenExpr(const core::parse_node &node) const
Definition parse_impl.h:139
bool is_proc_expr_sum(const core::parse_node &node) const
Definition parse_impl.h:154
process::communication_expression parse_CommExpr(const core::parse_node &node) const
Definition parse_impl.h:119
std::vector< process::process_equation > parse_ProcSpec(const core::parse_node &node) const
Definition parse_impl.h:220
std::vector< process::process_equation > parse_ProcDeclList(const core::parse_node &node) const
Definition parse_impl.h:215
process::process_expression parse_ProcExpr(const core::parse_node &node) const
Definition parse_impl.h:181
process_actions(const core::parser &parser_)
Definition parse_impl.h:95
process::process_expression parse_Init(const core::parse_node &node) const
Definition parse_impl.h:225
core::identifier_string_list parse_ActIdSet(const core::parse_node &node) const
Definition parse_impl.h:99
process::rename_expression_list parse_RenExprList(const core::parse_node &node) const
Definition parse_impl.h:144
std::vector< process::process_equation > equations
Definition parse_impl.h:27
process_specification construct_process_specification()
Definition parse_impl.h:30