File: nvp.nfa

package info (click to toggle)
mairix 0.23+git20131125-0.3
  • links: PTS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 1,296 kB
  • ctags: 1,299
  • sloc: ansic: 11,345; sh: 1,000; yacc: 185; makefile: 135; lex: 87; perl: 34
file content (213 lines) | stat: -rw-r--r-- 4,674 bytes parent folder | download | duplicates (3)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#########################################################################
#
# mairix - message index builder and finder for maildir folders.
#
# Copyright (C) Richard P. Curnow  2006,2007
#
# 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.
#
# 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.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# =======================================================================

Tokens EOS
Abbrev VALUE = [\041-~]~[\\";]
Abbrev QVALUE = VALUE | [\011\040;] | <escape:in->out>
Abbrev NAME1 = [0-9a-zA-Z_\-]
Abbrev MINOR = NAME1 | [\.\-+]
Abbrev OWS = <optwhite:in->out>

%{
#include "nvptypes.h"
%}

Block escape {
    State in
        [\\] ; [\\] -> out
        [\\] ; ["]  -> out
}

Block optwhite {
    State in
        -> out
        # I have seen headers with ^M in them...
        [ \t\r] -> in
}

Block name {
    # This needs to cope with embedded spaces, e.g. for mailers that write '7
    # bit' instead of '7bit'
    State in
        NAME1 -> name1

    State name1
        = COPY_TO_NAME
        = GOT_NAME
        NAME1 -> name1
        [ \t] -> name2
        -> out

    State name2
        = COPY_TO_NAME
        = GOT_NAME_TRAILING_SPACE
        [ \t] -> name2
        NAME1 -> name1
        -> out

    State out
}

Block value {
    State in
        VALUE -> v1
    State v1
        = COPY_TO_VALUE
        -> out
        VALUE -> v1
}

Block qvalue {
    State in
        ["] -> qv0

    State qv0
        QVALUE -> qv1

    State qv1
        = COPY_TO_VALUE
        QVALUE -> qv1
        -> qv2

    State qv2
        ["] -> out
}

Block digits {
    State in
        [0-9] -> out
        [0-9] -> in
}

Block minor {
    State in
        MINOR -> minor1

    State minor1
        = COPY_TO_MINOR
        MINOR -> minor1
        -> out
}

Block namevalue {
    State in
        OWS ; <name:in->out> ; OWS ; [=] -> rhs_normal
        OWS ; <name:in->out> ; [*] ; <digits:in->out> ; OWS ; [=] -> rhs_continue
        OWS ; <name:in->out> ; [*] ; OWS ; [=] -> rhs_charset
        OWS ; <name:in->out> ; [*] ; [0] ; [*] ; OWS ; [=] -> rhs_charset
        OWS ; <name:in->out> ; [*] ; [1-9A-Za-z] ; [*] ; OWS ; [=] -> rhs_charset_continue

    State rhs_normal
        OWS ; <qvalue:in->out> ; OWS -> out_normal
        OWS ; <value:in->out> ; OWS -> out_normal
        OWS ; ; EOS -> out_normal

    State rhs_continue
        OWS ; <qvalue:in->out> ; OWS -> out_continue
        OWS ; <value:in->out> ; OWS -> out_continue

    State rhs_charset
        OWS ; ['] ; ['] ; <value:in->out> ; OWS -> out_charset
        OWS ; <minor:in->out> ; ['] ; ['] ; <value:in->out> ; OWS -> out_charset

    State rhs_charset_continue
        OWS ; <value:in->out> ; OWS -> out_charset_continue

    State out_normal = GOT_NAMEVALUE
        -> out
    State out_continue = GOT_NAMEVALUE_CONT
        -> out
    State out_charset = GOT_NAMEVALUE_CSET
        -> out
    State out_charset_continue = GOT_NAMEVALUE_CCONT
        -> out
}

Block major {
    State in
        NAME1 -> name1

    State name1
        NAME1 -> name1
        -> out
}

Block majorminor {
    State in
        <major:in->out> -> foo

    State foo
        [/] -> bar

    State bar
        <minor:in->out> -> out

    State out = GOT_MAJORMINOR
}

Block component {
    State in
        <namevalue:in->out> -> out
        <name:in->out> -> out
        <majorminor:in->out> -> out
}

Block main {
    State in Entry in
        OWS ; <component:in->out> ; OWS ; EOS -> out2
        OWS ; <component:in->out> ; OWS ; [;] ; OWS ; EOS -> out2
        OWS ; <component:in->out> ; OWS ; [;] -> in2

    State in2
        = GOT_TERMINATOR
        -> in

    State out2
        = GOT_TERMINATOR
        -> out
}

Defattr 0
Prefix nvp

Group action {
    Attr GOT_NAMEVALUE
    Attr GOT_NAMEVALUE_CONT
    Attr GOT_NAMEVALUE_CSET
    Attr GOT_NAMEVALUE_CCONT
    Attr GOT_NAME
    Attr GOT_NAME_TRAILING_SPACE
    Attr GOT_MAJORMINOR
    Attr GOT_TERMINATOR
    Defattr GOT_NOTHING
    Type "enum nvp_action"
}

Group copier {
    Attr COPY_TO_NAME
    Attr COPY_TO_MINOR
    Attr COPY_TO_VALUE
    Defattr COPY_NOWHERE
    Type "enum nvp_copier"
}

# vim:et:sts=4:sw=4:ht=8