mCRL2
Loading...
Searching...
No Matches
parse.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_LPS_PARSE_H
13#define MCRL2_LPS_PARSE_H
14
16#include "mcrl2/lps/typecheck.h"
17#include "mcrl2/process/parse.h"
18
19namespace mcrl2
20{
21
22namespace lps
23{
24
25namespace detail {
26
27process::untyped_multi_action parse_multi_action_new(const std::string& text);
28multi_action complete_multi_action(process::untyped_multi_action& x, multi_action_type_checker& typechecker, const data::data_specification& data_spec = data::detail::default_specification());
29multi_action complete_multi_action(process::untyped_multi_action& x, const process::action_label_list& action_decls, const data::data_specification& data_spec = data::detail::default_specification());
30action_rename_specification parse_action_rename_specification_new(const std::string& text);
31void complete_action_rename_specification(action_rename_specification& x, const lps::stochastic_specification& spec);
32
33} // namespace detail
34
41inline
43{
44 std::string text = utilities::read_text(in);
46 return detail::complete_multi_action(u, action_decls, data_spec);
47}
48
55inline
57{
58 std::string text = utilities::read_text(in);
60 return detail::complete_multi_action(u, typechecker, data_spec);
61}
62
69inline
71{
72 std::stringstream ma_stream(text);
73 return parse_multi_action(ma_stream, action_decls, data_spec);
74}
75
82inline
84{
85 std::stringstream ma_stream(text);
86 return parse_multi_action(ma_stream, typechecker, data_spec);
87}
88
93inline
95{
96 std::string text = utilities::read_text(in);
99 return result;
100}
101
109inline
111 const std::string& spec_string,
113{
114 std::istringstream in(spec_string);
115 return parse_action_rename_specification(in, spec);
116}
117
127inline
129{
132 if (!process::is_linear(pspec, true))
133 {
134 throw mcrl2::runtime_error("the process specification is not linear!");
135 }
137 specification result = visitor.convert(pspec);
139 return result;
140}
141
151inline
153{
154 std::istringstream stream(text);
156}
157
158template <typename Specification>
159void parse_lps(std::istream&, Specification&)
160{
161 throw mcrl2::runtime_error("parse_lps not implemented yet!");
162}
163
164template <>
165inline
166void parse_lps<specification>(std::istream& from, specification& result)
167{
169}
170
181template <>
182inline
184{
187 if (!process::is_linear(pspec, true))
188 {
189 throw mcrl2::runtime_error("the process specification is not linear!");
190 }
192 result = visitor.convert(pspec);
194}
195
196template <typename Specification>
197void parse_lps(const std::string& text, Specification& result)
198{
199 std::istringstream stream(text);
200 parse_lps(stream, result);
201}
202
209// TODO: implement this function in the Process Library
210inline
212{
213 multi_action result = parse_multi_action(text, action_decls, data_spec);
214 if (result.actions().size() != 1)
215 {
216 throw mcrl2::runtime_error("cannot parse '" + text + " as an action!");
217 }
218 return result.actions().front();
219}
220
221} // namespace lps
222
223} // namespace mcrl2
224
225#endif // MCRL2_LPS_PARSE_H
size_type size() const
Returns the size of the term_list.
Definition aterm_list.h:256
const Term & front() const
Returns the first element of the list.
Definition aterm_list.h:239
Read-only singly linked list of action rename rules.
\brief A timed multi-action
const process::action_list & actions() const
Linear process specification.
Process specification consisting of a data specification, action labels, a sequence of process equati...
\brief An untyped multi action or data application
Standard exception class for reporting runtime errors.
Definition exception.h:27
add your file description here.
add your file description here.
static data_specification const & default_specification()
Definition parse.h:31
void complete_action_rename_specification(action_rename_specification &x, const lps::stochastic_specification &spec)
Definition lps.cpp:150
process::untyped_multi_action parse_multi_action_new(const std::string &text)
Definition lps.cpp:114
multi_action complete_multi_action(process::untyped_multi_action &x, multi_action_type_checker &typechecker, const data::data_specification &data_spec=data::detail::default_specification())
Definition lps.cpp:124
action_rename_specification parse_action_rename_specification_new(const std::string &text)
Definition lps.cpp:140
void parse_lps(std::istream &, Specification &)
Definition parse.h:159
process::action parse_action(const std::string &text, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Parses an action from a string.
Definition parse.h:211
void complete_data_specification(specification &spec)
Adds all sorts that appear in the process of l to the data specification of l.
action_rename_specification parse_action_rename_specification(std::istream &in, const lps::stochastic_specification &spec)
Parses a process specification from an input stream.
Definition parse.h:94
multi_action parse_multi_action(std::stringstream &in, const process::action_label_list &action_decls, const data::data_specification &data_spec=data::detail::default_specification())
Parses a multi_action from an input stream.
Definition parse.h:42
void parse_lps< specification >(std::istream &from, specification &result)
Definition parse.h:166
void parse_lps< stochastic_specification >(std::istream &from, stochastic_specification &result)
Parses a stochastic linear process specification from an input stream.
Definition parse.h:183
specification parse_linear_process_specification(std::istream &spec_stream)
Parses a linear process specification from an input stream.
Definition parse.h:128
bool is_linear(const process_specification &p, bool verbose=false)
Returns true if the process specification is linear.
Definition is_linear.h:347
atermpp::term_list< action_label > action_label_list
\brief list of action_labels
process_specification parse_process_specification(std::istream &in)
Parses a process specification from an input stream.
Definition parse.h:43
std::string read_text(const std::string &filename, bool warn=false)
Read text from a file.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Parse function for process specifications.
Converts a process expression into linear process format. Use the convert member functions for this.
void convert(const process_equation &)
Returns true if the process equation e is linear.
Converts a process expression into linear process format. Use the convert member functions for this.
void convert(const process_equation &)
Returns true if the process equation e is linear.