Commit 8256ae9b authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

Accept "P_0 == CS" as synonym for "P_0.CS" in the dve2 interface.

Suggested by Yann Thierry-Mieg.

* iface/dve2/dve2.cc (convert_aps): Allow string on the right
of operators, and look them up.
* iface/dve2/dve2check.test: Test this syntax.
parent 5318c1f9
2011-03-07 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Accept "P_0 == CS" as synonym for "P_0.CS" in the dve2 interface.
Suggested by Yann Thierry-Mieg.
* iface/dve2/dve2.cc (convert_aps): Allow string on the right
of operators, and look them up.
* iface/dve2/dve2check.test: Test this syntax.
2011-03-07 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Add some tests for the DVE2 interface.
......
......@@ -355,7 +355,6 @@ namespace spot
free(name);
continue;
}
free(name);
int var_num = ni->second.num;
......@@ -364,6 +363,7 @@ namespace spot
int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, OP_NE, 0, v };
out.push_back(p);
free(name);
continue;
}
......@@ -413,33 +413,73 @@ namespace spot
<< "' while parsing atomic proposition `" << str
<< "'." << std::endl;
++errors;
free(name);
continue;
}
while (*s && (*s == ' ' || *s == '\t'))
++s;
char* s_end;
int val = strtol(s, &s_end, 10);
if (s == s_end)
int val;
int type_num = ni->second.type;
if (type_num == 0 || (*s >= '0' && *s <= '9') || *s == '-')
{
std::cerr << "Failed to parse `" << s
<< "' as an integer." << std::endl;
++errors;
continue;
char* s_end;
val = strtol(s, &s_end, 10);
if (s == s_end)
{
std::cerr << "Failed to parse `" << s
<< "' as an integer." << std::endl;
++errors;
free(name);
continue;
}
s = s_end;
}
s = s_end;
else
{
// We are in a case such as P_0 == S, trying to convert
// the string S into an integer.
const char* end = s;
while (*end && *end != ' ' && *end != '\t')
++end;
std::string st(s, end);
// Lookup the string.
enum_map_t::const_iterator ei = enum_map[type_num].find(st);
if (ei == enum_map[type_num].end())
{
std::cerr << "No state `" << st
<< "' known for variable `"
<< name << "'." << std::endl;
std::cerr << "Possible states are:";
for (ei = enum_map[type_num].begin();
ei != enum_map[type_num].end(); ++ei)
std::cerr << " " << ei->first;
std::cerr << std::endl;
free(name);
++errors;
continue;
}
s = end;
val = ei->second;
}
free(name);
while (*s && (*s == ' ' || *s == '\t'))
++s;
if (*s)
{
std::cerr << "Unexpected character `" << s
std::cerr << "Unexpected `" << s
<< "' while parsing atomic proposition `" << str
<< "'." << std::endl;
++errors;
continue;
++errors;
continue;
}
int v = dict->register_proposition(*ap, d);
one_prop p = { var_num, op, val, v };
out.push_back(p);
......
......@@ -38,7 +38,12 @@ set -e
# time with valgrind.).
../dve2check -e $srcdir/beem-peterson.4.dve '!GF(P_0.CS|P_1.CS|P_2.CS|P_3.CS)'
run 0 ../dve2check -E $srcdir/beem-peterson.4.dve '!G(P_0.wait -> F P_0.CS)'
run 0 ../dve2check -E $srcdir/beem-peterson.4.dve \
'!G(P_0.wait -> F P_0.CS)' > stdout1
# same formula, different syntax.
run 0 ../dve2check -E $srcdir/beem-peterson.4.dve \
'!G("P_0 == wait" -> F "P_0 == CS")' > stdout2
cmp stdout1 stdout2
run 0 ../dve2check -E $srcdir/beem-peterson.4.dve '!G("pos[1] < 3")'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment