Statistics
| Branch: | Tag: | Revision:

dvbd / src / time-lexer.l @ fc92ba5f

History | View | Annotate | Download (2.01 KB)

1 bfdb7446 jak
%{
2
3
#include <string.h>
4
#include <time.h>
5 1eb242d0 jak
#include "time-parser.h"
6 bfdb7446 jak
#include "parsetime.h"
7
8
char *last_token = NULL;
9
char **my_argv;
10
11
#define COPY_TOK do { last_token = strdup(yytext); } while(0)
12
13
#define COPY_VAL do { yylval.charval = strdup(yytext); } while(0)
14
15
#define YY_INPUT(buf,result,max_size) \
16
    do { \
17
	if (*my_argv == NULL) { \
18
	    result = YY_NULL ;\
19
	    buf[0] = 0; \
20
	} \
21
	else { \
22
	    if (**my_argv == '\0') { \
23
		buf[0] = ' ' ; \
24
		my_argv ++; \
25
	    } \
26
	    else { \
27
		buf[0] = **my_argv; \
28
		(*my_argv) ++; \
29
	    } \
30
	result = 1; \
31
	} \
32
    } while(0)
33
%}
34
35
WORD		[a-z][a-z0-9]+
36
%%
37
38
now		{ COPY_TOK ; return NOW; }
39
am		{ COPY_TOK ; return AM; }
40
pm		{ COPY_TOK ; return PM; }
41
noon		{ COPY_TOK ; return NOON; }
42
midnight	{ COPY_TOK ; return MIDNIGHT; }
43
teatime		{ COPY_TOK ; return TEATIME; }
44
sun(day)?	{ COPY_TOK ; return SUN; }
45
mon(day)?	{ COPY_TOK ; return MON; }
46
tue(sday)?	{ COPY_TOK ; return TUE; }
47
wed(nesday)?	{ COPY_TOK ; return WED; }
48
thu(rsday)?	{ COPY_TOK ; return THU; }
49
fri(day)?	{ COPY_TOK ; return FRI; }
50
sat(urday)?	{ COPY_TOK ; return SAT; }
51
today		{ COPY_TOK ; return TODAY; }
52
tomorrow	{ COPY_TOK ; return TOMORROW; }
53
next		{ COPY_TOK ; return NEXT; }
54
min		{ COPY_TOK ; return MINUTE; }
55
minute(s)?	{ COPY_TOK ; return MINUTE; }
56
hour(s)?	{ COPY_TOK ; return HOUR; }
57
day(s)?		{ COPY_TOK ; return DAY; }
58
week(s)?	{ COPY_TOK ; return WEEK; }
59
month(s)?	{ COPY_TOK ; return MONTH; }
60
jan(uary)?	{ COPY_TOK ; return JAN; }
61
feb(ruary)?	{ COPY_TOK ; return FEB; }
62
mar(ch)?	{ COPY_TOK ; return MAR; }
63
apr(il)?	{ COPY_TOK ; return APR; }
64
may		{ COPY_TOK ; return MAY; }
65
jun(e)?		{ COPY_TOK ; return JUN; }
66
jul(y)?		{ COPY_TOK ; return JUL; }
67
aug(ust)?	{ COPY_TOK ; return AUG; }
68
sep(tember)?	{ COPY_TOK ; return SEP; }
69
oct(ober)?	{ COPY_TOK ; return OCT; }
70
nov(ember)?	{ COPY_TOK ; return NOV; }
71
dec(ember)?	{ COPY_TOK ; return DEC; }
72
[0-9]+		{ COPY_TOK ; COPY_VAL; return INT; }
73
[ \t\n]		;
74
{WORD}		{ COPY_TOK ; COPY_VAL; return WORD; }
75
.		{ COPY_TOK ; return yytext[0]; }
76
77
%%
78
79
#ifdef NEED_YYWRAP
80
int yywrap()
81
{
82
    return 1;
83
}
84
#endif