%{
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ipex_includes.h>
#include "y.tab.h"
#define SETSVAL(x) (time_parselval.string = strdup((x)))
%}
%option noyywrap
%%
DATE { return (DATE); }
TIME { return (TIME); }
"=" { return (EQ); }
"><" { return (GL); }
">" { return (GT); }
"<" { return (LT); }
">=" |
"=>" { return (GE); }
"<=" |
"=<" { return (LE); }
[0-9]{1,2}":"[0-9]{1,2}":"[0-9]{1,2} { SETSVAL(yytext); return (TIMESPEC); }
[0-9]{4}"-"[0-9]{2}"-"[0-9]{2} { SETSVAL(yytext); return (DATESPEC); }
[ \t] ;
\n return (0);
%%
int
readtimespec(const char *string)
{
if ((dsp = calloc(1, sizeof(struct datespec))) == 0)
errx(1, "exhausted memory.");
yy_switch_to_buffer(time_parse_scan_string(string));
time_parseparse();
yy_delete_buffer(YY_CURRENT_BUFFER);
return (0);
}
void
time_parseerror(char *msg)
{
printf("compilation error: %s\n", yytext);
exit(1);
}
syntax highlighted by Code2HTML, v. 0.9.1