diff --git a/preprocessor/macro/MacroDriver.hh b/preprocessor/macro/MacroDriver.hh index 0ae177ff2..0945a3296 100644 --- a/preprocessor/macro/MacroDriver.hh +++ b/preprocessor/macro/MacroDriver.hh @@ -86,8 +86,6 @@ private: //! If current context is the body of a loop, contains the location of the beginning of the body Macro::parser::location_type for_body_loc; - //! Temporary variable used for counting parens in dates statement - int dates_parens_nb; //! Temporary variable used in FOR_BODY mode string for_body_tmp; //! Temporary variable used in FOR_BODY mode diff --git a/preprocessor/macro/MacroFlex.ll b/preprocessor/macro/MacroFlex.ll index dc8fe29b9..09c04da01 100644 --- a/preprocessor/macro/MacroFlex.ll +++ b/preprocessor/macro/MacroFlex.ll @@ -51,7 +51,8 @@ typedef Macro::parser::token token; %x FOR_BODY %x THEN_BODY %x ELSE_BODY -%x COPY_DATE_INFO +%x DATE_MATCH +%x CLOSE_DATE %{ // Increments location counter for every token read @@ -92,17 +93,10 @@ DATE (-[1-9][0-9]*|[0-9]+)([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1- {DATE} { yylloc->step(); *yyout << "dates('" << yytext << "')"; } ${DATE} { yylloc->step(); *yyout << yytext + 1; } -dates{SPC}*\({SPC}* { yylloc->step(); *yyout << "dates("; dates_parens_nb=1; BEGIN(COPY_DATE_INFO); } -<> { driver.error(*yylloc, "Unexpected end of file in dates statement"); } -{EOL} { yylloc->lines(1); yylloc->step(); } -[^()] { yylloc->step(); *yyout << yytext; } -\( { yylloc->step(); *yyout << yytext; dates_parens_nb++; } -\) { - yylloc->step(); - *yyout << yytext; - if (--dates_parens_nb == 0) - BEGIN(INITIAL); - } +dates{SPC}*\({SPC}* { yylloc->step(); *yyout << "dates("; BEGIN(DATE_MATCH); } +\'{SPC}*{DATE}{SPC}*\' { yylloc->step(); *yyout << yytext; BEGIN(CLOSE_DATE); } +{DATE} { yylloc->step(); *yyout << "'" << yytext << "'"; BEGIN(CLOSE_DATE); } +{SPC}*\) { yylloc->step(); *yyout << ")"; BEGIN(INITIAL); } \} { BEGIN(INITIAL); return token::EOL; }