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_DATA_PARSE_IMPL_H
13#define MCRL2_DATA_PARSE_IMPL_H
14
15#include <climits>
16#include <fstream>
22
23namespace mcrl2 {
24
25namespace data {
26
27namespace detail {
28
30{
31 explicit sort_expression_actions(const core::parser& parser_)
32 : core::default_parser_actions(parser_)
33 {}
34
36 {
37 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Bool")) { return sort_bool::bool_(); }
38 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Pos")) { return sort_pos::pos(); }
39 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Nat")) { return sort_nat::nat(); }
40 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Int")) { return sort_int::int_(); }
41 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Real")) { return sort_real::real_(); }
42 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "List") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ")")) { return sort_list::list(parse_SortExpr(node.child(2))); }
43 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "Set") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ")")) { return sort_set::set_(parse_SortExpr(node.child(2))); }
44 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "FSet") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ")")) { return sort_fset::fset(parse_SortExpr(node.child(2))); }
45 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "Bag") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ")")) { return sort_bag::bag(parse_SortExpr(node.child(2))); }
46 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "FBag") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ")")) { return sort_fbag::fbag(parse_SortExpr(node.child(2))); }
47 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Id")) { return basic_sort(parse_Id(node.child(0))); }
48 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "(") && (symbol_name(node.child(1)) == "SortExpr") && (symbol_name(node.child(2)) == ")")) { return parse_SortExpr(node.child(1), product); }
49 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "struct") && (symbol_name(node.child(1)) == "ConstrDeclList")) { return structured_sort(parse_ConstrDeclList(node.child(1))); }
50 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "SortExpr") && (node.child(1).string() == "->") && (symbol_name(node.child(2)) == "SortExpr")) { return function_sort(parse_SortExpr_as_SortProduct(node.child(0)), parse_SortExpr(node.child(2))); }
51 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "SortExpr") && (node.child(1).string() == "#") && (symbol_name(node.child(2)) == "SortExpr"))
52 {
53 if (product != nullptr)
54 {
55 data::sort_expression new_element = parse_SortExpr(node.child(2), product);
56 if (new_element != data::sort_expression())
57 {
58 product->push_front(new_element);
59 }
60 new_element = parse_SortExpr(node.child(0), product);
61 if (new_element != data::sort_expression())
62 {
63 product->push_front(new_element);
64 }
65 return data::sort_expression();
66 }
67 else
68 {
69 throw core::parse_node_exception(node.child(1), "Sort product is only allowed on the left "
70 "hand side of ->, and when declaring actions.");
71 }
72 }
74 }
75
77 {
79 data::sort_expression new_element = parse_SortExpr(node, &result);
80 if (new_element != data::sort_expression())
81 {
82 result.push_front(new_element);
83 }
84 return result;
85 }
86
88 {
89 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "SortExpr"))
90 {
92 }
94 }
95
97 {
101 if (node.child(1))
102 {
103 arguments = parse_ProjDeclList(node.child(1));
104 }
105 if (node.child(2))
106 {
107 core::parse_node u = node.child(2);
108 if (u.child(0))
109 {
110 recogniser = parse_Id(node.child(2).child(0).child(1));
111 }
112 }
113 return structured_sort_constructor(name, arguments, recogniser);
114 }
115
117 {
118 return parse_list<data::structured_sort_constructor>(node, "ConstrDecl", [&](const core::parse_node& node) { return parse_ConstrDecl(node); });
119 }
120
122 {
124 sort_expression sort = parse_SortExpr(node.child(1));
125 if (node.child(0).child(0))
126 {
127 // TODO: check if this nesting depth is correct
128 name = parse_Id(node.child(0).child(0).child(0));
129 }
130 return structured_sort_constructor_argument(name, sort);
131 }
132
134 {
135 return parse_list<data::structured_sort_constructor_argument>(node, "ProjDecl", [&](const core::parse_node& node) { return parse_ProjDecl(node); });
136 }
137};
138
140{
142 : sort_expression_actions(parser_)
143 {}
144
146 {
148 }
149
151 {
152 assert(!x.empty());
154 }
155
157 {
158 assert(!x.empty());
160 }
161
163 {
164 assert(!x.empty());
166 }
167
169 {
171 }
172
173 template <typename ExpressionContainer>
174 data::sort_expression_list get_sorts(const ExpressionContainer& x) const
175 {
177 for (auto i = x.begin(); i != x.end(); ++i)
178 {
179 result.push_back(i->sort());
180 }
181 return data::sort_expression_list(result.begin(), result.end());
182 }
183
185 {
186 return variable(parse_Id(node.child(0)), parse_SortExpr(node.child(2)));
187 }
188
189 bool callback_VarsDecl(const core::parse_node& node, variable_vector& result) const
190 {
191 if (symbol_name(node) == "VarsDecl")
192 {
195 for (const core::identifier_string& name: names)
196 {
197 result.push_back(variable(name, sort));
198 }
199 return true;
200 }
201 return false;
202 };
203
205 {
206 variable_vector result;
207 traverse(node, [&](const core::parse_node& node) { return callback_VarsDecl(node, result); });
208 return data::variable_list(result.begin(), result.end());
209 }
210
212 {
213 assert(symbol_name(node) == "DataExpr");
214 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Id")) { return untyped_identifier(parse_Id(node.child(0))); }
215 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Number")) { return untyped_identifier(parse_Number(node.child(0))); }
216 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "true")) { return untyped_identifier(parse_Id(node.child(0))); }
217 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "false")) { return untyped_identifier(parse_Id(node.child(0))); }
218 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "[") && (symbol_name(node.child(1)) == "]")) { return untyped_identifier("[]"); }
219 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "{") && (symbol_name(node.child(1)) == "}")) { return untyped_identifier("{}"); }
220 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "{") && (symbol_name(node.child(1)) == ":") && (symbol_name(node.child(2)) == "}")) { return untyped_identifier("{:}"); }
221 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "[") && (symbol_name(node.child(1)) == "DataExprList") && (symbol_name(node.child(2)) == "]")) { return make_list_enumeration(parse_DataExprList(node.child(1))); }
222 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "{") && (symbol_name(node.child(1)) == "BagEnumEltList") && (symbol_name(node.child(2)) == "}")) { return make_bag_enumeration(parse_BagEnumEltList(node.child(1))); }
223 else if ((node.child_count() == 5) && (symbol_name(node.child(0)) == "{") && (symbol_name(node.child(1)) == "VarDecl") && (symbol_name(node.child(2)) == "|") && (symbol_name(node.child(3)) == "DataExpr") && (symbol_name(node.child(4)) == "}")) { return make_untyped_set_or_bag_comprehension(parse_VarDecl(node.child(1)), parse_DataExpr(node.child(3))); }
224 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "{") && (symbol_name(node.child(1)) == "DataExprList") && (symbol_name(node.child(2)) == "}")) { return make_set_enumeration(parse_DataExprList(node.child(1))); }
225 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "(") && (symbol_name(node.child(1)) == "DataExpr") && (symbol_name(node.child(2)) == ")")) { return parse_DataExpr(node.child(1)); }
226 else if ((node.child_count() == 6) && (symbol_name(node.child(0)) == "DataExpr") && (symbol_name(node.child(1)) == "[") && (symbol_name(node.child(2)) == "DataExpr") && (symbol_name(node.child(3)) == "->") && (symbol_name(node.child(4)) == "DataExpr") && (symbol_name(node.child(5)) == "]")) { return make_function_update(parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2)), parse_DataExpr(node.child(4))); }
227 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "DataExpr") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "DataExprList") && (symbol_name(node.child(3)) == ")")) { return application(parse_DataExpr(node.child(0)), parse_DataExprList(node.child(2))); }
228 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "!") && (symbol_name(node.child(1)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExpr(node.child(1))); }
229 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "-") && (symbol_name(node.child(1)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExpr(node.child(1))); }
230 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "#") && (symbol_name(node.child(1)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExpr(node.child(1))); }
231 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)) == "DataExpr")) { return forall(parse_VarsDeclList(node.child(1)), parse_DataExpr(node.child(3))); }
232 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)) == "DataExpr")) { return exists(parse_VarsDeclList(node.child(1)), parse_DataExpr(node.child(3))); }
233 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "lambda") && (symbol_name(node.child(1)) == "VarsDeclList") && (symbol_name(node.child(2)) == ".") && (symbol_name(node.child(3)) == "DataExpr")) { return lambda(parse_VarsDeclList(node.child(1)), parse_DataExpr(node.child(3))); }
234 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "=>") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
235 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "&&") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
236 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "||") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
237 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "==") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
238 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "!=") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
239 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "<") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
240 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "<=") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
241 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == ">=") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
242 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == ">") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
243 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "in") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
244 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "|>") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
245 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "<|") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
246 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "++") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
247 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "+") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
248 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "-") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
249 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "/") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
250 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "div") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
251 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "mod") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
252 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == "*") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
253 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "DataExpr") && (node.child(1).string() == ".") && (symbol_name(node.child(2)) == "DataExpr")) { return application(untyped_identifier(parse_Id(node.child(1))), parse_DataExpr(node.child(0)), parse_DataExpr(node.child(2))); }
254 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "DataExpr") && (symbol_name(node.child(1)) == "whr") && (symbol_name(node.child(2)) == "AssignmentList") && (symbol_name(node.child(3)) == "end")) { return where_clause(parse_DataExpr(node.child(0)), parse_AssignmentList(node.child(2))); }
256 }
257
259 {
260 if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Id")) { return untyped_identifier(parse_Id(node.child(0))); }
261 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "Number")) { return untyped_identifier(parse_Number(node.child(0))); }
262 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "true")) { return untyped_identifier(parse_Id(node.child(0))); }
263 else if ((node.child_count() == 1) && (symbol_name(node.child(0)) == "false")) { return untyped_identifier(parse_Id(node.child(0))); }
264 else if ((node.child_count() == 3) && (symbol_name(node.child(0)) == "(") && (symbol_name(node.child(1)) == "DataExpr") && (symbol_name(node.child(2)) == ")")) { return parse_DataExpr(node.child(1)); }
265 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "DataExprUnit") && (symbol_name(node.child(1)) == "(") && (symbol_name(node.child(2)) == "DataExprList") && (symbol_name(node.child(3)) == ")")) { return application(parse_DataExprUnit(node.child(0)), parse_DataExprList(node.child(2))); }
266 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "!") && (symbol_name(node.child(1)) == "DataExprUnit")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExprUnit(node.child(1))); }
267 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "-") && (symbol_name(node.child(1)) == "DataExprUnit")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExprUnit(node.child(1))); }
268 else if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "#") && (symbol_name(node.child(1)) == "DataExprUnit")) { return application(untyped_identifier(parse_Id(node.child(0))), parse_DataExprUnit(node.child(1))); }
270 }
271
273 {
274 return parse_DataExpr(node.child(2));
275 }
276
278 {
280 }
281
283 {
284 return parse_list<data::untyped_identifier_assignment>(node, "Assignment", [&](const core::parse_node& node) { return parse_Assignment(node); });
285 }
286
288 {
289 return parse_list<data::data_expression>(node, "DataExpr", [&](const core::parse_node& node) { return parse_DataExpr(node); });
290 }
291
293 {
294 return parse_DataExprList(node);
295 }
296};
297
299{
301 : data_expression_actions(parser_)
302 {}
303
304 bool callback_SortDecl(const core::parse_node& node, std::vector<atermpp::aterm>& result) const
305 {
306 if (symbol_name(node) == "SortDecl")
307 {
308 if ((node.child_count() == 2) && (symbol_name(node.child(0)) == "IdList") && (symbol_name(node.child(1)) == ";"))
309 {
311 for (const core::identifier_string& id: ids)
312 {
313 result.push_back(basic_sort(id));
314 }
315 }
316 else if ((node.child_count() == 4) && (symbol_name(node.child(0)) == "Id") && (symbol_name(node.child(1)) == "=") && (symbol_name(node.child(2)) == "SortExpr") && (symbol_name(node.child(3)) == ";"))
317 {
318 result.push_back(alias(basic_sort(parse_Id(node.child(0))), parse_SortExpr(node.child(2))));
319 }
320 else
321 {
323 }
324 return true;
325 }
326 return false;
327 }
328
329 std::vector<atermpp::aterm> parse_SortDeclList(const core::parse_node& node) const
330 {
331 std::vector<atermpp::aterm> result;
332 traverse(node, [&](const core::parse_node& node) { return callback_SortDecl(node, result); });
333 return result;
334 }
335
336 std::vector<atermpp::aterm> parse_SortSpec(const core::parse_node& node) const
337 {
338 return parse_SortDeclList(node.child(1));
339 }
340
342 {
343 if (symbol_name(node) == "IdsDecl")
344 {
347 for (const core::identifier_string& name: names)
348 {
349 result.push_back(function_symbol(name, sort));
350 }
351 return true;
352 }
353 return false;
354 }
355
357 {
359 traverse(node, [&](const core::parse_node& node) { return callback_IdsDecl(node, result); });
360 return result;
361 }
362
364 {
365 return parse_IdsDeclList(node);
366 }
367
369 {
370 return parse_IdsDeclList(node);
371 }
372
374 {
375 return parse_VarsDeclList(node);
376 }
377
379 {
380 return parse_VarsDeclList(node);
381 }
382
383 bool callback_EqnDecl(const core::parse_node& node, const variable_list& variables, data_equation_vector& result) const
384 {
385 if (symbol_name(node) == "EqnDecl")
386 {
387 data_expression condition = sort_bool::true_();
388 // TODO: check if this is the correct nesting depth
389 if (node.child(0).child(0))
390 {
391 condition = parse_DataExpr(node.child(0).child(0).child(0));
392 }
393 result.push_back(data_equation(variables, condition, parse_DataExpr(node.child(1)), parse_DataExpr(node.child(3))));
394 return true;
395 }
396 return false;
397 }
398
400 {
402 traverse(node, [&](const core::parse_node& node) { return callback_EqnDecl(node, variables, result); });
403 return result;
404 }
405
407 {
408 assert(symbol_name(node) == "EqnSpec");
409 variable_list variables = parse_VarSpec(node.child(0));
410 return parse_EqnDeclList(node.child(2), variables);
411 }
412
414 {
415 if (symbol_name(node) == "SortSpec")
416 {
417 std::vector<atermpp::aterm> sorts = parse_SortSpec(node);
418 for (const atermpp::aterm& t: sorts)
419 {
420 if (is_alias(t))
421 {
422 result.add_alias(alias(t));
423 }
424 else
425 {
426 result.add_sort(basic_sort(t));
427 }
428 }
429 return true;
430 }
431 else if (symbol_name(node) == "ConsSpec")
432 {
433 function_symbol_vector functions = parse_ConsSpec(node);
434 for (const function_symbol& f: functions)
435 {
436 result.add_constructor(f);
437 }
438 return true;
439 }
440 else if (symbol_name(node) == "MapSpec")
441 {
442 function_symbol_vector functions = parse_MapSpec(node);
443 for (const function_symbol& f: functions)
444 {
445 result.add_mapping(f);
446 }
447 return true;
448 }
449 else if (symbol_name(node) == "EqnSpec")
450 {
451 data_equation_vector equations = parse_EqnSpec(node);
452 for (const data_equation& eq: equations)
453 {
454 result.add_equation(eq);
455 }
456 return true;
457 }
458 return false;
459 }
460
462 {
464 traverse(node, [&](const core::parse_node& node) { return callback_DataSpecElement(node, result); });
465 return result;
466 }
467};
468
469} // namespace detail
470
471} // namespace data
472
473} // namespace mcrl2
474
475#endif // MCRL2_DATA_PARSE_IMPL_H
Term containing a string.
A list of aterm objects.
Definition aterm_list.h:24
bool empty() const
Returns true if the list's size is 0.
Definition aterm_list.h:268
void push_front(const Term &el)
Inserts a new element at the beginning of the current list.
An abstraction expression.
Definition abstraction.h:26
\brief A sort alias
Definition alias.h:26
An application of a data expression to a number of arguments.
\brief A basic sort
Definition basic_sort.h:26
\brief A data equation
existential quantification.
Definition exists.h:26
universal quantification.
Definition forall.h:26
\brief A function sort
\brief A function symbol
function symbol.
Definition lambda.h:27
\brief A sort expression
\brief An argument of a constructor of a structured sort
\brief A constructor for a structured sort
\brief Assignment of a data expression to a string
Definition assignment.h:182
\brief An untyped identifier
\brief Binder for untyped set or bag comprehension
Definition binder_type.h:77
\brief Unknown sort expression
\brief A data variable
Definition variable.h:28
\brief A where expression
add your file description here.
The standard sort function_update.
const aterm_string & empty_string()
Returns the empty aterm_string.
function_symbol bag_enumeration(const sort_expression &s)
Constructor for function symbol bag_enumeration.
container_sort bag(const sort_expression &s)
Constructor for sort expression Bag(S)
Definition bag1.h:44
const basic_sort & bool_()
Constructor for sort expression Bool.
Definition bool.h:44
const function_symbol & true_()
Constructor for function symbol true.
Definition bool.h:77
container_sort fbag(const sort_expression &s)
Constructor for sort expression FBag(S)
Definition fbag1.h:43
container_sort fset(const sort_expression &s)
Constructor for sort expression FSet(S)
Definition fset1.h:41
const basic_sort & int_()
Constructor for sort expression Int.
Definition int1.h:47
function_symbol list_enumeration(const sort_expression &s)
Constructor for function symbol list_enumeration.
container_sort list(const sort_expression &s)
Constructor for sort expression List(S)
Definition list1.h:42
const basic_sort & nat()
Constructor for sort expression Nat.
Definition nat1.h:46
const basic_sort & pos()
Constructor for sort expression Pos.
Definition pos1.h:45
const basic_sort & real_()
Constructor for sort expression Real.
Definition real1.h:48
function_symbol set_enumeration(const sort_expression &s)
Constructor for function symbol set_enumeration.
container_sort set_(const sort_expression &s)
Constructor for sort expression Set(S)
Definition set1.h:42
std::vector< sort_expression > sort_expression_vector
\brief vector of sort_expressions
const core::identifier_string & function_update_name()
Generate identifier @func_update.
std::vector< data_equation > data_equation_vector
\brief vector of data_equations
std::vector< variable > variable_vector
\brief vector of variables
Definition variable.h:89
atermpp::term_list< sort_expression > sort_expression_list
\brief list of sort_expressions
atermpp::term_list< variable > variable_list
\brief list of variables
bool is_alias(const atermpp::aterm &x)
Definition alias.h:81
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
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.
Provides utilities for working with data expressions of standard container sorts.
core::identifier_string parse_Id(const parse_node &node) const
Definition parse.h:233
default_parser_actions(const parser &parser_)
Definition parse.h:213
core::identifier_string_list parse_IdList(const parse_node &node) const
Definition parse.h:243
core::identifier_string parse_Number(const parse_node &node) const
Definition parse.h:238
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_expression make_untyped_set_or_bag_comprehension(const variable &v, const data_expression &x) const
Definition parse_impl.h:145
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_expression make_list_enumeration(const data_expression_list &x) const
Definition parse_impl.h:150
data_expression make_function_update(const data_expression &x, const data_expression &y, const data_expression &z) const
Definition parse_impl.h:168
data_expression make_set_enumeration(const data_expression_list &x) const
Definition parse_impl.h:156
data::sort_expression_list get_sorts(const ExpressionContainer &x) const
Definition parse_impl.h:174
data_expression_actions(const core::parser &parser_)
Definition parse_impl.h:141
bool callback_VarsDecl(const core::parse_node &node, variable_vector &result) const
Definition parse_impl.h:189
data::variable parse_VarDecl(const core::parse_node &node) const
Definition parse_impl.h:184
data::untyped_identifier_assignment parse_Assignment(const core::parse_node &node) const
Definition parse_impl.h:277
data::data_expression parse_DataValExpr(const core::parse_node &node) const
Definition parse_impl.h:272
data::data_expression_list parse_BagEnumEltList(const core::parse_node &node) const
Definition parse_impl.h:292
data::untyped_identifier_assignment_list parse_AssignmentList(const core::parse_node &node) const
Definition parse_impl.h:282
data_expression make_bag_enumeration(const data_expression_list &x) const
Definition parse_impl.h:162
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
bool callback_IdsDecl(const core::parse_node &node, function_symbol_vector &result) const
Definition parse_impl.h:341
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
data::function_symbol_vector parse_MapSpec(const core::parse_node &node) const
Definition parse_impl.h:368
data::data_equation_vector parse_EqnDeclList(const core::parse_node &node, const variable_list &variables) const
Definition parse_impl.h:399
data::variable_list parse_VarSpec(const core::parse_node &node) const
Definition parse_impl.h:378
std::vector< atermpp::aterm > parse_SortDeclList(const core::parse_node &node) const
Definition parse_impl.h:329
untyped_data_specification parse_DataSpec(const core::parse_node &node) const
Definition parse_impl.h:461
bool callback_SortDecl(const core::parse_node &node, std::vector< atermpp::aterm > &result) const
Definition parse_impl.h:304
data::data_equation_vector parse_EqnSpec(const core::parse_node &node) const
Definition parse_impl.h:406
data::function_symbol_vector parse_IdsDeclList(const core::parse_node &node) const
Definition parse_impl.h:356
bool callback_DataSpecElement(const core::parse_node &node, untyped_data_specification &result) const
Definition parse_impl.h:413
bool callback_EqnDecl(const core::parse_node &node, const variable_list &variables, data_equation_vector &result) const
Definition parse_impl.h:383
std::vector< atermpp::aterm > parse_SortSpec(const core::parse_node &node) const
Definition parse_impl.h:336
data::function_symbol_vector parse_ConsSpec(const core::parse_node &node) const
Definition parse_impl.h:363
data::structured_sort_constructor parse_ConstrDecl(const core::parse_node &node) const
Definition parse_impl.h:96
data::sort_expression parse_SortExpr(const core::parse_node &node, data::sort_expression_list *product=nullptr) const
Definition parse_impl.h:35
data::structured_sort_constructor_list parse_ConstrDeclList(const core::parse_node &node) const
Definition parse_impl.h:116
data::sort_expression_list parse_SortProduct(const core::parse_node &node) const
Definition parse_impl.h:87
data::sort_expression_list parse_SortExpr_as_SortProduct(const core::parse_node &node) const
Definition parse_impl.h:76
data::structured_sort_constructor_argument_list parse_ProjDeclList(const core::parse_node &node) const
Definition parse_impl.h:133
sort_expression_actions(const core::parser &parser_)
Definition parse_impl.h:31
data::structured_sort_constructor_argument parse_ProjDecl(const core::parse_node &node) const
Definition parse_impl.h:121
add your file description here.