diff --git a/preprocessor/DynareFlex.ll b/preprocessor/DynareFlex.ll index 5a31230f4..7bf9202d5 100644 --- a/preprocessor/DynareFlex.ll +++ b/preprocessor/DynareFlex.ll @@ -72,7 +72,7 @@ int sigma_e = 0; /* Rules for matching @line directives */ <*>^@line\ \" { line_caller = YYSTATE; BEGIN(LINE1); } -[^\"\n]* { +[^\"]* { if (yylloc->begin.filename) delete yylloc->begin.filename; yylloc->begin.filename = yylloc->end.filename = new string(yytext); diff --git a/preprocessor/macro/MacroFlex.ll b/preprocessor/macro/MacroFlex.ll index f51bdb235..0ef1f967f 100644 --- a/preprocessor/macro/MacroFlex.ll +++ b/preprocessor/macro/MacroFlex.ll @@ -62,11 +62,11 @@ typedef Macro::parser::token token; %} /* Ignore @line declarations, replace them by a blank line */ -^@line[^\n]*\n { yylloc->lines(1); yylloc->step(); *yyout << endl; } +^@line[^\r\n]*(\r)?\n { yylloc->lines(1); yylloc->step(); *yyout << endl; } -^@include[ \t]+\" BEGIN(INCLUDE); +^@include[ \t]+\" BEGIN(INCLUDE); -[^\"\n]* { +[^\"\r\n]* { driver.ifs = new ifstream(yytext); if (driver.ifs->fail()) driver.error(*yylloc, "Could not open " + string(yytext)); @@ -88,13 +88,13 @@ typedef Macro::parser::token token; BEGIN(INITIAL); } -\"[^\n]*\n { - yylloc->lines(1); - yylloc->step(); - *yyout << "@line \"" << *yylloc->begin.filename << "\" " - << yylloc->begin.line << endl; - BEGIN(INITIAL); - } +\"[^\r\n]*(\r)?\n { + yylloc->lines(1); + yylloc->step(); + *yyout << "@line \"" << *yylloc->begin.filename << "\" " + << yylloc->begin.line << endl; + BEGIN(INITIAL); + } <> { /* We don't use yypop_buffer_state(), since it doesn't exist in @@ -116,6 +116,10 @@ typedef Macro::parser::token token; BEGIN(END_INCLUDE); } + /* Ignore Ctrl-M */ +(\r)+ { yylloc->step(); } + + /* Copy everything else to output */ [\n]+ { yylloc->lines(yyleng); yylloc->step(); ECHO; } . { yylloc->step(); ECHO; }