mCRL2
Loading...
Searching...
No Matches
parse_substitution.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_DETAIL_PARSE_SUBSTITUTION_H
13#define MCRL2_DATA_DETAIL_PARSE_SUBSTITUTION_H
14
15#include "mcrl2/data/parse.h"
16
17namespace mcrl2
18{
19
20namespace data
21{
22
23namespace detail
24{
25
29template <typename MutableSubstitution>
30void parse_substitution(std::string text, MutableSubstitution& sigma, const data_specification& data_spec = data::data_specification())
31{
32 text = utilities::regex_replace("^\\s*\\[", "", text);
33 text = utilities::regex_replace("\\]\\s*$", "", text);
34 std::cout << "text = " << text << std::endl;
35 std::vector<std::string> substitutions = utilities::split(text, ";");
36 for (const std::string& substitution: substitutions)
37 {
38 std::vector<std::string> words = utilities::regex_split(substitution, ":=");
39 if (words.size() != 2)
40 {
41 continue;
42 }
43 data::variable v = data::parse_variable(words[0], data_spec);
45 sigma[v] = e;
46 }
47}
48
49} // namespace detail
50
51} // namespace data
52
53} // namespace mcrl2
54
55#endif // MCRL2_DATA_DETAIL_PARSE_SUBSTITUTION_H
\brief A data variable
Definition variable.h:28
Parser for data specifications.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
void parse_substitution(std::string text, MutableSubstitution &sigma, const data_specification &data_spec=data::data_specification())
Parses a string of the form "b: Bool := true, n: Nat := 0", and adds the substitutions to the substit...
data_expression parse_data_expression(std::istream &in, const VariableContainer &variables, const data_specification &dataspec=detail::default_specification(), bool type_check=true, bool translate_user_notation=true, bool normalize_sorts=true)
Parses and type checks a data expression.
Definition parse.h:276
variable parse_variable(const std::string &text, const data_specification &data_spec=detail::default_specification())
Parses and type checks a data variable declaration.
Definition parse.h:218
std::string regex_replace(const std::string &src, const std::string &dest, const std::string &text)
Regular expression replacement in a string.
std::vector< std::string > regex_split(const std::string &text, const std::string &sep)
Split a string using a regular expression separator.
std::vector< std::string > split(const std::string &line, const std::string &separators)
Split the text.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72