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;
68 addrWS = ( [ \t]+ | '\n' [ \t]+ );
69 addrComment = '(' [^)]* ')';
70 addrWord = [^"'@,<>() \t\n]+;
71 addrAddr1 = '<' [^>]* '>';
72 addrAddr2 = addrWord '@' addrWord;
78 addrAddr1 %prn_addr1 |
79 addrAddr2 %prn_addr2 |
94 address ( ',' @prn_nl address )*
98 'Subject:' @prn_subj @prn_tab
102 ( '\n' [ \t]+ ) %prn_space
106 header = consumeHeader |
107 addrHeader | subjectHeader;
110 ( [^\n]* '\n' - fromLine );
113 fromLine %prn_separator
124 void test( char *buf )
126 int cs, len = strlen( buf );
127 char *preserve = 0, *ws = 0;
134 if ( cs == mailbox_error )
135 cerr << "ERROR" << endl;
137 if ( cs < mailbox_first_final )
138 cerr << "DID NOT FINISH IN A FINAL STATE" << endl;
144 "From user@host.com Wed Nov 28 13:30:05 2001\n"
145 "From: \"Adrian D. Thurston\" <thurston@cs.queensu.ca>\n"
146 "Subject: the squirrel has landed\n"
148 "Message goes here. \n"
149 "From (trick from line).\n"
150 "From: not really a header\n"
152 "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
153 "To: Edgar Allen Poe <ep@net.com> (da man)\n"
154 "Subject: (no subject) \n"
156 "Message goes here. \n"
162 #ifdef _____OUTPUT_____
165 "Adrian D. Thurston" | thurston@cs.queensu.ca
167 the squirrel has landed
170 Edgar Allen Poe | ep@net.com