17 action prn_char { cout << *p; }
18 action prn_space { cout << ' '; }
19 action prn_word { cout.write(ws, p-ws); cout << ' '; }
20 action prn_addr1 { cout << "| "; cout.write(ws+1, p-ws-2); }
21 action prn_addr2 { cout << "| "; cout.write(ws, p-ws); }
22 action prn_tab { cout << '\t'; }
23 action prn_nl { cout << '\n'; }
24 action prn_separator { cout << "------\n"; }
25 action prn_from { cout << "FROM\n"; }
26 action prn_to { cout << "TO\n"; }
27 action prn_subj { cout << "SUBJECT\n"; }
29 action start_word { ws = p; }
30 action start_headers { preserve = p; }
31 action end_headers {preserve = 0;}
34 month = upper lower{2};
36 time = digit{2} ':' digit{2}
38 letterZone = upper{3};
39 numZone = [+\-] digit{4};
40 zone = letterZone | numZone;
41 dayNum = ( digit | ' ' ) digit;
43 date = day ' ' month ' '
51 fromLine = 'From ' [^\n]* ' '
52 date '\n' @start_headers;
54 headerChar = print - [ :];
55 headersToPrint = 'From' |
58 headerChar+ - headersToPrint;
60 action init_hlen {hlen = 0;}
61 action hlen {hlen++ < 50}
72 headersToConsume consumeHeaderBody;
74 addrWS = ( [ \t]+ | '\n' [ \t]+ );
75 addrComment = '(' [^)]* ')';
76 addrWord = [^"'@,<>() \t\n]+;
77 addrAddr1 = '<' [^>]* '>';
78 addrAddr2 = addrWord '@' addrWord;
84 addrAddr1 %prn_addr1 |
85 addrAddr2 %prn_addr2 |
100 ( address ( ',' @prn_nl address )* ) when hlen
104 'Subject:' @prn_subj @prn_tab @init_hlen
109 ( '\n' [ \t]+ ) %prn_space
114 header = consumeHeader |
115 addrHeader | subjectHeader;
118 ( [^\n]* when hlen '\n' @init_hlen ) - fromLine;
121 fromLine %prn_separator
123 '\n' @end_headers @init_hlen
132 void test( const char *buf )
134 int cs, len = strlen( buf );
135 const char *preserve = 0, *ws = 0;
140 const char *pe = p + len;
143 if ( cs < mailbox_first_final ) {
144 cout << endl << endl;
145 cout << "DID NOT FINISH IN A FINAL STATE" << endl;
152 "From user@host.com Wed Nov 28 13:30:05 2001\n"
153 "From: \"Adrian D. Thurston\" <thurston@cs.queensu.ca>\n"
154 "Subject: the squirrel has landed\n"
156 "Message goes here. \n"
157 "From (trick from line).\n"
158 "From: not really a header\n"
160 "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
161 "To: \"(kill 1)\" Edgar Allen Poe <ep@net.com> (da man)\n"
162 "Subject: (no subject) this is a really long subject which should fail the length constraint \n"
163 "Other: 0123456789\n"
165 "Message goes here. \n"
169 "From user@host.com Wed Nov 28 13:30:05 2001\n"
170 "To: \"(kill 2)\" some guy <sg@net.com>\n"
171 "From: \"Adrian D. Thurston this name is far too long\" <thurston@cs.queensu.ca>\n"
172 "Subject: the squirrel has landed\n"
174 "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
175 "To: Edgar Allen Poe <ep@net.com> (da man)\n"
176 "Subject: (no subject) \n"
180 "From user@host.com Wed Nov 28 13:30:05 2001\n"
181 "To: \"(kill 3)\" some guy <sg@net.com>\n"
182 "From: \"Adrian D. Thurston This name is fore sure absolutely too long\" <t@cs.ca>\n"
183 "Subject: the squirrel has landed\n"
187 "From user@host.com Wed Nov 28 13:30:05 2001\n"
188 "From: \"Adrian D. Thurston \" <t@cs.ca>\n"
189 "Subject: (kill 4) the squirrel has landed\n"
190 "Other: This is another header field, not interpreted, that is too long\n"
194 "From user@host.com Wed Nov 28 13:30:05 2001\n"
195 "From: \"Adrian D. Thurston \" <t@cs.ca>\n"
196 "Subject: (kill 5)the squirrel has landed\n"
198 "This message line is okay.\n"
199 "But this message line is far too long and will cause an error.\n"
204 #ifdef _____OUTPUT_____
207 "Adrian D. Thurston" | thurston@cs.queensu.ca
209 the squirrel has landed
212 "(kill 1)" Edgar Allen Poe | ep@net.com
214 (no subject) this is a really long subject whic
216 DID NOT FINISH IN A FINAL STATE
219 "(kill 2)" some guy | sg@net.com
221 "Adrian D. Thurston this name is far too long"
223 DID NOT FINISH IN A FINAL STATE
226 "(kill 3)" some guy | sg@net.com
230 DID NOT FINISH IN A FINAL STATE
233 "Adrian D. Thurston " | t@cs.ca
235 (kill 4) the squirrel has landed
238 DID NOT FINISH IN A FINAL STATE
241 "Adrian D. Thurston " | t@cs.ca
243 (kill 5)the squirrel has landed
246 DID NOT FINISH IN A FINAL STATE