v4 preprocessor: ignore Ctrl-M in macro-processor

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1699 ac1d8469-bf42-47a9-8791-bf33cf982152
issue#70
sebastien 2008-02-08 13:10:10 +00:00
parent aac0db2568
commit b9441c887e
2 changed files with 15 additions and 11 deletions

View File

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

View File

@ -62,11 +62,11 @@ typedef Macro::parser::token token;
%}
/* Ignore @line declarations, replace them by a blank line */
<INITIAL>^@line[^\n]*\n { yylloc->lines(1); yylloc->step(); *yyout << endl; }
<INITIAL>^@line[^\r\n]*(\r)?\n { yylloc->lines(1); yylloc->step(); *yyout << endl; }
<INITIAL>^@include[ \t]+\" BEGIN(INCLUDE);
<INITIAL>^@include[ \t]+\" BEGIN(INCLUDE);
<INCLUDE>[^\"\n]* {
<INCLUDE>[^\"\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);
}
<END_INCLUDE>\"[^\n]*\n {
yylloc->lines(1);
yylloc->step();
*yyout << "@line \"" << *yylloc->begin.filename << "\" "
<< yylloc->begin.line << endl;
BEGIN(INITIAL);
}
<END_INCLUDE>\"[^\r\n]*(\r)?\n {
yylloc->lines(1);
yylloc->step();
*yyout << "@line \"" << *yylloc->begin.filename << "\" "
<< yylloc->begin.line << endl;
BEGIN(INITIAL);
}
<<EOF>> {
/* 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 */
<INITIAL>(\r)+ { yylloc->step(); }
/* Copy everything else to output */
<INITIAL>[\n]+ { yylloc->lines(yyleng); yylloc->step(); ECHO; }
<INITIAL>. { yylloc->step(); ECHO; }