hoaparse: make it possible to read from a string

* src/hoaparse/public.hh, src/hoaparse/parsedecl.hh,
src/hoaparse/hoascan.ll, src/hoaparse/hoaparse.yy: Implement this new
interface.
* wrap/python/spot.py (automata): Use it when the argument contains
a newline.
* wrap/python/tests/automata-io.ipynb: Test it.
This commit is contained in:
Alexandre Duret-Lutz 2015-04-27 00:11:29 +02:00
parent 528cc04cca
commit 5bfed246f9
6 changed files with 221 additions and 38 deletions

View file

@ -1667,6 +1667,14 @@ namespace spot
throw std::runtime_error(std::string("Cannot open file ") + name);
}
hoa_stream_parser::hoa_stream_parser(const char* data,
const std::string& filename,
bool ignore_abort)
: filename_(filename), ignore_abort_(ignore_abort)
{
hoayystring(data);
}
hoa_stream_parser::~hoa_stream_parser()
{
hoayyclose();

View file

@ -390,6 +390,14 @@ namespace spot
return 0;
}
int
hoayystring(const char* data)
{
yy_scan_string(data);
hoayyreset();
return 0;
}
int
hoayyopen(int fd)
{

View file

@ -34,6 +34,7 @@ namespace spot
void hoayyreset();
int hoayyopen(const std::string& name);
int hoayyopen(int fd);
int hoayystring(const char* data);
void hoayyclose();
// This exception is thrown by the lexer when it reads "--ABORT--".

View file

@ -68,6 +68,10 @@ namespace spot
// Use filename in error messages.
hoa_stream_parser(int fd, const std::string& filename,
bool ignore_abort = false);
// Read from a buffer
hoa_stream_parser(const char* data,
const std::string& filename,
bool ignore_abort = false);
~hoa_stream_parser();
hoa_aut_ptr parse(hoa_parse_error_list& error_list,
const bdd_dict_ptr& dict,