spot  1.99.4
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
public.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2013, 2014, 2015 Laboratoire de Recherche et Développement
3 // de l'Epita (LRDE).
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #pragma once
21 
22 #include "twa/twagraph.hh"
23 #include "misc/location.hh"
24 #include "tl/defaultenv.hh"
25 #include <string>
26 #include <list>
27 #include <utility>
28 #include <iosfwd>
29 #include <misc/bitvect.hh>
30 
31 namespace spot
32 {
35 
36 #ifndef SWIG
37  typedef std::pair<spot::location, std::string> parse_aut_error;
40  typedef std::list<parse_aut_error> parse_aut_error_list;
41 #else
42  // Turn parse_aut_error_list into an opaque type for Swig.
43  struct parse_aut_error_list {};
44 #endif
45 
46  enum class parsed_aut_type { HOA, NeverClaim, LBTT, DRA, DSA, Unknown };
47 
50  struct SPOT_API parsed_aut
51  {
52  // Transition structure of the automaton.
53  // This is encoded as a TGBA without acceptance condition.
54  twa_graph_ptr aut;
55  bool aborted = false;
56  spot::location loc;
57  parsed_aut_type type = parsed_aut_type::Unknown;
58  };
59 
60  typedef std::shared_ptr<parsed_aut> parsed_aut_ptr;
61  typedef std::shared_ptr<const parsed_aut> const_parsed_aut_ptr;
62 
63  class SPOT_API automaton_stream_parser
64  {
65  spot::location last_loc;
66  std::string filename_;
67  bool ignore_abort_;
68  public:
69  automaton_stream_parser(const std::string& filename,
70  bool ignore_abort = false);
71  // Read from an already open file descriptor.
72  // Use filename in error messages.
73  automaton_stream_parser(int fd, const std::string& filename,
74  bool ignore_abort = false);
75  // Read from a buffer
76  automaton_stream_parser(const char* data,
77  const std::string& filename,
78  bool ignore_abort = false);
80  parsed_aut_ptr parse(parse_aut_error_list& error_list,
81  const bdd_dict_ptr& dict,
82  environment& env =
84  bool debug = false);
85  // Raises a parse_error on any syntax error
86  twa_graph_ptr parse_strict(const bdd_dict_ptr& dict,
87  environment& env =
89  bool debug = false);
90  };
91 
119  inline parsed_aut_ptr
120  parse_aut(const std::string& filename,
121  parse_aut_error_list& error_list,
122  const bdd_dict_ptr& dict,
124  bool debug = false)
125  {
126  try
127  {
128  automaton_stream_parser p(filename);
129  return p.parse(error_list, dict, env, debug);
130  }
131  catch (std::runtime_error& e)
132  {
133  error_list.emplace_back(spot::location(), e.what());
134  return nullptr;
135  }
136  }
137 
144  SPOT_API bool
145  format_parse_aut_errors(std::ostream& os,
146  const std::string& filename,
147  parse_aut_error_list& error_list);
148 
150 }
Definition: graph.hh:31
static default_environment & instance()
Get the sole instance of spot::default_environment.
std::pair< spot::location, std::string > parse_aut_error
A parse diagnostic with its location.
Definition: public.hh:38
Temporary encoding of an omega automaton produced by the parser.
Definition: public.hh:50
An environment that describes atomic propositions.
Definition: environment.hh:32
parsed_aut_ptr parse_aut(const std::string &filename, parse_aut_error_list &error_list, const bdd_dict_ptr &dict, environment &env=default_environment::instance(), bool debug=false)
Build a spot::twa_graph from a HOA file or a neverclaim.
Definition: public.hh:120
std::list< parse_aut_error > parse_aut_error_list
A list of parser diagnostics, as filled by parse.
Definition: public.hh:40
bool format_parse_aut_errors(std::ostream &os, const std::string &filename, parse_aut_error_list &error_list)
Format diagnostics produced by spot::parse_aut.
Definition: public.hh:63

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Thu Oct 1 2015 05:49:14 for spot by doxygen 1.8.8