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-bf33cf982152time-shift
parent
fe418672cd
commit
596d2a801d
|
@ -55,8 +55,8 @@ class ParsingDriver;
|
||||||
%locations
|
%locations
|
||||||
%initial-action
|
%initial-action
|
||||||
{
|
{
|
||||||
// Initialize the location filenames to NULL
|
// Initialize the locations' filenames to the filename maintained by the lexer
|
||||||
@$.begin.filename = @$.end.filename = NULL;
|
@$.begin.filename = @$.end.filename = &(driver.lexer->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
%debug
|
%debug
|
||||||
|
|
|
@ -73,9 +73,7 @@ int sigma_e = 0;
|
||||||
/* Rules for matching $line directives */
|
/* Rules for matching $line directives */
|
||||||
<*>^@#line\ \" { line_caller = YYSTATE; BEGIN(LINE1); }
|
<*>^@#line\ \" { line_caller = YYSTATE; BEGIN(LINE1); }
|
||||||
<LINE1>[^\"]* {
|
<LINE1>[^\"]* {
|
||||||
if (yylloc->begin.filename)
|
filename = string(yytext);
|
||||||
delete yylloc->begin.filename;
|
|
||||||
yylloc->begin.filename = yylloc->end.filename = new string(yytext);
|
|
||||||
BEGIN(LINE2);
|
BEGIN(LINE2);
|
||||||
}
|
}
|
||||||
<LINE2>\" BEGIN(LINE3);
|
<LINE2>\" BEGIN(LINE3);
|
||||||
|
|
|
@ -72,12 +72,6 @@ ParsingDriver::parse(istream &in, bool debug)
|
||||||
|
|
||||||
delete lexer;
|
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;
|
return mod_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ public:
|
||||||
Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval,
|
Dynare::parser::token_type lex(Dynare::parser::semantic_type *yylval,
|
||||||
Dynare::parser::location_type *yylloc,
|
Dynare::parser::location_type *yylloc,
|
||||||
ParsingDriver &driver);
|
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
|
//! Drives the scanning and parsing of the .mod file, and constructs its abstract representation
|
||||||
|
|
Loading…
Reference in New Issue