summaryrefslogtreecommitdiffstats
path: root/libkholidays/scanholiday.lex
blob: 89de88707ffb45f363dab16ae729f9aec6702881 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
%{
#include <string.h>
#include "parseholiday.h"
#define YY_NO_UNPUT
%}

%option nomain
%option noyywrap
%option never-interactive
%option noalways-interactive
%option nostack

%%

#.*\n				;
^:.*\n				;
[ \t\r\n]				;
[-+*/%.!?:()\[\]]		{ return(*kcaltext); }

january				{ kcallval.ival =   1; return(MONTH); }
february			{ kcallval.ival =   2; return(MONTH); }
march				{ kcallval.ival =   3; return(MONTH); }
april				{ kcallval.ival =   4; return(MONTH); }
may				{ kcallval.ival =   5; return(MONTH); }
june				{ kcallval.ival =   6; return(MONTH); }
july				{ kcallval.ival =   7; return(MONTH); }
august				{ kcallval.ival =   8; return(MONTH); }
september			{ kcallval.ival =   9; return(MONTH); }
october				{ kcallval.ival =  10; return(MONTH); }
november			{ kcallval.ival =  11; return(MONTH); }
december			{ kcallval.ival =  12; return(MONTH); }

monday				{ kcallval.ival =   1; return(WDAY); }
tuesday				{ kcallval.ival =   2; return(WDAY); }
wednesday			{ kcallval.ival =   3; return(WDAY); }
thursday			{ kcallval.ival =   4; return(WDAY); }
friday				{ kcallval.ival =   5; return(WDAY); }
saturday			{ kcallval.ival =   6; return(WDAY); }
sunday				{ kcallval.ival =   7; return(WDAY); }

1st|first			{ kcallval.ival =   1; return(NUMBER); }
2nd|second			{ kcallval.ival =   2; return(NUMBER); }
3rd|third			{ kcallval.ival =   3; return(NUMBER); }
4th|fourth			{ kcallval.ival =   4; return(NUMBER); }
5th|fifth			{ kcallval.ival =   5; return(NUMBER); }
last				{ kcallval.ival = 999; return(NUMBER); }
any				{ kcallval.ival =   0; return(NUMBER); }

before				{ kcallval.ival =  -1; return(NUMBER); }
after				{ kcallval.ival =  -2; return(NUMBER); }

[0-9]+				{ kcallval.ival = atoi(kcaltext); return(NUMBER); }

\"[^"]*\"			{ kcallval.sval = strdup(kcaltext+1);
				  kcallval.sval[strlen(kcallval.sval)-1] = 0;
				  return(STRING); }

every				;
day				;
days				;
on				;
to				;
in				{ return(IN);    }
if				{ return(IF); }
plus				{ return(PLUS);  }
minus				{ return(MINUS); }
small				{ return(SMALL); }
year				{ return(CYEAR);  }
leapyear			{ return(LEAPYEAR); }
easter				{ return(EASTER); }
pascha				{ return(PASCHA); }
length				{ return(LENGTH); }
shift				{ return(SHIFT); }

black				{ kcallval.ival = 1; return(COLOR); }
red				{ kcallval.ival = 2; return(COLOR); }
green				{ kcallval.ival = 3; return(COLOR); }
yellow				{ kcallval.ival = 4; return(COLOR); }
blue				{ kcallval.ival = 5; return(COLOR); }
magenta				{ kcallval.ival = 6; return(COLOR); }
cyan				{ kcallval.ival = 7; return(COLOR); }
white				{ kcallval.ival = 8; return(COLOR); }
weekend				{ kcallval.ival = 9; return(COLOR); }

"=="				{ return(EQ); }
"!="				{ return(NE); }
"<="				{ return(LE); }
">="				{ return(GE); }
"<"				{ return(LT); }
">"				{ return(GT); }
"&&"				{ return(AND);}
"||"				{ return(OR); }

.				{ printf("holiday: bad char: %s \n", kcaltext); }

%%