bin: factor handling of -B/-C/-D/... output options
* src/bin/common_post.cc: Handle the options for BA/TGBA/Monitor as well as Complete/SBAcc here, and in the same group. Rename "Translation intent" and "Optimization level" to "Simplification goal" and "Simplification level" so that it makes sense even in autfilt. * src/bin/autfilt.cc, src/bin/dstar2tgba.cc, src/bin/ltl2tgba.cc: Remove common code. * doc/org/autfilt.org, doc/org/dstar2tgba.org, doc/org/ltl2tgba.org: Adjust sed invocations.
This commit is contained in:
parent
dee73ee342
commit
71979840cb
7 changed files with 97 additions and 127 deletions
|
|
@ -101,7 +101,6 @@ enum {
|
|||
OPT_SIMPLIFY_EXCLUSIVE_AP,
|
||||
OPT_STATES,
|
||||
OPT_STRIPACC,
|
||||
OPT_TGBA,
|
||||
};
|
||||
|
||||
static const argp_option options[] =
|
||||
|
|
@ -111,16 +110,6 @@ static const argp_option options[] =
|
|||
{ "file", 'F', "FILENAME", 0,
|
||||
"process the automaton in FILENAME", 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Output automaton type:", 2 },
|
||||
{ "generic", OPT_GENERIC, nullptr, 0,
|
||||
"Any acceptance is allowed (default)", 0 },
|
||||
{ "tgba", OPT_TGBA, nullptr, 0,
|
||||
"Transition-based Generalized Büchi Automaton", 0 },
|
||||
{ "ba", 'B', nullptr, 0,
|
||||
"Büchi Automaton (with state-based acceptance)", 0 },
|
||||
{ "monitor", 'M', nullptr, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given property)", 0 },
|
||||
/**************************************************/
|
||||
{ "count", 'c', nullptr, 0, "print only a count of matched automata", 3 },
|
||||
{ "max-count", 'n', "NUM", 0, "output at most NUM automata", 3 },
|
||||
/**************************************************/
|
||||
|
|
@ -213,9 +202,9 @@ static const argp_option options[] =
|
|||
RANGE_DOC_FULL,
|
||||
{ nullptr, 0, nullptr, 0,
|
||||
"If any option among --small, --deterministic, or --any is given, "
|
||||
"then the optimization level defaults to --high unless specified "
|
||||
"then the simplification level defaults to --high unless specified "
|
||||
"otherwise. If any option among --low, --medium, or --high is given, "
|
||||
"then the translation intent defaults to --small unless specified "
|
||||
"then the simplification goal defaults to --small unless specified "
|
||||
"otherwise. If none of those options are specified, then autfilt "
|
||||
"acts as is --any --low were given: these actually disable the "
|
||||
"simplification routines.", 22 },
|
||||
|
|
@ -233,7 +222,7 @@ static const struct argp_child children[] =
|
|||
{ &hoaread_argp, 0, nullptr, 0 },
|
||||
{ &aoutput_argp, 0, nullptr, 0 },
|
||||
{ &aoutput_io_format_argp, 0, nullptr, 4 },
|
||||
{ &post_argp_disabled, 0, nullptr, 20 },
|
||||
{ &post_argp_disabled, 0, nullptr, 0 },
|
||||
{ &misc_argp, 0, nullptr, -1 },
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
|
@ -298,18 +287,12 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
// This switch is alphabetically-ordered.
|
||||
switch (key)
|
||||
{
|
||||
case 'B':
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case 'c':
|
||||
automaton_format = Count;
|
||||
break;
|
||||
case 'F':
|
||||
jobs.emplace_back(arg, true);
|
||||
break;
|
||||
case 'M':
|
||||
type = spot::postprocessor::Monitor;
|
||||
break;
|
||||
case 'n':
|
||||
opt_max_count = to_pos_int(arg);
|
||||
break;
|
||||
|
|
@ -359,8 +342,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
case OPT_EXCLUSIVE_AP:
|
||||
excl_ap.add_group(arg);
|
||||
break;
|
||||
case OPT_GENERIC:
|
||||
type = spot::postprocessor::Generic;
|
||||
case OPT_INSTUT:
|
||||
if (!arg || (arg[0] == '1' && arg[1] == 0))
|
||||
opt_instut = 1;
|
||||
|
|
@ -493,11 +474,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
case OPT_STRIPACC:
|
||||
opt_stripacc = true;
|
||||
break;
|
||||
case OPT_TGBA:
|
||||
if (automaton_format == Spin)
|
||||
error(2, 0, "--spin and --tgba are incompatible");
|
||||
type = spot::postprocessor::TGBA;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
jobs.emplace_back(arg, true);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "common_post.hh"
|
||||
#include "common_r.hh"
|
||||
#include "common_aoutput.hh"
|
||||
#include "error.h"
|
||||
|
||||
spot::postprocessor::output_type type = spot::postprocessor::TGBA;
|
||||
|
|
@ -31,27 +32,36 @@ bool level_set = false;
|
|||
bool pref_set = false;
|
||||
|
||||
enum {
|
||||
OPT_HIGH = 1,
|
||||
OPT_GENERIC = 1,
|
||||
OPT_HIGH,
|
||||
OPT_LOW,
|
||||
OPT_MEDIUM,
|
||||
OPT_SMALL,
|
||||
OPT_TGBA,
|
||||
};
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Translation intent:", 20 },
|
||||
{ "small", OPT_SMALL, nullptr, 0, "prefer small automata (default)", 0 },
|
||||
{ "deterministic", 'D', nullptr, 0, "prefer deterministic automata", 0 },
|
||||
{ "any", 'a', nullptr, 0, "no preference, do not bother making it small "
|
||||
"or deterministic", 0 },
|
||||
{ "complete", 'C', nullptr, 0, "output a complete automaton (combine "
|
||||
"with other intents)", 0 },
|
||||
{ nullptr, 0, nullptr, 0, "Output automaton type:", 2 },
|
||||
{ "tgba", OPT_TGBA, nullptr, 0,
|
||||
"Transition-based Generalized Büchi Automaton (default)", 0 },
|
||||
{ "ba", 'B', nullptr, 0,
|
||||
"Büchi Automaton (implies -S)", 0 },
|
||||
{ "monitor", 'M', nullptr, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given property)", 0 },
|
||||
{ "complete", 'C', nullptr, 0, "output a complete automaton", 0 },
|
||||
{ "state-based-acceptance", 'S', nullptr, 0,
|
||||
"define the acceptance using states", 0 },
|
||||
{ "sbacc", 0, nullptr, OPTION_ALIAS, nullptr, 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Optimization level:", 21 },
|
||||
{ nullptr, 0, nullptr, 0, "Simplification goal:", 20 },
|
||||
{ "small", OPT_SMALL, nullptr, 0, "prefer small automata (default)", 0 },
|
||||
{ "deterministic", 'D', nullptr, 0, "prefer deterministic automata", 0 },
|
||||
{ "any", 'a', nullptr, 0, "no preference, do not bother making it small "
|
||||
"or deterministic", 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Simplification level:", 21 },
|
||||
{ "low", OPT_LOW, nullptr, 0, "minimal optimizations (fast)", 0 },
|
||||
{ "medium", OPT_MEDIUM, nullptr, 0, "moderate optimizations", 0 },
|
||||
{ "high", OPT_HIGH, nullptr, 0,
|
||||
|
|
@ -62,18 +72,27 @@ static const argp_option options[] =
|
|||
static const argp_option options_disabled[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Translation intent:", 20 },
|
||||
{ "small", OPT_SMALL, nullptr, 0, "prefer small automata", 0 },
|
||||
{ "deterministic", 'D', nullptr, 0, "prefer deterministic automata", 0 },
|
||||
{ "any", 'a', nullptr, 0, "no preference, do not bother making it small "
|
||||
"or deterministic", 0 },
|
||||
{ "complete", 'C', nullptr, 0, "output a complete automaton (combine "
|
||||
"with other intents)", 0 },
|
||||
{ nullptr, 0, nullptr, 0, "Output automaton type:", 2 },
|
||||
{ "generic", OPT_GENERIC, nullptr, 0,
|
||||
"Any acceptance is allowed (default)", 0 },
|
||||
{ "tgba", OPT_TGBA, nullptr, 0,
|
||||
"Transition-based Generalized Büchi Automaton", 0 },
|
||||
{ "ba", 'B', nullptr, 0,
|
||||
"Büchi Automaton (with state-based acceptance)", 0 },
|
||||
{ "monitor", 'M', nullptr, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given property)", 0 },
|
||||
{ "complete", 'C', nullptr, 0, "output a complete automaton", 0 },
|
||||
{ "state-based-acceptance", 'S', nullptr, 0,
|
||||
"define the acceptance using states", 0 },
|
||||
{ "sbacc", 0, nullptr, OPTION_ALIAS, nullptr, 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Optimization level:", 21 },
|
||||
{ nullptr, 0, nullptr, 0, "Simplification goal:", 20 },
|
||||
{ "small", OPT_SMALL, nullptr, 0, "prefer small automata", 0 },
|
||||
{ "deterministic", 'D', nullptr, 0, "prefer deterministic automata", 0 },
|
||||
{ "any", 'a', nullptr, 0, "no preference, do not bother making it small "
|
||||
"or deterministic", 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Simplification level:", 21 },
|
||||
{ "low", OPT_LOW, nullptr, 0, "minimal optimizations (fast)", 0 },
|
||||
{ "medium", OPT_MEDIUM, nullptr, 0, "moderate optimizations", 0 },
|
||||
{ "high", OPT_HIGH, nullptr, 0,
|
||||
|
|
@ -91,6 +110,9 @@ parse_opt_post(int key, char*, struct argp_state*)
|
|||
pref = spot::postprocessor::Any;
|
||||
pref_set = true;
|
||||
break;
|
||||
case 'B':
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case 'C':
|
||||
comp = spot::postprocessor::Complete;
|
||||
break;
|
||||
|
|
@ -98,9 +120,15 @@ parse_opt_post(int key, char*, struct argp_state*)
|
|||
pref = spot::postprocessor::Deterministic;
|
||||
pref_set = true;
|
||||
break;
|
||||
case 'M':
|
||||
type = spot::postprocessor::Monitor;
|
||||
break;
|
||||
case 'S':
|
||||
sbacc = spot::postprocessor::SBAcc;
|
||||
break;
|
||||
case OPT_GENERIC:
|
||||
type = spot::postprocessor::Generic;
|
||||
break;
|
||||
case OPT_HIGH:
|
||||
level = spot::postprocessor::High;
|
||||
simplification_level = 3;
|
||||
|
|
@ -120,6 +148,11 @@ parse_opt_post(int key, char*, struct argp_state*)
|
|||
pref = spot::postprocessor::Small;
|
||||
pref_set = true;
|
||||
break;
|
||||
case OPT_TGBA:
|
||||
if (automaton_format == Spin)
|
||||
error(2, 0, "--spin and --tgba are incompatible");
|
||||
type = spot::postprocessor::TGBA;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,6 @@ Büchi automata.\n\nThis reads automata into any supported format \
|
|||
Transition-based Generalized Büchi Automata in GraphViz's format by default. \
|
||||
Each supplied file may contain multiple automata.";
|
||||
|
||||
enum {
|
||||
OPT_TGBA = 1,
|
||||
};
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
|
|
@ -64,14 +60,6 @@ static const argp_option options[] =
|
|||
{ "file", 'F', "FILENAME", 0,
|
||||
"process the automaton in FILENAME", 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Output automaton type:", 2 },
|
||||
{ "tgba", OPT_TGBA, nullptr, 0,
|
||||
"Transition-based Generalized Büchi Automaton (default)", 0 },
|
||||
{ "ba", 'B', nullptr, 0,
|
||||
"Büchi Automaton (with state-based acceptance)", 0 },
|
||||
{ "monitor", 'M', nullptr, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given property)", 0 },
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ "extra-options", 'x', "OPTS", 0,
|
||||
"fine-tuning options (see spot-x (7))", 0 },
|
||||
|
|
@ -83,7 +71,7 @@ static const struct argp_child children[] =
|
|||
{ &hoaread_argp, 0, nullptr, 0 },
|
||||
{ &aoutput_argp, 0, nullptr, 0 },
|
||||
{ &aoutput_io_format_argp, 0, nullptr, 4 },
|
||||
{ &post_argp, 0, nullptr, 20 },
|
||||
{ &post_argp, 0, nullptr, 0 },
|
||||
{ &misc_argp, 0, nullptr, -1 },
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
|
@ -96,15 +84,9 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
// This switch is alphabetically-ordered.
|
||||
switch (key)
|
||||
{
|
||||
case 'B':
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case 'F':
|
||||
jobs.emplace_back(arg, true);
|
||||
break;
|
||||
case 'M':
|
||||
type = spot::postprocessor::Monitor;
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
const char* opt = extra_options.parse_options(arg);
|
||||
|
|
@ -112,11 +94,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
error(2, 0, "failed to parse --options near '%s'", opt);
|
||||
}
|
||||
break;
|
||||
case OPT_TGBA:
|
||||
if (automaton_format == Spin)
|
||||
error(2, 0, "--spin and --tgba are incompatible");
|
||||
type = spot::postprocessor::TGBA;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
jobs.emplace_back(arg, true);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -47,26 +47,13 @@ in GraphViz's format.\n\
|
|||
If multiple formulas are supplied, several automata will be output.";
|
||||
|
||||
|
||||
enum {
|
||||
OPT_TGBA = 1,
|
||||
};
|
||||
|
||||
static const argp_option options[] =
|
||||
{
|
||||
/**************************************************/
|
||||
{ nullptr, 0, nullptr, 0, "Output automaton type:", 2 },
|
||||
{ "tgba", OPT_TGBA, nullptr, 0,
|
||||
"Transition-based Generalized Büchi Automaton (default)", 0 },
|
||||
{ "ba", 'B', nullptr, 0,
|
||||
"Büchi Automaton (with state-based acceptance)", 0 },
|
||||
{ "monitor", 'M', nullptr, 0, "Monitor (accepts all finite prefixes "
|
||||
"of the given formula)", 0 },
|
||||
/**************************************************/
|
||||
{ "%f", 0, nullptr, OPTION_DOC | OPTION_NO_USAGE,
|
||||
"the formula, in Spot's syntax", 4 },
|
||||
/**************************************************/
|
||||
{ "unambiguous", 'U', nullptr, 0, "output unambiguous automata "
|
||||
"(combine with other intents)", 20 },
|
||||
{ "unambiguous", 'U', nullptr, 0, "output unambiguous automata", 2 },
|
||||
{ nullptr, 0, nullptr, 0, "Miscellaneous options:", -1 },
|
||||
{ "extra-options", 'x', "OPTS", 0,
|
||||
"fine-tuning options (see spot-x (7))", 0 },
|
||||
|
|
@ -92,12 +79,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
// This switch is alphabetically-ordered.
|
||||
switch (key)
|
||||
{
|
||||
case 'B':
|
||||
type = spot::postprocessor::BA;
|
||||
break;
|
||||
case 'M':
|
||||
type = spot::postprocessor::Monitor;
|
||||
break;
|
||||
case 'U':
|
||||
unambig = spot::postprocessor::Unambiguous;
|
||||
break;
|
||||
|
|
@ -108,11 +89,6 @@ parse_opt(int key, char* arg, struct argp_state*)
|
|||
error(2, 0, "failed to parse --options near '%s'", opt);
|
||||
}
|
||||
break;
|
||||
case OPT_TGBA:
|
||||
if (automaton_format == Spin)
|
||||
error(2, 0, "--spin and --tgba are incompatible");
|
||||
type = spot::postprocessor::TGBA;
|
||||
break;
|
||||
case ARGP_KEY_ARG:
|
||||
// FIXME: use stat() to distinguish filename from string?
|
||||
jobs.emplace_back(arg, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue