Fix error reporting in utf8-encoded LTL formulae.

* src/ltlparse/public.hh (fix_utf8_locations): New function.
* src/ltlparse/fmterror.cc (fix_utf8_locations): Implement it.
(format_parse_errors): Rename as ...
(format_parse_errors_aux): ... this.
(format_parse_errors): New implementation that call fix_utf8_locations()
before format_parse_errors_aux() on valid utf8 strings.
* src/ltlparse/Makefile.am: Include $(top_srcdir).
* src/ltltest/utf8.test: New file.
* src/ltltest/Makefile.am: Add it.
* src/ltltest/parse.test: Fix header.
This commit is contained in:
Alexandre Duret-Lutz 2012-03-29 14:14:56 +02:00
parent 403170f5c8
commit 7e4787da22
6 changed files with 192 additions and 27 deletions

View file

@ -83,6 +83,7 @@ EXTRA_DIST = $(TESTS)
TESTS = \
parse.test \
parseerr.test \
utf8.test \
length.test \
equals.test \
tostring.test \

View file

@ -2,7 +2,7 @@
# Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Developpement
# de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# d<EFBFBD>partement Syst<73>mes R<>partis Coop<6F>ratifs (SRC), Universit<69> Pierre
# département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie.
#
# This file is part of Spot, a model checking library.

72
src/ltltest/utf8.test Executable file
View file

@ -0,0 +1,72 @@
#! /bin/sh
# Copyright (C) 2012 Laboratoire de Recherche et Developpement
# 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 2 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 Spot; see the file COPYING. If not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Make sure
. ./defs || exit 1
# ----
run 0 ../ltl2text '□◯a' >out
echo 'unop(G, unop(X, AP(a)))' > exp
cmp out exp
# ----
run 0 ../ltl2text '□◯"αβγ"' >out
echo 'unop(G, unop(X, AP(αβγ)))' > exp
cmp out exp
# ----
set +x
run 1 ../ltl2text '□)◯a' 2>err
set -x
cat >exp <<EOF
>>> □)◯a
^
syntax error, unexpected closing parenthesis
>>> □)◯a
^
missing right operand for "always operator"
>>> □)◯a
^^^
ignoring trailing garbage
EOF
cmp exp err
# ----
set +x
run 1 ../ltl2text '"αβγ"X' 2>err
set -x
cat >exp <<EOF
>>> "αβγ"X
^
syntax error, unexpected next operator
>>> "αβγ"X
^
ignoring trailing garbage
EOF
cmp exp err