tostring: quote U, W, M, R when used as atomic propositions

* src/ltltest/tostring.test, src/ltltest/parse.test: More tests.
* src/ltlvisit/tostring.cc (is_bare_word): Quote U, W, M, R.
* NEWS: Mention it.
This commit is contained in:
Alexandre Duret-Lutz 2013-01-19 14:15:17 +01:00
parent 5086e24165
commit bf3c3aecde
4 changed files with 29 additions and 10 deletions

4
NEWS
View file

@ -9,6 +9,10 @@ New in spot 1.0a (not released):
- "P0.init" is parsed as an atomic even without the double quotes, - "P0.init" is parsed as an atomic even without the double quotes,
but it was always output with double quotes. This version will but it was always output with double quotes. This version will
not quote this atomic proposition anymore. not quote this atomic proposition anymore.
- "U", "W", "M", "R" were correctly parsed as atomic propositions
(instead of binary operators) when placed in double quotes, but
on output they were output without quotes, making the result
unparsable.
- tgba_product::transition_annotation() would segfault when - tgba_product::transition_annotation() would segfault when
called in a product against a Kripke structure. called in a product against a Kripke structure.
* Minor improvements: * Minor improvements:

View file

@ -1,6 +1,7 @@
#! /bin/sh #! /bin/sh
# Copyright (C) 2009, 2010, 2011, 2012 Laboratoire de Recherche et Developpement # -*- coding: utf-8 -*-
# de l'Epita (LRDE). # Copyright (C) 2009, 2010, 2011, 2012, 2013 Laboratoire de Recherche
# et Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre # département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie. # et Marie Curie.
@ -61,6 +62,13 @@ for f in \
'<>b' \ '<>b' \
'X b' \ 'X b' \
'()b' \ '()b' \
'X"X"' \
'X"F"' \
'X"G"' \
'X"U"' \
'X"W"' \
'X"R"' \
'X"M"' \
'long_atomic_proposition_1 U long_atomic_proposition_2' \ 'long_atomic_proposition_1 U long_atomic_proposition_2' \
' ab & ac | ad ^ af' \ ' ab & ac | ad ^ af' \
'((b & a) + a) & d' \ '((b & a) + a) & d' \
@ -81,7 +89,7 @@ do
if ../ltl2text "$f"; then if ../ltl2text "$f"; then
: :
else else
echo "ltl2dot failed to parse '$f'" echo "ltl2text failed to parse '$f'"
exit 1 exit 1
fi fi

View file

@ -1,8 +1,9 @@
#! /bin/sh #! /bin/sh
# Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et Développement # -*- coding: utf-8 -*-
# de l'Epita (LRDE). # Copyright (C) 2009, 2010, 2011, 2013 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
# Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), # Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
# département Systèmes Répartis Coopératifs (SRC), Université Pierre # département Systèmes Répartis Coopératifs (SRC), Université Pierre
# et Marie Curie. # et Marie Curie.
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
@ -54,6 +55,10 @@ run 0 ../tostring 'p=0UFXp=1'
run 0 ../tostring 'GF"\GF"' run 0 ../tostring 'GF"\GF"'
run 0 ../tostring 'GF"foo bar"' run 0 ../tostring 'GF"foo bar"'
run 0 ../tostring 'FFG__GFF' run 0 ../tostring 'FFG__GFF'
run 0 ../tostring 'X"U"'
run 0 ../tostring 'X"W"'
run 0 ../tostring 'X"M"'
run 0 ../tostring 'X"R"'
run 0 ../tostring '{a;b;{c && d*};**}|=>G{a*:b*}' run 0 ../tostring '{a;b;{c && d*};**}|=>G{a*:b*}'
run 0 ../tostring 'GF!{{a || c} && b}' run 0 ../tostring 'GF!{{a || c} && b}'

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2008, 2010, 2012 Laboratoire de Recherche et // Copyright (C) 2008, 2010, 2012, 2013 Laboratoire de Recherche et
// Développement de l'Epita (LRDE) // Développement de l'Epita (LRDE)
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6), // Copyright (C) 2003, 2004 Laboratoire d'Informatique de Paris 6 (LIP6),
// département Systèmes Répartis Coopératifs (SRC), Université Pierre // département Systèmes Répartis Coopératifs (SRC), Université Pierre
@ -191,14 +191,16 @@ namespace spot
static bool static bool
is_bare_word(const char* str) is_bare_word(const char* str)
{ {
// Bare words cannot be empty, start with the letter of a unary // Bare words cannot be empty, start with the letter of a
// operator, or be the name of an existing constant. Also they // unary operator, or be the name of an existing constant or
// should start with an letter. // operator. Also they should start with an letter.
if (!*str if (!*str
|| *str == 'F' || *str == 'F'
|| *str == 'G' || *str == 'G'
|| *str == 'X' || *str == 'X'
|| !(isalpha(*str) || *str == '_' || *str == '.') || !(isalpha(*str) || *str == '_' || *str == '.')
|| ((*str == 'U' || *str == 'W' || *str == 'M' || *str == 'R')
&& str[1] == 0)
|| !strcasecmp(str, "true") || !strcasecmp(str, "true")
|| !strcasecmp(str, "false")) || !strcasecmp(str, "false"))
return false; return false;