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
|
|
@ -260,6 +260,47 @@ namespace spot
|
|||
"\\SereGoto{",
|
||||
};
|
||||
|
||||
const char* sclatex_kw[] = {
|
||||
"\\ffalse",
|
||||
"\\ttrue",
|
||||
"\\varepsilon",
|
||||
" \\oplus ",
|
||||
" \\rightarrow ",
|
||||
" \\leftrightarrow ",
|
||||
" \\mathbin{\\mathsf{U}} ",
|
||||
" \\mathbin{\\mathsf{R}} ",
|
||||
" \\mathbin{\\mathsf{W}} ",
|
||||
" \\mathbin{\\mathsf{M}} ",
|
||||
("\\mathrel{\\Diamond\\kern-1.7pt\\raise.4pt"
|
||||
"\\hbox{$\\mathord{\\rightarrow}$}} "),
|
||||
("\\mathrel{\\Diamond\\kern-1.7pt\\raise.4pt"
|
||||
"\\hbox{$\\mathord{\\Rightarrow}$}} "),
|
||||
"\\seqM ",
|
||||
"\\seqXM ",
|
||||
("\\mathrel{\\Box\\kern-1.7pt\\raise.4pt"
|
||||
"\\hbox{$\\mathord{\\rightarrow}$}} "),
|
||||
("\\mathrel{\\Box\\kern-1.7pt\\raise.4pt"
|
||||
"\\hbox{$\\mathord{\\Rightarrow}$}} "),
|
||||
"\\lnot ",
|
||||
"\\mathsf{X} ",
|
||||
"\\mathsf{F} ",
|
||||
"\\mathsf{G} ",
|
||||
" \\lor ",
|
||||
" \\cup ",
|
||||
" \\land ",
|
||||
" \\cap ",
|
||||
" \\mathbin{\\mathsf{\\&}} ",
|
||||
" \\mathbin{\\mathsf{;}} ",
|
||||
" \\mathbin{\\mathsf{:}} ",
|
||||
"\\{",
|
||||
"\\}",
|
||||
"}",
|
||||
"^{\\star",
|
||||
"^+",
|
||||
"^{=",
|
||||
"^{\\to",
|
||||
};
|
||||
|
||||
static bool
|
||||
is_bare_word(const char* str)
|
||||
{
|
||||
|
|
@ -370,7 +411,7 @@ namespace spot
|
|||
}
|
||||
else
|
||||
{
|
||||
if (kw_ == latex_kw)
|
||||
if (kw_ == latex_kw || kw_ == sclatex_kw)
|
||||
{
|
||||
size_t s = str.size();
|
||||
while (str[s - 1] >= '0' && str[s - 1] <= '9')
|
||||
|
|
@ -945,6 +986,24 @@ namespace spot
|
|||
return os.str();
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
to_sclatex_string(const formula* f, std::ostream& os,
|
||||
bool full_parent, bool ratexp)
|
||||
{
|
||||
to_string_visitor v(os, full_parent, ratexp, sclatex_kw);
|
||||
f->accept(v);
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string
|
||||
to_sclatex_string(const formula* f,
|
||||
bool full_parent, bool ratexp)
|
||||
{
|
||||
std::ostringstream os;
|
||||
to_sclatex_string(f, os, full_parent, ratexp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue