Diagnose reversed ranges like [=2..1], [->..0] or [*8..4].
* src/ltlparse/ltlparse.yy: Diagnose them. * src/ltltest/parseerr.test: Add tests.
This commit is contained in:
parent
ec9a3f96cb
commit
2f9f274a5f
2 changed files with 36 additions and 5 deletions
|
|
@ -376,12 +376,31 @@ rationalexp: booleanatom
|
||||||
| rationalexp OP_FUSION error
|
| rationalexp OP_FUSION error
|
||||||
{ missing_right_binop($$, $1, @2, "fusion operator"); }
|
{ missing_right_binop($$, $1, @2, "fusion operator"); }
|
||||||
| rationalexp starargs
|
| rationalexp starargs
|
||||||
{ $$ = bunop::instance(bunop::Star, $1, $2.min, $2.max); }
|
{
|
||||||
|
if ($2.max < $2.min)
|
||||||
|
{
|
||||||
|
error_list.push_back(parse_error(@2, "reversed range"));
|
||||||
|
std::swap($2.max, $2.min);
|
||||||
|
}
|
||||||
|
$$ = bunop::instance(bunop::Star, $1, $2.min, $2.max);
|
||||||
|
}
|
||||||
| starargs
|
| starargs
|
||||||
{ $$ = bunop::instance(bunop::Star, constant::true_instance(),
|
{
|
||||||
$1.min, $1.max); }
|
if ($1.max < $1.min)
|
||||||
|
{
|
||||||
|
error_list.push_back(parse_error(@1, "reversed range"));
|
||||||
|
std::swap($1.max, $1.min);
|
||||||
|
}
|
||||||
|
$$ = bunop::instance(bunop::Star, constant::true_instance(),
|
||||||
|
$1.min, $1.max);
|
||||||
|
}
|
||||||
| rationalexp equalargs
|
| rationalexp equalargs
|
||||||
{
|
{
|
||||||
|
if ($2.max < $2.min)
|
||||||
|
{
|
||||||
|
error_list.push_back(parse_error(@2, "reversed range"));
|
||||||
|
std::swap($2.max, $2.min);
|
||||||
|
}
|
||||||
if ($1->is_boolean())
|
if ($1->is_boolean())
|
||||||
{
|
{
|
||||||
$$ = bunop::instance(bunop::Equal, $1, $2.min, $2.max);
|
$$ = bunop::instance(bunop::Equal, $1, $2.min, $2.max);
|
||||||
|
|
@ -399,6 +418,11 @@ rationalexp: booleanatom
|
||||||
}
|
}
|
||||||
| rationalexp gotoargs
|
| rationalexp gotoargs
|
||||||
{
|
{
|
||||||
|
if ($2.max < $2.min)
|
||||||
|
{
|
||||||
|
error_list.push_back(parse_error(@2, "reversed range"));
|
||||||
|
std::swap($2.max, $2.min);
|
||||||
|
}
|
||||||
if ($1->is_boolean())
|
if ($1->is_boolean())
|
||||||
{
|
{
|
||||||
$$ = bunop::instance(bunop::Goto, $1, $2.min, $2.max);
|
$$ = bunop::instance(bunop::Goto, $1, $2.min, $2.max);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Copyright (C) 2009, 2010 Laboratoire de Recherche et Développement
|
# Copyright (C) 2009, 2010, 2011 Laboratoire de Recherche et
|
||||||
# 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
|
||||||
# et Marie Curie.
|
# et Marie Curie.
|
||||||
|
|
@ -85,6 +85,13 @@ run 0 ../equals -E 'a & (a + b c' 'a & (0)'
|
||||||
run 0 ../equals -E 'a & (+' 'a & (0)'
|
run 0 ../equals -E 'a & (+' 'a & (0)'
|
||||||
run 0 ../equals -E 'a & (' 'a & (0)'
|
run 0 ../equals -E 'a & (' 'a & (0)'
|
||||||
|
|
||||||
|
# Invalid ranges
|
||||||
|
run 0 ../equals -E '{a[*8..1];b}' '{a[*1..8];b}'
|
||||||
|
run 0 ../equals -E '{a[=8..1];b}' '{a[=1..8];b}'
|
||||||
|
run 0 ../equals -E '{a[->8..1];b}' '{a[->1..8];b}'
|
||||||
|
run 0 ../equals -E '{a[->..0];b}' '{a[->0..1];b}'
|
||||||
|
|
||||||
|
|
||||||
check 'a - b' 'AP(a)' '>>> a - b
|
check 'a - b' 'AP(a)' '>>> a - b
|
||||||
^
|
^
|
||||||
syntax error, unexpected $undefined
|
syntax error, unexpected $undefined
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue