Better formula I/O for ipython.
* src/ltlparse/public.hh, src/ltlparse/ltlparse.yy, src/ltlparse/ltlscan.ll (parse_error): New class. (parse_formula): New function that raises a parse_error exception on error. * src/ltlvisit/tostring.hh, src/ltlvisit/tostring.cc: (to_sclatex_string): New method. * wrap/python/spot.i: Catch the parser_error exception, and use the to_sclatex_string for MathJax rendering. * wrap/python/tests/run.in: Start ipython on demand.
This commit is contained in:
parent
6d7c258fd7
commit
ae35cc29f5
7 changed files with 150 additions and 16 deletions
|
|
@ -33,6 +33,7 @@
|
|||
%code requires
|
||||
{
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include "public.hh"
|
||||
#include "ltlast/allnodes.hh"
|
||||
#include "ltlvisit/tostring.hh"
|
||||
|
|
@ -1034,6 +1035,24 @@ namespace spot
|
|||
return result;
|
||||
}
|
||||
|
||||
const formula*
|
||||
parse_formula(const std::string& ltl_string, environment& env)
|
||||
{
|
||||
parse_error_list pel;
|
||||
const formula* f = parse(ltl_string, pel, env);
|
||||
std::ostringstream s;
|
||||
if (format_parse_errors(s, ltl_string, pel))
|
||||
{
|
||||
parse_error_list pel2;
|
||||
const formula* g = parse_lbt(ltl_string, pel2, env);
|
||||
if (pel2.empty())
|
||||
return g;
|
||||
else
|
||||
throw parse_error(s.str());
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue