Remove building with NOCRYPTO option
[minix3.git] / external / bsd / flex / dist / examples / manual / dates.lex
blob9429e1dba87a5d72c51f79761184192b6991412f
1 /*
2  * dates.lex: An example of using start states to
3  *            distinguish between different date formats.
4  */
6 %{
7 #include <ctype.h>
9 char month[20],dow[20],day[20],year[20];
13 skip        of|the|[ \t,]*
15 mon         (mon(day)?)
16 tue         (tue(sday)?)
17 wed         (wed(nesday)?)
18 thu         (thu(rsday)?)
19 fri         (fri(day)?)
20 sat         (sat(urday)?)
21 sun         (sun(day)?)
23 day_of_the_week ({mon}|{tue}|{wed}|{thu}|{fri}|{sat}|{sun})
25 jan         (jan(uary)?)
26 feb         (feb(ruary)?)
27 mar         (mar(ch)?)
28 apr         (apr(il)?)
29 may         (may)
30 jun         (jun(e)?)
31 jul         (jul(y)?)
32 aug         (aug(ust)?)
33 sep         (sep(tember)?)
34 oct         (oct(ober)?)
35 nov         (nov(ember)?)
36 dec         (dec(ember)?)
38 first_half  ({jan}|{feb}|{mar}|{apr}|{may}|{jun})
39 second_half ({jul}|{aug}|{sep}|{oct}|{nov}|{dec})
40 month       {first_half}|{second_half}
42 nday         [1-9]|[1-2][0-9]|3[0-1]
43 nmonth       [1-9]|1[0-2]
44 nyear        [0-9]{1,4}
46 year_ext    (ad|AD|bc|BC)?
47 day_ext     (st|nd|rd|th)?
49 %s LONG SHORT
50 %s DAY DAY_FIRST YEAR_FIRST YEAR_LAST YFMONTH YLMONTH
54   /* the default is month-day-year */
56 <LONG>{day_of_the_week}    strcpy(dow,yytext); 
57 <LONG>{month}              strcpy(month,yytext); BEGIN(DAY);
59   /* handle the form: day-month-year */
61 <LONG>{nday}{day_ext}      strcpy(day,yytext);   BEGIN(DAY_FIRST);
62 <DAY_FIRST>{month}         strcpy(month,yytext); BEGIN(LONG);
63 <DAY>{nday}{day_ext}       strcpy(day,yytext);   BEGIN(LONG);  
65 <LONG>{nyear}{year_ext}  {
66                            printf("Long:\n");
67                            printf("  DOW   : %s \n",dow);
68                            printf("  Day   : %s \n",day);
69                            printf("  Month : %s \n",month);
70                            printf("  Year  : %s \n",yytext);
71                            strcpy(dow,"");
72                            strcpy(day,"");
73                            strcpy(month,"");
74                          }
76   /* handle dates of the form: day-month-year */
78 <SHORT>{nday}              strcpy(day,yytext);  BEGIN(YEAR_LAST);
79 <YEAR_LAST>{nmonth}        strcpy(month,yytext);BEGIN(YLMONTH);
80 <YLMONTH>{nyear}           strcpy(year,yytext); BEGIN(SHORT);
82   /* handle dates of the form: year-month-day */
84 <SHORT>{nyear}             strcpy(year,yytext); BEGIN(YEAR_FIRST);
85 <YEAR_FIRST>{nmonth}       strcpy(month,yytext);BEGIN(YFMONTH);
86 <YFMONTH>{nday}            strcpy(day,yytext);  BEGIN(SHORT);
89 <SHORT>\n                {
90                            printf("Short:\n");
91                            printf("  Day   : %s \n",day);
92                            printf("  Month : %s \n",month);
93                            printf("  Year  : %s \n",year);
94                            strcpy(year,""); 
95                            strcpy(day,"");
96                            strcpy(month,"");
97                          }
99 long\n                      BEGIN(LONG);
100 short\n                     BEGIN(SHORT);
102 {skip}*