* HACKING, Makefile.am, configure.ac, m4/gccwarn.m4,

src/Makefile.am, src/ltlast/Makefile.am, src/ltlast/allnodes.hh,
src/ltlast/atomic_prop.cc, src/ltlast/atomic_prop.hh,
src/ltlast/binop.cc, src/ltlast/binop.hh, src/ltlast/constant.cc,
src/ltlast/constant.hh, src/ltlast/formulae.hh,
src/ltlast/multop.cc, src/ltlast/multop.hh, src/ltlast/predecl.hh,
src/ltlast/unop.cc, src/ltlast/unop.hh, src/ltlast/visitor.hh,
src/ltlparse/Makefile.am, src/ltlparse/ltlparse.yy,
src/ltlparse/ltlscan.ll, src/ltlparse/parsedecl.hh,
src/ltlparse/public.hh, src/ltlvisit/Makefile.am,
src/ltlvisit/dotty.cc, src/ltlvisit/dotty.hh,
src/ltlvisit/dump.cc, src/ltlvisit/dump.hh,
src/ltlvisit/rewrite.cc, src/ltlvisit/rewrite.hh,
src/ltltest/Makefile.am, src/ltltest/defs.in, src/ltltest/readltl.cc,
src/ltltest/parse.test, src/ltltest/parseerr.test,
src/misc/Makefile.am, src/misc/const_sel.hh: New files.
This commit is contained in:
Alexandre Duret-Lutz 2003-04-15 10:55:16 +00:00
parent ababb9ff93
commit f0a8d0aeb3
46 changed files with 1818 additions and 0 deletions

9
src/ltltest/.cvsignore Normal file
View file

@ -0,0 +1,9 @@
Makefile
Makefile.in
.deps
ltl2dot
ltl2text
stdout
parser.dot
expect
defs

15
src/ltltest/Makefile.am Normal file
View file

@ -0,0 +1,15 @@
AM_CPPFLAGS = -I$(srcdir)/..
LDADD = ../ltlparse/libltlparse.a \
../ltlvisit/libltlvisit.a \
../ltlast/libltlast.a
check_SCRIPTS = defs
check_PROGRAMS = ltl2dot ltl2text
ltl2dot_SOURCES = readltl.cc
ltl2dot_CPPFLAGS = $(AM_CPPFLAGS) -DDOTTY
ltl2text_SOURCES = readltl.cc
EXTRA_DIST = $(TESTS)
TESTS = parse.test parseerr.test
CLEANFILES = stdout expect parse.dot

35
src/ltltest/defs.in Normal file
View file

@ -0,0 +1,35 @@
# -*- shell-script -*-
# Ensure we are running from the right directory.
test -f ./defs || {
echo "defs: not found in current directory" 1>&2
exit 1
}
# If srcdir is not set, then we are not running from `make check', be verbose.
if test -z "$srcdir"; then
test -z "$VERBOSE" && VERBOSE=x
# compute $srcdir.
srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
test $srcdir = $0 && srcdir=.
fi
# Ensure $srcdir is set correctly.
test -f $srcdir/defs.in || {
echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
exit 1
}
# User can set VERBOSE to see all output.
test -z "$VERBOSE" && exec >/dev/null 2>&1
echo "== Running test $0"
DOT='@DOT@'
# Turn on shell traces when VERBOSE=x.
if test "x$VERBOSE" = xx; then
set -x
else
:
fi

64
src/ltltest/parse.test Executable file
View file

