mCRL2
Loading...
Searching...
No Matches
rewriter_tool.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//
9/// \file mcrl2/data/rewriter_tool.h
10/// \brief Base class for tools that use a data rewriter.
11
12#ifndef MCRL2_DATA_REWRITER_TOOL_H
13#define MCRL2_DATA_REWRITER_TOOL_H
14
15#include "mcrl2/data/detail/enumerator_iteration_limit.h"
16#include "mcrl2/data/rewriter.h"
17#include "mcrl2/utilities/command_line_interface.h"
18
19namespace mcrl2::data::tools
20{
21
22/// \brief Base class for tools that use a rewriter.
23template <typename Tool>
24class rewriter_tool: public Tool
25{
26 protected:
27 /// The data rewriter strategy
28 data::rewrite_strategy m_rewrite_strategy = mcrl2::data::rewrite_strategy::jitty;
29 /// The limit on the number of rewriting steps in quantifiers. By default 10;
31
32 /// \brief Add options to an interface description. Also includes
33 /// rewriter options.
34 /// \param desc An interface description.
35 /// \param suppress_jittyp Boolean that if true will prevent showing that jittyp is an option for rewriting.
36 void add_options(utilities::interface_description& desc, bool suppress_jittyp)
37 {
38 Tool::add_options(desc);
39
40 utilities::interface_description::enum_argument<data::rewrite_strategy> rewriter_option("NAME");
41 rewriter_option.add_value(data::rewrite_strategy::jitty, true);
42#ifdef MCRL2_ENABLE_JITTYC
43 rewriter_option.add_value(data::rewrite_strategy::jitty_compiling);
44#endif
45 if (!suppress_jittyp)
46 {
47 rewriter_option.add_value(data::rewrite_strategy::jitty_prover);
48 }
49
50 desc.add_option(
51 "rewriter",
52 rewriter_option,
53 "use rewrite strategy NAME:"
54 ,'r'
55 );
56
57 desc.add_option(
58 "qlimit",
59 utilities::make_mandatory_argument("NUM"),
60 "limit enumeration of universal and existential quantifiers in data expressions to NUM iterations (default NUM=10, NUM=0 for unlimited).",
61 'Q'
62 );
63
64 }
65
66 /// \brief Add options to an interface description. Also includes
67 /// rewriter options.
68 /// \param desc An interface description
69 void add_options(utilities::interface_description& desc) override { add_options(desc, false); }
70
71 /// \brief Parse non-standard options
72 /// \param parser A command line parser
73 void parse_options(const utilities::command_line_parser& parser) override
74 {
75 Tool::parse_options(parser);
76 m_rewrite_strategy = parser.option_argument_as< data::rewrite_strategy >("rewriter");
77
78 //Set enumerator limit for quantifier enumeration
79 if (parser.options.count("qlimit"))
80 {
81 std::size_t qlimit = parser.option_argument_as< std::size_t >("qlimit");
82 m_qlimit = (qlimit == 0 ? std::numeric_limits<std::size_t>::max() : qlimit);
83 }
84 data::detail::set_enumerator_iteration_limit(m_qlimit);
85 }
86
87 public:
88
89 /// \brief Constructor.
90 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 Returns the rewrite strategy
100 /// \return The rewrite strategy
101 data::rewrite_strategy rewrite_strategy() const
102 {
103 return m_rewrite_strategy;
104 }
105
106 /// \brief Creates a data rewriter as specified on the command line.
107 /// \param data_spec A data specification
108 /// \return A data rewriter
110 {
111 return data::rewriter(data_spec, rewrite_strategy());
112 }
113};
114
115} // namespace mcrl2::data::tools
116
117
118
119
120
121#endif // MCRL2_DATA_REWRITER_TOOL_H
data_specification()=default
Default constructor. Generate a data specification that contains only booleans and positive numbers.
Rewriter that operates on data expressions.
Definition rewriter.h:84
Base class for tools that use a rewriter.
void add_options(utilities::interface_description &desc) override
Add options to an interface description. Also includes rewriter options.
std::size_t m_qlimit
The limit on the number of rewriting steps in quantifiers. By default 10;.
data::rewrite_strategy m_rewrite_strategy
The data rewriter strategy.
void add_options(utilities::interface_description &desc, bool suppress_jittyp)
Add options to an interface description. Also includes rewriter options.
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.
void parse_options(const utilities::command_line_parser &parser) override
Parse non-standard options.
data::rewriter create_rewriter(const data::data_specification &data_spec=data::data_specification())
Creates a data rewriter as specified on the command line.
Main parsing component for command line strings as well as interface to the results of parsing....
Command line interface description component.