trunk preprocessor: fixed a memory management bug related to the filename being parsed

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2412 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
sebastien 2009-02-12 13:38:01 +00:00
parent 2de828a643
commit ce1b012278
4 changed files with 7 additions and 11 deletions

View File

@ -55,8 +55,8 @@ class ParsingDriver;
%locations
%initial-action
{
// Initialize the location filenames to NULL
@$.begin.filename = @$.end.filename = NULL;
// Initialize the locations' filenames to the filename maintained by the lexer
@$.begin.filename = @$.end.filename = &(driver.lexer->filename);
}
%debug

View File

@ -73,9 +73,7 @@ int sigma_e = 0;
/* Rules for matching $line directives */
<*>^@#line\ \" { line_caller = YYSTATE; BEGIN(LINE1); }
<LINE1>[^\"]* {
if (yylloc->begin.filename)
delete yylloc->begin.filename;
yylloc->begin.filename = yylloc->end.filename = new string(yytext);
filename = string(yytext);
BEGIN(LINE2);
}
<LINE2>\" BEGIN(LINE3);

View File

@ -72,12 +72,6 @@ ParsingDriver::parse(istream &in, bool debug)
delete lexer;
/* Deleting filename in DynareFlex::yyterminate() is prematurate,
because if there is an unexpected end of file, the call to
ParsingDriver::error() needs filename */
/*if (location.begin.filename)
delete location.begin.filename;*/
return mod_file;
}

View File

@ -60,6 +60,10 @@ public:
Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval,
Dynare::parser::location_type *yylloc,
ParsingDriver &driver);
//! The filename being parsed
/*! The bison parser locations (begin and end) contain a pointer to that string */
string filename;
};
//! Drives the scanning and parsing of the .mod file, and constructs its abstract representation