@ -0,0 +1,64 @@
#! /bin/sh
# Check that spot::ltl::parse succeed on valid input, and that
# dump and dotty will work with the resulting trees. Note that
# this doesn't check that the tree is correct w.r.t. the formula.
. ./defs || exit 1
for f in \
'0' \
'1' \
'true' \
'false' \
'a' \
'p11011' \
'(p11011)' \
'a & b' \
'a * _b12' \
'a . b' \
'a + b' \
'a3214 | b' \
'a & b' \
'_a_ U b' \
'a R b' \
'a <=> b' \
'a <-> b' \
'a ^ b' \
'a => b' \
'a -> b' \
'F b' \
'Gb' \
'G(b)' \
'!G(!b)' \
'!b' \
'[]b' \
'<>b' \
'X b' \
'()b' \
'long_atomic_proposition_1 U long_atomic_proposition_2' \
' ab & ac | ad ^ af' \
'(ab & ac | ad ) <=> af ' \
'a U b U c U d U e U f U g U h U i U j U k U l U m' \
'(ab * !Xad + ad U ab) & FG p12 & GF p13' \
'((([]<>()p12)) )' \
'a R ome V anille'
do
if ./ltl2text "$f"; then
:
else
echo "ltl2dot failed to parse '$f'"
exit 1
fi
if test -n "$DOT"; then
./ltl2dot "$f" > parse.dot
if $DOT -o /dev/null parse.dot; then
rm -f parse.dot
else
rm -f parse.dot
echo "dot failed to parse ltl2dot output for '$f'"
exit 1
fi
fi
done

47
src/ltltest/parseerr.test Executable file
View file

@ -0,0 +1,47 @@
#! /bin/sh
# Check error recovery in parsing. This also check how the
# resulting tree looks like.
. ./defs || exit 1
check()
{
if ./ltl2text "$1" >stdout; then
echo "ltl2text unexpectedly parsed '$1' successfully"
rm -f stdout
exit 1
else
if test -n "$2"; then
echo "$2" >expect
else
: >expect
fi
if cmp stdout expect; then
:
else
echo "'$1' parsed as"
cat stdout
echo "instead of"
cat expect
rm -f stdout expect
exit 1
fi
fi
}
# Empty or unparsable strings
check '' ''
check '+' ''
check 'a U' ''
check 'a U b V c R' ''
# leading and trailing garbage are skipped
check '/2/3/4/5 a + b /6/7/8/' 'multop(Or, AP(a), AP(b))'
check 'a U b c' 'binop(U, AP(a), AP(b))'
# Recovery inside parentheses
check 'a U (b c) U e R (f g <=> h)' \
'binop(R, binop(U, binop(U, AP(a), AP(b)), AP(e)), AP(f))'
check 'a U ((c) U e) R (<=> f g)' \
'binop(R, binop(U, AP(a), binop(U, AP(c), AP(e))), constant(0))'

69
src/ltltest/readltl.cc Normal file
View file

@ -0,0 +1,69 @@
#include <iostream>
#include "ltlparse/public.hh"
#include "ltlvisit/dump.hh"
#include "ltlvisit/dotty.hh"
void
syntax(char *prog)
{
std::cerr << prog << " [-d] formulae" << std::endl;
exit(2);
}
int
main(int argc, char **argv)
{
int exit_code = 0;
if (argc < 2)
syntax(argv[0]);
bool debug = false;
int formulae_index = 1;
if (!strcmp(argv[1], "-d"))
{
debug = true;
if (argc < 3)
syntax(argv[0]);
formulae_index = 2;
}
spot::ltl::parse_error_list pel;
spot::ltl::formulae *f = spot::ltl::parse(argv[formulae_index],
pel, debug);
spot::ltl::parse_error_list::iterator it;
for (it = pel.begin(); it != pel.end(); ++it)
{
std::cerr << ">>> " << argv[formulae_index] << std::endl;
unsigned n = 0;
yy::Location& l = it->first;
for (; n < 4 + l.begin.column; ++n)
std::cerr << ' ';
// Write at least one '^', even if begin==end.
std::cerr << '^';
++n;
for (; n < 4 + l.end.column; ++n)
std::cerr << '^';
std::cerr << std::endl << it->second << std::endl << std::endl;
exit_code = 1;
}
if (f)
{
#ifdef DOTTY
spot::ltl::dotty(*f, std::cout);
#else
spot::ltl::dump(*f, std::cout);
std::cout << std::endl;
#endif
delete f;
}
else
{
exit_code = 1;
}
return exit_code;
}