LCOV - code coverage report
Current view: top level - data/include/mcrl2/data/detail - parse_substitution.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 13 13 100.0 %
Date: 2024-04-19 03:43:27 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/data/detail/parse_substitution.h
      10             : /// \brief Add your file description here.
      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             : 
      17             : namespace mcrl2
      18             : {
      19             : 
      20             : namespace data
      21             : {
      22             : 
      23             : namespace detail
      24             : {
      25             : 
      26             : /// \brief Parses a string of the form "b: Bool := true, n: Nat := 0", and adds
      27             : /// the substitutions to the substition function sigma. If the string is surrounded
      28             : /// by brackets (e.g. "[b: Bool := true, n: Nat := 0]"), these are ignored.
      29             : template <typename MutableSubstitution>
      30          15 : void parse_substitution(std::string text, MutableSubstitution& sigma, const data_specification& data_spec = data::data_specification())
      31             : {
      32          15 :   text = utilities::regex_replace("^\\s*\\[", "", text);
      33          15 :   text = utilities::regex_replace("\\]\\s*$", "", text);
      34          15 :   std::cout << "text = " << text << std::endl;
      35          30 :   std::vector<std::string> substitutions = utilities::split(text, ";");
      36          57 :   for (const std::string& substitution: substitutions)
      37             :   {
      38          42 :     std::vector<std::string> words = utilities::regex_split(substitution, ":=");
      39          21 :     if (words.size() != 2)
      40             :     {
      41           4 :       continue;
      42             :     }
      43          17 :     data::variable v = data::parse_variable(words[0], data_spec);
      44          17 :     data::data_expression e = data::parse_data_expression(words[1], data_spec);
      45          17 :     sigma[v] = e;
      46             :   }
      47          15 : }
      48             : 
      49             : } // namespace detail
      50             : 
      51             : } // namespace data
      52             : 
      53             : } // namespace mcrl2
      54             : 
      55             : #endif // MCRL2_DATA_DETAIL_PARSE_SUBSTITUTION_H

Generated by: LCOV version 1.14