hoa: preliminary implementation of a parser

* src/hoaparse/Makefile.am, src/hoaparse/fmterror.cc,
src/hoaparse/hoaparse.yy, src/hoaparse/hoascan.ll,
src/hoaparse/parsedecl.hh, src/hoaparse/public.hh: New files.
* src/Makefile.am, configure.ac, README: Adjust.
* src/tgbatest/ltl2tgba.cc: Add a -XH option.
* src/tgbatest/hoaparse.test: New file.
* src/tgbatest/Makefile.am: Adjust.
* buddy/src/bddx.h: Add a bdd_from_int() function.
This commit is contained in:
Alexandre Duret-Lutz 2014-11-18 18:48:36 +01:00
parent e1d4522ca9
commit e55bcd95aa
14 changed files with 1138 additions and 3 deletions

View file

@ -84,6 +84,7 @@ TESTS = \
nondet.test \
det.test \
neverclaimread.test \
hoaparse.test \
dstar.test \
readsave.test \
maskacc.test \

198
src/tgbatest/hoaparse.test Executable file
View file

@ -0,0 +1,198 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Laboratoire de Recherche et Développement de
# l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
#
# Spot is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Spot is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
# License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
. ./defs
set -e
expecterr()
{
cat >$1.exp
../ltl2tgba -XH $1 2>$1.err && exit 1
test $? = 2
cat $1.err
diff $1.err $1.exp
}
cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF
expecterr input <<EOF
input:5.1-9: redefinition of the number of states...
input:2.1-9: ... previously defined here.
EOF
cat >input <<EOF
HOA: v1
States: 1
Start: 0
AP: 1 "a"
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF
expecterr input <<EOF
input:8.5: state number is larger than state count...
input:2.1-9: ... declared here.
input:9.8: state number is larger than state count...
input:2.1-9: ... declared here.
input:10.5: state number is larger than state count...
input:2.1-9: ... declared here.
EOF
cat >input <<EOF
HOA: v1
States: 0
AP: 1 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF
expecterr input <<EOF
input:3.1-13: found 2 atomic propositions instead of the 1 announced
EOF
cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
AP: 2 "a" "b"
Acceptance: 0 t
--BODY--
--END--
EOF
expecterr input <<EOF
input:4.1-3: redeclaration of APs...
input:2.1-5: ... previously defined here.
EOF
cat >input <<EOF
HOA: v1
AP: 1 "a"
States: 0
Start: 1
--BODY--
--END--
EOF
expecterr input <<EOF
input:4.8: state number is larger than state count...
input:3.1-9: ... declared here.
input:1.1-4.8: missing 'Acceptance:' header
EOF
cat >input <<EOF
HOA: v1
AP: 1 "a"
Start: 0
States: 0
--BODY--
--END--
EOF
expecterr input <<EOF
input:3.1-8: initial state number is larger than state count...
input:4.1-9: ... declared here.
EOF
cat >input <<EOF
HOA: v1
Acceptance: 1 Inf(0)
Start: 0
States: 1
Acceptance: 1 Inf(0)
--BODY--
--END--
EOF
expecterr input <<EOF
input:5.1-13: redefinition of the acceptance condition...
input:2.1-13: ... previously defined here.
EOF
cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(0)
--BODY--
State: 0 {0}
[0] 1
State: 1 {1}
[t] 1
--END--
EOF
expecterr input <<EOF
input:9.11: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
EOF
cat >input <<EOF
HOA: v1
Start: 0
AP: 1 "a"
States: 2
Acceptance: 1 Inf(2)
--BODY--
State: 0 {0}
[0] 1
State: 1 {0}
[t] 1
--END--
EOF
expecterr input <<EOF
input:5.19: number is larger than the count of acceptance sets...
input:5.1-13: ... declared here.
EOF
cat >input <<EOF
HOA: v2
--BODY--
--END--
EOF
expecterr input <<EOF
input:1.1-7: unsupported version of the HOA format
input:1.1-7: missing 'Acceptance:' header
EOF

View file

@ -43,6 +43,7 @@
#include "tgbaparse/public.hh"
#include "neverparse/public.hh"
#include "dstarparse/public.hh"
#include "hoaparse/public.hh"
#include "tgbaalgos/dupexp.hh"
#include "tgbaalgos/minimize.hh"
#include "taalgos/minimize.hh"
@ -128,6 +129,8 @@ syntax(char* prog)
<< "TGBA" << std::endl
<< " -XDD read the from an ltl2dstar file and convert it to "
<< "TGBA,\n keeping it deterministic when possible\n"
<< " -XH do not compute an automaton, read it from a"
<< " HOA file\n"
<< " -XL do not compute an automaton, read it from an"
<< " LBTT file" << std::endl
<< " -XN do not compute an automaton, read it from a"
@ -355,7 +358,8 @@ checked_main(int argc, char** argv)
bool accepting_run = false;
bool accepting_run_replay = false;
bool from_file = false;
enum { ReadSpot, ReadLbtt, ReadNeverclaim, ReadDstar } readformat = ReadSpot;
enum { ReadSpot, ReadLbtt, ReadNeverclaim, ReadDstar, ReadHoa } readformat
= ReadSpot;
bool nra2nba = false;
bool dra2dba = false;
bool scc_filter = false;
@ -923,6 +927,11 @@ checked_main(int argc, char** argv)
nra2nba = true;
dra2dba = true;
}
else if (!strcmp(argv[formula_index], "-XH"))
{
from_file = true;
readformat = ReadHoa;
}
else if (!strcmp(argv[formula_index], "-XL"))
{
from_file = true;
@ -1097,6 +1106,18 @@ checked_main(int argc, char** argv)
tm.stop("dstar2tgba");
}
break;
case ReadHoa:
{
spot::dstar_parse_error_list pel;
tm.start("parsing hoa");
auto daut = spot::hoa_parse(input, pel, dict, env, debug_opt);
tm.stop("parsing hoa");
if (spot::format_hoa_parse_errors(std::cerr, input, pel))
return 2;
a = daut->aut;
assume_sba = false;
}
break;
}
}
else