* src/ltlparse/ltlscan.ll: Pass yyleng to the std::string constructor,

so it doesn't have to compute it.
* src/tgbaparse/tgbascan.ll: Likewise.
(YY_USER_INIT, current_file): Remove, it is too costly to use
yy::Location::filename in the current implementation
of yy::Location (this attribute is duplicated for each token).
Leaving it empty divides the parsing time by 3.
* src/tgbaparse/fmterror.cc, src/tgbaparse/public.hh
(format_tgba_parse_errors): Take the filename as argument.
* src/tgbatest/explprod.cc, src/tgbatest/ltl2tgba.cc,
src/tgbatest/mixprod.cc, src/tgbatest/powerset.cc,
src/tgbatest/readsave.cc, src/tgbatest/reductgba.cc,
src/tgbatest/tgbaread.cc, src/tgbatest/tripprod.cc,
iface/gspn/dottyssp.cc, iface/gspn/ltlgspn.cc: Adjust calls
to format_tgba_parse_errors.
This commit is contained in:
Alexandre Duret-Lutz 2004-12-16 12:33:37 +00:00
parent 704f237a22
commit 0efca0f644
15 changed files with 44 additions and 31 deletions

View file

@ -26,14 +26,16 @@ namespace spot
{
bool
format_tgba_parse_errors(std::ostream& os,
const std::string& filename,
tgba_parse_error_list& error_list)
{
bool printed = false;
spot::tgba_parse_error_list::iterator it;
for (it = error_list.begin(); it != error_list.end(); ++it)
{
if (it->first.begin.filename != "")
os << it->first << ": ";
if (filename != "-")
os << filename << ":";
os << it->first << ": ";
os << it->second << std::endl;
printed = true;
}

View file

@ -69,6 +69,7 @@ namespace spot
/// parsing \a ltl_string.
/// \return \c true iff any diagnostic was output.
bool format_tgba_parse_errors(std::ostream& os,
const std::string& filename,
tgba_parse_error_list& error_list);
/// @}

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2003 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
** et Marie Curie.
**
@ -31,16 +31,8 @@
#define YY_USER_ACTION \
yylloc->columns(yyleng);
#define YY_USER_INIT \
do { \
yylloc->begin.filename = current_file; \
yylloc->end.filename = current_file; \
} while (0)
#define YY_NEVER_INTERACTIVE 1
static std::string current_file;
%}
eol \n|\r|\n\r|\r\n
@ -54,7 +46,7 @@ eol \n|\r|\n\r|\r\n
acc[ \t]*= return ACC_DEF;
[a-zA-Z][a-zA-Z0-9_]* {
yylval->str = new std::string(yytext);
yylval->str = new std::string(yytext, yyleng);
return IDENT;
}
@ -76,7 +68,7 @@ acc[ \t]*= return ACC_DEF;
return STRING;
}
\\["\\] yylval->str->append(1, yytext[1]);
[^"\\]+ yylval->str->append (yytext, yyleng);
[^"\\]+ yylval->str->append(yytext, yyleng);
<<EOF>> {
BEGIN(INITIAL);
return UNTERMINATED_STRING;
@ -98,12 +90,10 @@ namespace spot
if (name == "-")
{
yyin = stdin;
current_file = "standard input";
}
else
{
yyin = fopen (name.c_str (), "r");
current_file = name;
yyin = fopen(name.c_str(), "r");
if (!yyin)
return 1;
}