bin: use regexes to detect shorthands, and add support for owl-21.0
Fixes #480. * bin/common_trans.cc (shorthands_ltl, shorthands_autproc): Write those lists using regexes. Add entries for Owl 21.0. (show_shorthands, tool_spec): Adjust to use those regexes. * doc/org/autcross.org, doc/org/ltlcross.org, doc/org/ltldo.org: Update the list of shorthands. * tests/core/ltldo.test: Add a couple of tests. * NEWS: Mention this new feature.
This commit is contained in:
parent
97046ea263
commit
f99ddef787
6 changed files with 90 additions and 76 deletions
6
NEWS
6
NEWS
|
|
@ -56,6 +56,12 @@ New in spot 2.9.8.dev (not yet released)
|
||||||
|
|
||||||
- autfilt learned a --kill-states=NUM[,NUM...] option.
|
- autfilt learned a --kill-states=NUM[,NUM...] option.
|
||||||
|
|
||||||
|
- ltlcross, autcross, ltldo have learned shorthands for
|
||||||
|
the commands of Owl 21.0. For instance running
|
||||||
|
ltlcross 'owl-21 ltl2nba' ...
|
||||||
|
is equivalent to running
|
||||||
|
ltlcross '{owl-21 ltl2nba}owl-21 ltl2nba -f %f>%O' ...
|
||||||
|
|
||||||
Library:
|
Library:
|
||||||
- Spot now provides convenient function to create and solve games.
|
- Spot now provides convenient function to create and solve games.
|
||||||
The functions are located in twaalgos/game.hh. Additional
|
The functions are located in twaalgos/game.hh. Additional
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// -*- coding: utf-8 -*-
|
// -*- coding: utf-8 -*-
|
||||||
// Copyright (C) 2015-2020 Laboratoire de Recherche et Développement
|
// Copyright (C) 2015-2021 Laboratoire de Recherche et Développement
|
||||||
// de l'Epita (LRDE).
|
// de l'Epita (LRDE).
|
||||||
//
|
//
|
||||||
// This file is part of Spot, a model checking library.
|
// This file is part of Spot, a model checking library.
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#ifdef HAVE_SPAWN_H
|
#ifdef HAVE_SPAWN_H
|
||||||
#include <spawn.h>
|
#include <spawn.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
|
|
@ -45,49 +46,52 @@
|
||||||
struct shorthands_t
|
struct shorthands_t
|
||||||
{
|
{
|
||||||
const char* prefix;
|
const char* prefix;
|
||||||
|
std::regex rprefix;
|
||||||
const char* suffix;
|
const char* suffix;
|
||||||
};
|
};
|
||||||
|
#define SHORTHAND(PRE, POST) { PRE, std::regex("^" PRE), POST }
|
||||||
|
|
||||||
static shorthands_t shorthands_ltl[] = {
|
static shorthands_t shorthands_ltl[] = {
|
||||||
{ "delag", " %f>%O" },
|
SHORTHAND("delag", " %f>%O"),
|
||||||
{ "lbt", " <%L>%O" },
|
SHORTHAND("lbt", " <%L>%O"),
|
||||||
{ "ltl2ba", " -f %s>%O" },
|
SHORTHAND("ltl2ba", " -f %s>%O"),
|
||||||
{ "ltl2da", " %f>%O" },
|
SHORTHAND("ltl2(da|dgra|dpa|dra|ldba|na|nba|ngba)", " %f>%O"),
|
||||||
{ "ltl2dgra", " %f>%O" },
|
SHORTHAND("ltl2dstar", " --output-format=hoa %[MW]L %O"),
|
||||||
{ "ltl2dpa", " %f>%O" },
|
SHORTHAND("ltl2tgba", " -H %f>%O"),
|
||||||
{ "ltl2dra", " %f>%O" },
|
// ltl3tela is the new name of ltl3hoa
|
||||||
{ "ltl2dstar", " --output-format=hoa %[MW]L %O"},
|
SHORTHAND("ltl3(ba|dra|hoa|tela)", " -f %s>%O"),
|
||||||
{ "ltl2ldba", " %f>%O" },
|
SHORTHAND("modella", " %[MWei^]L %O"),
|
||||||
{ "ltl2na", " %f>%O" },
|
SHORTHAND("spin", " -f %s>%O"),
|
||||||
{ "ltl2nba", " %f>%O" },
|
// Starting from Owl 21.0, Owl's tools have been grouped as
|
||||||
{ "ltl2ngba", " %f>%O" },
|
// sub-commands of the Owl binary. We still want to support
|
||||||
{ "ltl2tgba", " -H %f>%O" },
|
// use cases where several version of owl are installed with
|
||||||
{ "ltl3ba", " -f %s>%O" },
|
// different names.
|
||||||
{ "ltl3dra", " -f %s>%O" },
|
SHORTHAND("owl.* ltl2[bdeglnpr]+a\\b", " -f %f>%O"),
|
||||||
{ "ltl3hoa", " -f %f>%O" },
|
SHORTHAND("owl.* ltl2delta2\\b", " -f %f"),
|
||||||
{ "ltl3tela", " -f %f>%O" }, // ltl3tela is the new name of ltl3hoa
|
SHORTHAND("owl.* ltl-utilities\\b", " -f %f"),
|
||||||
{ "modella", " %[MWei^]L %O" },
|
};
|
||||||
{ "spin", " -f %s>%O" },
|
|
||||||
};
|
|
||||||
|
|
||||||
static shorthands_t shorthands_autproc[] = {
|
static shorthands_t shorthands_autproc[] = {
|
||||||
{ "autfilt", " %H>%O" },
|
SHORTHAND("autfilt", " %H>%O"),
|
||||||
{ "dra2dpa", " <%H>%O" },
|
SHORTHAND("dra2dpa", " <%H>%O"),
|
||||||
{ "dstar2tgba", " %H>%O" },
|
SHORTHAND("dstar2tgba", " %H>%O"),
|
||||||
{ "ltl2dstar", " -B %H %O" },
|
SHORTHAND("ltl2dstar", " -B %H %O"),
|
||||||
{ "nba2dpa", " <%H>%O" },
|
SHORTHAND("nba2l?dpa", " <%H>%O"),
|
||||||
{ "nba2ldpa", " <%H>%O" },
|
SHORTHAND("seminator", " %H>%O"),
|
||||||
{ "seminator", " %H>%O" },
|
SHORTHAND("owl.* "
|
||||||
};
|
"(ngba2ldba|nba(2dpa|2det|sim)|aut2parity|gfg-minimization)\\b",
|
||||||
|
" <%H>%O"),
|
||||||
|
};
|
||||||
|
|
||||||
static void show_shorthands(shorthands_t* begin, shorthands_t* end)
|
static void show_shorthands(shorthands_t* begin, shorthands_t* end)
|
||||||
{
|
{
|
||||||
std::cout
|
std::cout
|
||||||
<< ("If a COMMANDFMT does not use any %-sequence, and starts with one of\n"
|
<< ("If a COMMANDFMT does not use any %-sequence, and starts with one of\n"
|
||||||
"the following words, then the string on the right is appended.\n\n");
|
"the following regexes, then the string on the right is appended.\n\n");
|
||||||
while (begin != end)
|
while (begin != end)
|
||||||
{
|
{
|
||||||
std::cout << " "
|
std::cout << " "
|
||||||
<< std::left << std::setw(12) << begin->prefix
|
<< std::left << std::setw(40) << begin->prefix
|
||||||
<< begin->suffix << '\n';
|
<< begin->suffix << '\n';
|
||||||
++begin;
|
++begin;
|
||||||
}
|
}
|
||||||
|
|
@ -139,8 +143,7 @@ tool_spec::tool_spec(const char* spec, shorthands_t* begin, shorthands_t* end,
|
||||||
while (begin != end)
|
while (begin != end)
|
||||||
{
|
{
|
||||||
auto& p = *begin++;
|
auto& p = *begin++;
|
||||||
int n = strlen(p.prefix);
|
if (std::regex_search(basename, p.rprefix))
|
||||||
if (strncmp(basename, p.prefix, n) == 0)
|
|
||||||
{
|
{
|
||||||
int m = strlen(p.suffix);
|
int m = strlen(p.suffix);
|
||||||
int q = strlen(cmd);
|
int q = strlen(cmd);
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,15 @@ autcross --list-shorthands
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
#+begin_example
|
#+begin_example
|
||||||
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
||||||
the following words, then the string on the right is appended.
|
the following regexes, then the string on the right is appended.
|
||||||
|
|
||||||
autfilt %H>%O
|
autfilt %H>%O
|
||||||
dstar2tgba %H>%O
|
dra2dpa <%H>%O
|
||||||
ltl2dstar -B %H %O
|
dstar2tgba %H>%O
|
||||||
nba2dpa <%H>%O
|
ltl2dstar -B %H %O
|
||||||
nba2ldpa <%H>%O
|
nba2l?dpa <%H>%O
|
||||||
seminator %H>%O
|
seminator %H>%O
|
||||||
|
owl.* (ngba2ldba|nba(2dpa|2det|sim)|aut2parity|gfg-minimization)\b <%H>%O
|
||||||
|
|
||||||
Any {name} and directory component is skipped for the purpose of
|
Any {name} and directory component is skipped for the purpose of
|
||||||
matching those prefixes. So for instance
|
matching those prefixes. So for instance
|
||||||
|
|
|
||||||
|
|
@ -185,24 +185,20 @@ ltlcross --list-shorthands
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
#+begin_example
|
#+begin_example
|
||||||
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
||||||
the following words, then the string on the right is appended.
|
the following regexes, then the string on the right is appended.
|
||||||
|
|
||||||
delag %f>%O
|
delag %f>%O
|
||||||
lbt <%L>%O
|
lbt <%L>%O
|
||||||
ltl2ba -f %s>%O
|
ltl2ba -f %s>%O
|
||||||
ltl2da %f>%O
|
ltl2(da|dgra|dpa|dra|ldba|na|nba|ngba) %f>%O
|
||||||
ltl2dgra %f>%O
|
ltl2dstar --output-format=hoa %[MW]L %O
|
||||||
ltl2dpa %f>%O
|
ltl2tgba -H %f>%O
|
||||||
ltl2dra %f>%O
|
ltl3(ba|dra|hoa|tela) -f %s>%O
|
||||||
ltl2ldba %f>%O
|
modella %[MWei^]L %O
|
||||||
ltl2dstar --output-format=hoa %[MW]L %O
|
spin -f %s>%O
|
||||||
ltl2tgba -H %f>%O
|
owl.* ltl2[bdeglnpr]+a\b -f %f>%O
|
||||||
ltl3ba -f %s>%O
|
owl.* ltl2delta2\b -f %f
|
||||||
ltl3dra -f %s>%O
|
owl.* ltl-utilities\b -f %f
|
||||||
ltl3hoa -f %f>%O
|
|
||||||
ltl3tela -f %f>%O
|
|
||||||
modella %[MWei^]L %O
|
|
||||||
spin -f %s>%O
|
|
||||||
|
|
||||||
Any {name} and directory component is skipped for the purpose of
|
Any {name} and directory component is skipped for the purpose of
|
||||||
matching those prefixes. So for instance
|
matching those prefixes. So for instance
|
||||||
|
|
|
||||||
|
|
@ -306,26 +306,26 @@ ltldo --list-shorthands
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
#+begin_example
|
#+begin_example
|
||||||
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
If a COMMANDFMT does not use any %-sequence, and starts with one of
|
||||||
the following words, then the string on the right is appended.
|
the following regexes, then the string on the right is appended.
|
||||||
|
|
||||||
lbt <%L>%O
|
delag %f>%O
|
||||||
ltl2ba -f %s>%O
|
lbt <%L>%O
|
||||||
ltl2da %f>%O
|
ltl2ba -f %s>%O
|
||||||
ltl2dpa %f>%O
|
ltl2(da|dgra|dpa|dra|ldba|na|nba|ngba) %f>%O
|
||||||
ltl2ldba %f>%O
|
ltl2dstar --output-format=hoa %[MW]L %O
|
||||||
ltl2dstar --output-format=hoa %[MW]L %O
|
ltl2tgba -H %f>%O
|
||||||
ltl2tgba -H %f>%O
|
ltl3(ba|dra|hoa|tela) -f %s>%O
|
||||||
ltl3ba -f %s>%O
|
modella %[MWei^]L %O
|
||||||
ltl3dra -f %s>%O
|
spin -f %s>%O
|
||||||
ltl3hoa -f %f>%O
|
owl.* ltl2[bdeglnpr]+a\b -f %f>%O
|
||||||
modella %[MWei^]L %O
|
owl.* ltl2delta2\b -f %f
|
||||||
spin -f %s>%O
|
owl.* ltl-utilities\b -f %f
|
||||||
|
|
||||||
Any {name} and directory component is skipped for the purpose of
|
Any {name} and directory component is skipped for the purpose of
|
||||||
matching those prefixes. So for instance
|
matching those prefixes. So for instance
|
||||||
'{DRA} ~/mytools/ltl2dstar-0.5.2'
|
'{DRA} ~/mytools/ltl2dstar-0.5.2'
|
||||||
will changed into
|
will be changed into
|
||||||
'{DRA} ~/mytools/ltl2dstar-0.5.2 --output-format=hoa %[MR]L %O'
|
'{DRA} ~/mytools/ltl2dstar-0.5.2 --output-format=hoa %[MW]L %O'
|
||||||
#+end_example
|
#+end_example
|
||||||
|
|
||||||
Therefore you can type the following to obtain a Dot output (as
|
Therefore you can type the following to obtain a Dot output (as
|
||||||
|
|
@ -353,9 +353,10 @@ digraph "" {
|
||||||
The =ltl2ba= argument passed to =ltldo= was interpreted as if you had
|
The =ltl2ba= argument passed to =ltldo= was interpreted as if you had
|
||||||
typed ={ltl2ba}ltl2ba -f %s>%O=.
|
typed ={ltl2ba}ltl2ba -f %s>%O=.
|
||||||
|
|
||||||
The shorthand is only used if it is the first word of a command
|
Those shorthand patterns are only tested if the command string does
|
||||||
string that does not use any =%= character. This makes it possible to
|
not contains any =%= character. They should always patch a prefix of
|
||||||
add options:
|
the command, ignoring any leading directory. This makes it possible
|
||||||
|
to add options:
|
||||||
|
|
||||||
#+BEGIN_SRC sh
|
#+BEGIN_SRC sh
|
||||||
ltldo ltl3ba 'ltl3ba -H2' -f GFa --stats='%T, %s states, %e edges'
|
ltldo ltl3ba 'ltl3ba -H2' -f GFa --stats='%T, %s states, %e edges'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Copyright (C) 2015-2020 Laboratoire de Recherche et Développement de
|
# Copyright (C) 2015-2021 Laboratoire de Recherche et Développement de
|
||||||
# l'Epita (LRDE).
|
# l'Epita (LRDE).
|
||||||
#
|
#
|
||||||
# This file is part of Spot, a model checking library.
|
# This file is part of Spot, a model checking library.
|
||||||
|
|
@ -157,8 +157,15 @@ grep ':.*empty input' stderr
|
||||||
|
|
||||||
|
|
||||||
ltldo '{name} foo/bar/ltl2baextended' -f GFa 2>stderr && exit 1
|
ltldo '{name} foo/bar/ltl2baextended' -f GFa 2>stderr && exit 1
|
||||||
|
grep % stderr && exit 1
|
||||||
grep 'ltldo:.*foo/bar/ltl2baextended' stderr
|
grep 'ltldo:.*foo/bar/ltl2baextended' stderr
|
||||||
|
|
||||||
|
ltldo '{name} foo/bar/owl-21.00 ltl2nba' -f GFa 2>stderr && exit 1
|
||||||
|
grep % stderr && exit 1
|
||||||
|
grep 'ltldo:.*foo/bar/owl-21.00' stderr
|
||||||
|
|
||||||
|
ltldo '{name} foo/bar/owl-21.00 non-existant' -f GFa 2>stderr && exit 1
|
||||||
|
grep % stderr
|
||||||
|
|
||||||
test 2 = `genltl --and-gf=1..4 | ltldo ltl2tgba -n2 | autfilt -c`
|
test 2 = `genltl --and-gf=1..4 | ltldo ltl2tgba -n2 | autfilt -c`
|
||||||
test 3 = `genltl --and-gf=1..2 | ltldo ltl2tgba 'ltl2tgba -s' -n3 | autfilt -c`
|
test 3 = `genltl --and-gf=1..2 | ltldo ltl2tgba 'ltl2tgba -s' -n3 | autfilt -c`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue