hoaparse: rename to parseaut
Because this parser is not specific to HOA anymore. * src/hoaparse/Makefile.am, src/hoaparse/fmterror.cc, src/hoaparse/hoaparse.yy, src/hoaparse/parsedecl.hh, src/parseaut/public.hh, src/hoaparse/hoascan.ll, src/tests/hoaparse.test: Rename to... * src/parseaut/Makefile.am, src/parseaut/fmterror.cc, src/parseaut/parseaut.yy, src/parseaut/parsedecl.hh, src/hoaparse/public.hh, src/parseaut/scanaut.ll, src/tests/parseaut.test: ... these, and also adjust the name internally. For instance hoa_aut_ptr is now parsed_aut_ptr; hoa_stream_parser is now automaton_stream_parser, and hoa_parse() has become parse_aut(). * NEWS, README, configure.ac, doc/org/tut20.org, src/Makefile.am, src/bin/autfilt.cc, src/bin/common_aoutput.cc, src/bin/common_aoutput.hh, src/bin/common_conv.cc, src/bin/ltlcross.cc, src/bin/ltldo.cc, src/tests/Makefile.am, src/tests/complementation.cc, src/tests/ltl2tgba.cc, src/tests/readsave.test, wrap/python/ajax/spot.in, wrap/python/spot.py, wrap/python/spot_impl.i, wrap/python/tests/automata-io.ipynb, wrap/python/tests/parsetgba.py: Adjust.
This commit is contained in:
parent
60bd9dd606
commit
a86391ab77
29 changed files with 158 additions and 156 deletions
|
|
@ -123,40 +123,39 @@ State: 4
|
|||
* C++
|
||||
|
||||
Parsing an automaton is almost similar to [[file:tut01.org][parsing an LTL formula]]. The
|
||||
=hoa_parse()= function (despite the name, it can actually read never
|
||||
claims, or the LBTT or HOA formats) takes a filename, a reference to a
|
||||
=hoa_parse_error_list= object to populate (should errors be found) and
|
||||
=parse_aut()= function takes a filename, a reference to a
|
||||
=parse_aut_error_list= object to populate (should errors be found) and
|
||||
a BDD dictionary (to be discussed later on this page). It returns a
|
||||
shared pointer to a structure that has two fields: =aborted= is a
|
||||
Boolean telling if the input automaton was voluntarily aborted (a
|
||||
feature of [[file:hoa.org][the HOA format]]), and =aut= is the actual automaton. The
|
||||
shared pointer returned by =hoa_parse()= might be null (in which case
|
||||
the the =hoa_parse_error_list= is guaranteed not to be empty), but
|
||||
shared pointer returned by =parse_aut()= might be null (in which case
|
||||
the the =parse_aut_error_list= is guaranteed not to be empty), but
|
||||
since the parser performs some error recovery it is likely that an
|
||||
automaton is returned even in the presence of parse errors.
|
||||
|
||||
#+BEGIN_SRC C++ :results verbatim :exports both
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include "hoaparse/public.hh"
|
||||
#include "parseaut/public.hh"
|
||||
#include "twaalgos/hoa.hh"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string input = "tut20.never";
|
||||
spot::hoa_parse_error_list pel;
|
||||
spot::parse_aut_error_list pel;
|
||||
spot::bdd_dict_ptr dict = spot::make_bdd_dict();
|
||||
spot::hoa_aut_ptr h = hoa_parse(input, pel, dict);
|
||||
if (spot::format_hoa_parse_errors(std::cerr, input, pel))
|
||||
spot::parsed_aut_ptr pa = parse_aut(input, pel, dict);
|
||||
if (spot::format_parse_aut_errors(std::cerr, input, pel))
|
||||
return 1;
|
||||
// This cannot occur when reading a never claim, but
|
||||
// it could while reading a HOA file.
|
||||
if (h->aborted)
|
||||
if (pa->aborted)
|
||||
{
|
||||
std::cerr << "--ABORT-- read" << '\n';
|
||||
return 1;
|
||||
}
|
||||
spot::print_hoa(std::cout, h->aut) << '\n';
|
||||
spot::print_hoa(std::cout, pa->aut) << '\n';
|
||||
return 0;
|
||||
}
|
||||
#+END_SRC
|
||||
|
|
@ -214,11 +213,11 @@ There are actually different C++ interfaces to the automaton parser,
|
|||
depending on your use case. For instance the parser is able to read a
|
||||
stream of automata stored in the same file, so that they could be
|
||||
processed in a loop. For this, you would instanciate a
|
||||
=hoa_stream_parser= object and call its =parse()= method in a loop.
|
||||
Each call to this method will either return one automaton, or
|
||||
=nullptr= if there is no more automaton to read. The =hoa_parse()=
|
||||
function is actually a simple wrapper that instanciate
|
||||
=hoa_stream_parser= and calls =parse()= once.
|
||||
=automaton_stream_parser= object and call its =parse()= method in a
|
||||
loop. Each call to this method will either return one automaton, or
|
||||
=nullptr= if there is no more automaton to read. The =parse_aut()=
|
||||
function is actually a simple convenience wrapper that instanciate
|
||||
an =automaton_stream_parser= and calls its =parse()= method once.
|
||||
|
||||
|
||||
In Python, you can easily iterate over a file containing multiple
|
||||
|
|
@ -284,7 +283,8 @@ print(spot.automaton('spin -f "[]<>p0" |').to_str('lbtt'))
|
|||
:
|
||||
|
||||
- a string that includes new lines, in which case it is assumed
|
||||
to describe an automaton, and is passed directly to the parser:
|
||||
to describe an automaton (or multiple automata) and is
|
||||
passed directly to the parser:
|
||||
|
||||
#+BEGIN_SRC python :results output :exports both
|
||||
import spot
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue