datescan.nfa 2.85 KB
Newer Older
1 2 3 4
#########################################################################
#
# mairix - message index builder and finder for maildir folders.
#
5
# Copyright (C) Richard P. Curnow  2002-2004,2006
6 7 8 9
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
Richard P. Curnow's avatar
Richard P. Curnow committed
10
#
11 12 13 14
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
Richard P. Curnow's avatar
Richard P. Curnow committed
15
#
16 17
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 20
#
# =======================================================================
21 22 23 24 25

# NFA description for parsing dates

# Stuff to pass through verbatim
%{
26
#include "dates.h"
27 28
%}

29
Abbrev A = [a-zA-Z]
30

31
BLOCK day {
32
    State in
33 34 35
        [12] ; [0-9] -> out
        [3] ; [01]  -> out
}
36 37

# Match 2 digit year
38
BLOCK year {
39
    State in
40 41 42
        [04-9] ; [0-9]  -> out
        [3] ; [2-9] -> out
}
43

44
BLOCK month {
45 46
    State in
        A ; A ; A -> out
47
}
48

49
BLOCK scaled {
50
    State in
51
        [0-9] -> in, after_value
52 53 54

    State after_value
        A -> out
55
}
56

57
BLOCK ccyy {
58
    State in
59 60
        [1-9] ; [0-9] ; [0-9] ; [0-9] -> out
}
61

62
BLOCK main {
63
    State in
64
        [1-9] = DS_D
65 66 67
        <day:in->out> = DS_D
        <year:in->out> = DS_Y
        <ccyy:in->out> = DS_Y
68 69 70
        [0-9] ; [0-9] ; [0-9] ; [0-9] ; [0-9] ; [0-9] = DS_YYMMDD
        [0-9] ; [0-9] ; [0-9] ; [0-9] ;
            [0-9] ; [0-9] ; [0-9] ; [0-9] = DS_YYMMDD
71 72
        <scaled:in->out> = DS_SCALED
        <month:in->out> = DS_M
73
        [1-9] ; <month:in->out> = DS_DM
74
        <day:in->out> ; <month:in->out> = DS_DM
75
        <month:in->out> ; [1-9] = DS_MD
76 77 78 79 80
        <month:in->out> ; <day:in->out> = DS_MD
        <year:in->out> ; <month:in->out> = DS_YM
        <month:in->out> ; <year:in->out> = DS_MY
        <ccyy:in->out> ; <month:in->out> = DS_YM
        <month:in->out> ; <ccyy:in->out> = DS_MY
Richard P. Curnow's avatar
Richard P. Curnow committed
81

82
        <year:in->out> ; <month:in->out> ; [1-9] = DS_YMD
83
        <year:in->out> ; <month:in->out> ; <day:in->out> = DS_YMD
84
        [1-9] ; <month:in->out> ; <year:in->out> = DS_DMY
85
        <day:in->out> ; <month:in->out> ; <year:in->out> = DS_DMY
Richard P. Curnow's avatar
Richard P. Curnow committed
86

87
        <ccyy:in->out> ; <month:in->out> ; [1-9] = DS_YMD
88
        <ccyy:in->out> ; <month:in->out> ; <day:in->out> = DS_YMD
89
        [1-9] ; <month:in->out> ; <ccyy:in->out> = DS_DMY
90
        <day:in->out> ; <month:in->out> ; <ccyy:in->out> = DS_DMY
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
}

ATTR DS_D
ATTR DS_Y
ATTR DS_YYMMDD
ATTR DS_SCALED
ATTR DS_M
ATTR DS_DM
ATTR DS_MD
ATTR DS_YM
ATTR DS_MY
ATTR DS_YMD
ATTR DS_DMY

DEFATTR DS_FAILURE

107
TYPE "enum DATESCAN_TYPE"
108 109 110 111 112
PREFIX datescan


# vim:ft=txt:et:sw=4:sts=4:ht=4