Skip to content
Snippets Groups Projects
Commit d2e93452 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

preprocessor: match dates in dynare syntax

parent fae00ea7
No related branches found
No related tags found
No related merge requests found
......@@ -69,6 +69,9 @@ string eofbuff;
// Increments location counter for every token read
#define YY_USER_ACTION location_increment(yylloc, yytext);
%}
DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2]))
%%
/* Code put at the beginning of yylex() */
%{
......@@ -205,6 +208,23 @@ string eofbuff;
<INITIAL>corr {BEGIN DYNARE_STATEMENT; return token::CORR;}
/* Inside of a Dynare statement */
<DYNARE_STATEMENT>{DATE} {
char *yycopy = strdup(yytext);
char *uput = yycopy + yyleng;
unput(')');
unput('\'');
while (uput > yycopy)
unput(*--uput);
unput('\'');
unput('(');
unput('s');
unput('e');
unput('t');
unput('a');
unput('d');
free( yycopy );
}
<DYNARE_STATEMENT>${DATE} { yylloc->step(); *yyout << yytext + 1; }
<DYNARE_STATEMENT>dates {dates_parens_nb=0; BEGIN DATES_STATEMENT; yylval->string_val = new string("dates");}
<DYNARE_STATEMENT>file {return token::FILE;}
<DYNARE_STATEMENT>datafile {return token::DATAFILE;}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment