bin: %a,%b,%s format specs for LTL output
* NEWS: Mention those. * bin/common_output.cc, bin/common_output.hh: Implement them. * bin/genltl.cc, bin/ltlfilt.cc, bin/ltlgrind.cc, bin/randltl.cc: Update --help. * tests/core/format.test: New file. * tests/Makefile.am: Add it. * doc/org/ioltl.org, doc/org/ltlfilt.org: Update documentation.
This commit is contained in:
parent
0210080152
commit
926ffbf965
11 changed files with 177 additions and 21 deletions
|
|
@ -22,6 +22,8 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <spot/tl/print.hh>
|
||||
#include <spot/tl/length.hh>
|
||||
#include <spot/tl/apcollect.hh>
|
||||
#include <spot/misc/formater.hh>
|
||||
#include <spot/misc/escape.hh>
|
||||
#include "common_cout.hh"
|
||||
|
|
@ -179,12 +181,16 @@ namespace
|
|||
formula_printer(std::ostream& os, const char* format)
|
||||
: format_(format)
|
||||
{
|
||||
declare('a', &ap_num_);
|
||||
declare('b', &bool_size_);
|
||||
declare('f', &fl_);
|
||||
declare('F', &filename_);
|
||||
declare('L', &line_);
|
||||
declare('s', &size_);
|
||||
declare('<', &prefix_);
|
||||
declare('>', &suffix_);
|
||||
set_output(os);
|
||||
prime(format);
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
|
|
@ -195,6 +201,17 @@ namespace
|
|||
line_ = fl.line;
|
||||
prefix_ = fl.prefix ? fl.prefix : "";
|
||||
suffix_ = fl.suffix ? fl.suffix : "";
|
||||
auto f = fl_.val()->f;
|
||||
if (has('a'))
|
||||
{
|
||||
auto s = spot::atomic_prop_collect(f);
|
||||
ap_num_ = s->size();
|
||||
delete s;
|
||||
}
|
||||
if (has('b'))
|
||||
bool_size_ = spot::length_boolone(f);
|
||||
if (has('s'))
|
||||
size_ = spot::length(f);
|
||||
return format(format_);
|
||||
}
|
||||
|
||||
|
|
@ -205,6 +222,9 @@ namespace
|
|||
spot::printable_value<int> line_;
|
||||
spot::printable_value<const char*> prefix_;
|
||||
spot::printable_value<const char*> suffix_;
|
||||
spot::printable_value<int> size_;
|
||||
spot::printable_value<int> bool_size_;
|
||||
spot::printable_value<int> ap_num_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,15 @@ extern output_format_t output_format;
|
|||
extern bool full_parenth;
|
||||
extern bool escape_csv;
|
||||
|
||||
#define COMMON_LTL_OUTPUT_SPECS \
|
||||
{ "%a", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, \
|
||||
"number of atomic propositions used in the formula", 0 }, \
|
||||
{ "%s", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, \
|
||||
"the length (or size) of the formula", 0 }, \
|
||||
{ "%b", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE, \
|
||||
"the Boolean-length of the formula (i.e., all Boolean " \
|
||||
"subformulas count as 1)", 0 }
|
||||
|
||||
extern const struct argp output_argp;
|
||||
|
||||
int parse_opt_output(int key, char* arg, struct argp_state* state);
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ static const argp_option options[] =
|
|||
"the argument of the pattern", 0 },
|
||||
{ "%%", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
COMMON_LTL_OUTPUT_SPECS,
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ nullptr, 0, nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ static const argp_option options[] =
|
|||
"comes from a column extracted from a CSV file", 0 },
|
||||
{ "%%", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
COMMON_LTL_OUTPUT_SPECS,
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ nullptr, 0, nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -96,8 +96,9 @@ static const argp_option options[] = {
|
|||
"comes from a column extracted from a CSV file", 0 },
|
||||
{ "%%", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
{nullptr, 0, nullptr, 0, "Miscellaneous options:", -1},
|
||||
{nullptr, 0, nullptr, 0, nullptr, 0}
|
||||
COMMON_LTL_OUTPUT_SPECS,
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ nullptr, 0, nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
static const argp_child children[] = {
|
||||
|
|
|
|||
|
|
@ -119,6 +119,7 @@ static const argp_option options[] =
|
|||
"the (serial) number of the formula", 0 },
|
||||
{ "%%", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"a single %", 0 },
|
||||
COMMON_LTL_OUTPUT_SPECS,
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ nullptr, 0, nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue