ltlscan: get rid of boost::lexical_cast

This is one less useless dependency on Boost.

* src/ltlparse/ltlscan.ll: Replace lexical_cast<unsigned>() by
strtoul().
* src/ltltest/parseerr.test: Add a test case.
This commit is contained in:
Alexandre Duret-Lutz 2013-03-27 19:12:45 +01:00
parent 990ba837d3
commit 9145515bb8
2 changed files with 27 additions and 18 deletions

View file

@ -26,8 +26,9 @@
%option stack
%{
#include <cstdlib>
#include <string>
#include <boost/lexical_cast.hpp>
#include "ltlparse/parsedecl.hh"
#include "misc/escape.hh"
@ -197,20 +198,21 @@ BOXDARROW {BOX}{DARROWL}|"|"{DARROWL}|"⤇"
"["{ARROWL} BEGIN(sqbracket); return token::OP_GOTO_OPEN;
<sqbracket>"]" BEGIN(0); return token::OP_SQBKT_CLOSE;
<sqbracket>[0-9]+ {
unsigned num = 0;
try {
num = boost::lexical_cast<unsigned>(yytext);
yylval->num = num;
return token::OP_SQBKT_NUM;
}
catch (boost::bad_lexical_cast &)
{
error_list.push_back(
spot::ltl::parse_error(*yylloc,
"value too large ignored"));
// Skip this number and read next token
yylloc->step();
}
errno = 0;
unsigned long n = strtoul(yytext, 0, 10);
yylval->num = n;
if (errno || yylval->num != n)
{
error_list.push_back(
spot::ltl::parse_error(*yylloc,
"value too large ignored"));
// Skip this number and read next token
yylloc->step();
}
else
{
return token::OP_SQBKT_NUM;
}
}
/* .. is from PSL and EDL
: is from Verilog and PSL