mCRL2
Loading...
Searching...
No Matches
lps_rewriter_tool.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote (based on mcrl2/bes/pbes_rewriter_tool.h by 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/lps_rewriter_tool.h
10/// \brief Base class for tools that use an lps rewriter.
11
12#ifndef MCRL2_LPS_LPS_REWRITER_TOOL_H
13#define MCRL2_LPS_LPS_REWRITER_TOOL_H
14
15#include <set>
16#include "mcrl2/utilities/command_line_interface.h"
17#include "mcrl2/lps/lps_rewriter_type.h"
18
19namespace mcrl2::lps::tools
20{
21
22/// \brief Base class for filter tools that use a lps rewriter.
23template <typename Tool>
24class lps_rewriter_tool: public Tool
25{
26 protected:
27 /// \brief The type of the lps rewriter
28 lps::lps_rewriter_type m_lps_rewriter_type;
29
30 /// \brief Returns the types of rewriters that are available for this tool.
31 /// Override this method to change the standard behavior.
32 /// \return The set { simplify, quantifier_all, quantifier_finite }
34 {
35 std::set<lps::lps_rewriter_type> result;
36 result.insert(lps::lps_rewriter_type::simplify);
37 result.insert(lps::lps_rewriter_type::quantifier_one_point);
38 result.insert(lps::lps_rewriter_type::condition_one_point);
39 result.insert(lps::lps_rewriter_type::prune_dataspec);
40 return result;
41 }
42
43 /// \brief Returns the default lps rewriter.
44 /// Override this method to change the standard behavior.
45 /// \return The string "simplify"
46 virtual lps::lps_rewriter_type default_rewriter() const
47 {
48 return lps::lps_rewriter_type::simplify;
49 }
50
51 /// \brief Add options to an interface description. Also includes
52 /// rewriter options.
53 /// \param desc An interface description
55 {
56 Tool::add_options(desc);
57
58 utilities::interface_description::enum_argument<lps::lps_rewriter_type> arg(utilities::make_enum_argument<lps::lps_rewriter_type>("NAME"));
59
60 // Compute the available rewriters, and add the approriate arguments
61 for (const lps::lps_rewriter_type& type: available_rewriters())
62 {
63 arg.add_value(type, type==default_rewriter());
64 }
65
66 desc.add_option(
67 "lps-rewriter",
68 arg,
69 "use lps rewrite strategy NAME:",
70 'p'
71 );
72 }
73
74 /// \brief Parse non-standard options
75 /// \param parser A command line parser
76 void parse_options(const utilities::command_line_parser& parser) override
77 {
78 Tool::parse_options(parser);
79 m_lps_rewriter_type = parser.option_argument_as<lps::lps_rewriter_type>("lps-rewriter");
80 }
81
82
83 public:
84 /// \brief Constructor.
85 /// \param name The name of the tool
86 /// \param author The author(s) of the tool
87 /// \param what_is One-line "what is" description of the tool
88 /// \param tool_description The description of the tool
89 /// \param known_issues Known issues with the tool
90 lps_rewriter_tool(const std::string& name,
91 const std::string& author,
92 const std::string& what_is,
93 const std::string& tool_description,
94 std::string known_issues = ""
95 )
97 {}
98
99 /// \brief Destructor.
100 ~lps_rewriter_tool() override = default;
101
102 /// \brief Returns the rewriter type
103 /// \return The rewriter type
104 lps::lps_rewriter_type rewriter_type() const
105 {
106 return m_lps_rewriter_type;
107 }
108};
109
110} // namespace mcrl2::lps::tools
111
112#endif // MCRL2_LPS_LPS_REWRITER_TOOL_H
Base class for filter tools that use a lps rewriter.
~lps_rewriter_tool() override=default
Destructor.
void parse_options(const utilities::command_line_parser &parser) override
Parse non-standard options.
virtual std::set< lps::lps_rewriter_type > available_rewriters() const
Returns the types of rewriters that are available for this tool. Override this method to change the s...
virtual lps::lps_rewriter_type default_rewriter() const
Returns the default lps rewriter. Override this method to change the standard behavior.
lps_rewriter_tool(const std::string &name, const std::string &author, const std::string &what_is, const std::string &tool_description, std::string known_issues="")
Constructor.
lps::lps_rewriter_type rewriter_type() const
Returns the rewriter type.
lps::lps_rewriter_type m_lps_rewriter_type
The type of the lps rewriter.
void add_options(utilities::interface_description &desc) override
Add options to an interface description. Also includes rewriter options.
Main parsing component for command line strings as well as interface to the results of parsing....
Command line interface description component.
The main namespace for the LPS library.
Definition constelm.h:18