macroprocessor: substitute dates, don't substitute dates preceded by $ or dates('
parent
84dd46d9e5
commit
9be1d084fd
|
@ -51,6 +51,7 @@ typedef Macro::parser::token token;
|
||||||
%x FOR_BODY
|
%x FOR_BODY
|
||||||
%x THEN_BODY
|
%x THEN_BODY
|
||||||
%x ELSE_BODY
|
%x ELSE_BODY
|
||||||
|
%x END_DATE
|
||||||
|
|
||||||
%{
|
%{
|
||||||
// Increments location counter for every token read
|
// Increments location counter for every token read
|
||||||
|
@ -60,6 +61,7 @@ typedef Macro::parser::token token;
|
||||||
SPC [ \t]+
|
SPC [ \t]+
|
||||||
EOL (\r)?\n
|
EOL (\r)?\n
|
||||||
CONT \\\\
|
CONT \\\\
|
||||||
|
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() */
|
/* Code put at the beginning of yylex() */
|
||||||
|
@ -87,6 +89,12 @@ CONT \\\\
|
||||||
<INITIAL>^{SPC}*@# { yylloc->step(); BEGIN(STMT); }
|
<INITIAL>^{SPC}*@# { yylloc->step(); BEGIN(STMT); }
|
||||||
<INITIAL>@\{ { yylloc->step(); BEGIN(EXPR); }
|
<INITIAL>@\{ { yylloc->step(); BEGIN(EXPR); }
|
||||||
|
|
||||||
|
<INITIAL>{DATE} { yylloc->step(); *yyout << "dates('" << yytext << "')"; }
|
||||||
|
<INITIAL>${DATE} { yylloc->step(); *yyout << yytext + 1; }
|
||||||
|
|
||||||
|
<INITIAL>dates{SPC}*\({SPC}*\'{DATE} { yylloc->step(); *yyout << yytext; BEGIN(END_DATE); }
|
||||||
|
<END_DATE>{SPC}*\'{SPC}*\) { yylloc->step(); *yyout << yytext; BEGIN(INITIAL); }
|
||||||
|
|
||||||
<EXPR>\} { BEGIN(INITIAL); return token::EOL; }
|
<EXPR>\} { BEGIN(INITIAL); return token::EOL; }
|
||||||
|
|
||||||
<STMT>{CONT}{SPC}*{EOL} { yylloc->lines(1); yylloc->step(); }
|
<STMT>{CONT}{SPC}*{EOL} { yylloc->lines(1); yylloc->step(); }
|
||||||
|
|
Loading…
Reference in New Issue