python: improve handling of formulas

* src/misc/escape.hh, src/misc/escape.cc (escape_latex): New function.
* src/ltlvisit/tostring.cc: Escape atomic proposition in LaTeX output.
* wrap/python/spot.py: Make it easy to output formulas in different
syntaxes.  Also allow the AST to be shown.
* wrap/python/spot_impl.i: Catch std::runtime_error.
* wrap/python/tests/formulas.ipynb: New file.
* wrap/python/tests/Makefile.am: Add it.
This commit is contained in:
Alexandre Duret-Lutz 2015-03-11 19:41:24 +01:00
parent a6dbf5cf5e
commit 2362b9ab68
7 changed files with 667 additions and 35 deletions

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2013 Laboratoire de Recherche et
// Copyright (C) 2011, 2012, 2013, 2015 Laboratoire de Recherche et
// Developpement de l'Epita (LRDE).
// Copyright (C) 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -39,6 +39,13 @@ namespace spot
SPOT_API std::ostream&
escape_rfc4180(std::ostream& os, const std::string& str);
/// \brief Escape special LaTeX characters.
///
/// The following characters are rewritten:
/// <code>& % $ # _ { } ~ ^ \\</code>
SPOT_API std::ostream&
escape_latex(std::ostream& os, const std::string& str);
/// \brief Escape characters <code>"</code>, <code>\\</code>, and
/// <code>\\n</code> in \a str.
SPOT_API std::ostream&