Add support for printing LTL formulas using Wring's syntax.

* src/ltlvisit/tostring.hh, src/ltlvisit/tostring.cc
(to_wring_string): New option.
* src/bin/common_output.hh, src/bin/common_output.cc:
Add support for a --wring option.
* src/bin/ltlcheck.cc: Add %w and %W format specifiers.
This commit is contained in:
Alexandre Duret-Lutz 2012-10-20 13:32:05 +02:00
parent bf765480b1
commit 0fc3c6bcff
5 changed files with 102 additions and 7 deletions

View file

@ -26,6 +26,7 @@
#include "error.h"
#define OPT_SPOT 1
#define OPT_WRING 2
output_format_t output_format = spot_output;
bool full_parenth = false;
@ -37,6 +38,7 @@ static const argp_option options[] =
{ "spin", 's', 0, 0, "output in Spin's syntax", -20 },
{ "spot", OPT_SPOT, 0, 0, "output in Spot's syntax (default)", -20 },
{ "lbt", 'l', 0, 0, "output in LBT's syntax", -20 },
{ "wring", OPT_WRING, 0, 0, "output in Wring's syntax", -20 },
{ "utf8", '8', 0, 0, "output using UTF-8 characters", -20 },
{ 0, 0, 0, 0, 0, 0 }
};
@ -64,6 +66,9 @@ parse_opt_output(int key, char*, struct argp_state*)
case OPT_SPOT:
output_format = spot_output;
break;
case OPT_WRING:
output_format = wring_output;
break;
default:
return ARGP_ERR_UNKNOWN;
}
@ -105,6 +110,12 @@ output_formula(const spot::ltl::formula* f, const char* filename, int linenum)
else
report_not_ltl(f, filename, linenum, "Spin");
break;
case wring_output:
if (f->is_ltl_formula())
spot::ltl::to_wring_string(f, std::cout);
else
report_not_ltl(f, filename, linenum, "Wring");
break;
case utf8_output:
spot::ltl::to_utf8_string(f, std::cout, full_parenth);
break;

View file

@ -25,7 +25,8 @@
#include <argp.h>
#include "ltlast/formula.hh"
enum output_format_t { spot_output, spin_output, utf8_output, lbt_output };
enum output_format_t { spot_output, spin_output, utf8_output,
lbt_output, wring_output };
extern output_format_t output_format;
extern bool full_parenth;

View file

@ -92,10 +92,11 @@ static const argp_option options[] =
{ 0, 0, 0, 0,
"COMMANDFMT should specify input and output arguments using the "
"following character sequences:", 3 },
{ "%f,%s,%l", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the formula as a (quoted) string in Spot, Spin, or LBT's syntax", 0 },
{ "%F,%S,%L", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the formula as a file in Spot, Spin, or LBT's syntax", 0 },
{ "%f,%s,%l,%w", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the formula as a (quoted) string in Spot, Spin, LBT, or Wring's syntax",
0 },
{ "%F,%S,%L,%W", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the formula as a file in Spot, Spin, LBT, or Wring's syntax", 0 },
{ "%N,%T", 0, 0, OPTION_DOC | OPTION_NO_USAGE,
"the output automaton as a Never claim, or in LBTT's format", 0 },
{ 0, 0, 0, 0,
@ -458,9 +459,11 @@ namespace
quoted_string string_ltl_spot;
quoted_string string_ltl_spin;
quoted_string string_ltl_lbt;
quoted_string string_ltl_wring;
quoted_string filename_ltl_spot;
quoted_string filename_ltl_spin;
quoted_string filename_ltl_lbt;
quoted_string filename_ltl_wring;
// Run-specific variables
printable_result_filename output;
public:
@ -472,9 +475,11 @@ namespace
declare('f', &string_ltl_spot);
declare('s', &string_ltl_spin);
declare('l', &string_ltl_lbt);
declare('w', &string_ltl_wring);
declare('F', &filename_ltl_spot);
declare('S', &filename_ltl_spin);
declare('L', &filename_ltl_lbt);
declare('W', &filename_ltl_wring);
declare('N', &output);
declare('T', &output);
@ -503,6 +508,8 @@ namespace
return string_ltl_spot;
if (!string_ltl_spin.val().empty())
return string_ltl_spin;
if (!string_ltl_wring.val().empty())
return string_ltl_wring;
if (!string_ltl_lbt.val().empty())
return string_ltl_lbt;
error(2, 0, "None of the translators need the input formula?");
@ -518,12 +525,16 @@ namespace
string_ltl_spin = spot::ltl::to_spin_string(f, true);
if (has('l') || has('L'))
string_ltl_lbt = spot::ltl::to_lbt_string(f);
if (has('w') || has('W'))
string_ltl_wring = spot::ltl::to_wring_string(f);
if (has('F'))
string_to_tmp(string_ltl_spot, serial, filename_ltl_spot);
if (has('S'))
string_to_tmp(string_ltl_spin, serial, filename_ltl_spin);
if (has('L'))
string_to_tmp(string_ltl_lbt, serial, filename_ltl_lbt);
if (has('W'))
string_to_tmp(string_ltl_wring, serial, filename_ltl_wring);
}
const spot::tgba*