python: read automata from pipes
* src/hoaparse/hoaparse.yy, src/hoaparse/hoascan.ll, src/hoaparse/parsedecl.hh, src/hoaparse/public.hh: Add a way to read automata from a file descriptor. * wrap/python/spot.py: Add machinery to read from pipes. * wrap/python/tests/piperead.ipynb: New file. * wrap/python/tests/Makefile.am: Add it. * wrap/python/tests/run.in: Setup PATH.
This commit is contained in:
parent
af8e7d62de
commit
961d005b84
8 changed files with 603 additions and 8 deletions
|
|
@ -388,6 +388,31 @@ namespace spot
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
hoayyopen(int fd)
|
||||
{
|
||||
bool want_interactive = false;
|
||||
|
||||
yyin = fdopen(fd, "r");
|
||||
|
||||
// If the input is a pipe, make the scanner
|
||||
// interactive so that it does not wait for the input
|
||||
// buffer to be full to process automata.
|
||||
struct stat s;
|
||||
if (fstat(fd, &s) < 0)
|
||||
throw std::runtime_error("fstat failed");
|
||||
if (S_ISFIFO(s.st_mode))
|
||||
want_interactive = true;
|
||||
|
||||
// Reset the lexer in case a previous parse
|
||||
// ended badly.
|
||||
YY_NEW_FILE;
|
||||
hoayyreset();
|
||||
if (want_interactive)
|
||||
yy_set_interactive(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
hoayyclose()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue