Mercurial > ~dholland > hg > ag > index.cgi
comparison tests/agcl/parsifal/rfc822a.syn @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 Transcription of RFC822 grammar to AnaGram Syntax | |
3 Transcription copyright (c) Parsifal Software, 1997. All Rights Reserved. | |
4 See the file COPYING for license and usage terms. | |
5 | |
6 Grammar taken from RFC 822 | |
7 | |
8 The rules as given in RFC 822 have been retained as comments. | |
9 In a few cases obvious errors or questionable syntax was observed. | |
10 These are noted in // comments | |
11 */ | |
12 | |
13 { | |
14 #define GET_CONTEXT CONTEXT = PCB.pointer | |
15 } | |
16 [ | |
17 pointer input | |
18 ~case sensitive | |
19 grammar token = message | |
20 context type = unsigned char * | |
21 eof token = CRLF | |
22 sticky {atom, word, {linear_space}..., number} | |
23 ] | |
24 | |
25 | |
26 | |
27 { | |
28 /************************************************************** | |
29 * Input function to the parsing engine. | |
30 * | |
31 * It takse a pointer to a string and a ponter to a Request Object | |
32 * that will be populated | |
33 ***************************************************************/ | |
34 /*INT rfc822_parser(char *buffer, CRfc822Req *Request) | |
35 { | |
36 PCB.pointer = (unsigned char *)buffer; | |
37 pRequest = Request; | |
38 rfc822parse(); | |
39 return PCB.exit_flag; | |
40 | |
41 }*/ | |
42 } | |
43 | |
44 | |
45 | |
46 | |
47 /*************************************************************************** | |
48 * address = mailbox ; one addressee | |
49 * / group ; named list | |
50 ****************************************************************************/ | |
51 address | |
52 -> mailbox | |
53 -> group | |
54 | |
55 | |
56 /*************************************************************************** | |
57 * addr-spec = local-part "@" domain ; global address | |
58 ****************************************************************************/ | |
59 addr_spec | |
60 -> local_part,'@',domain | |
61 | |
62 | |
63 /*************************************************************************** | |
64 * ALPHA = <any ASCII alphabetic character> | |
65 * ; (101-132, 65.- 90.) | |
66 * ; (141-172, 97.-122.) | |
67 ****************************************************************************/ | |
68 ALPHA = 'a-z' + 'A-Z' | |
69 | |
70 | |
71 /*************************************************************************** | |
72 * atom = 1*<any CHAR except specials, SPACE and CTLs> | |
73 ****************************************************************************/ | |
74 atom | |
75 -> ATOM_CHAR | |
76 -> atom, ATOM_CHAR | |
77 | |
78 ATOM_CHAR = CHAR - atom_specials | |
79 | |
80 atom_specials = SPACE + CTL + specials | |
81 | |
82 /*************************************************************************** | |
83 * authentic = "From" ":" mailbox ; Single author | |
84 * / ( "Sender" ":" mailbox ; Actual submittor | |
85 * "From" ":" 1#mailbox) ; Multiple authors | |
86 * ; or not sender | |
87 ****************************************************************************/ | |
88 authentic | |
89 -> "From",':',mailbox | |
90 -> '(',"Sender",':',mailbox, SPACE,"From",':',multiple_mailboxes,')' | |
91 | |
92 multiple_mailboxes | |
93 -> mailbox | |
94 -> multiple_mailboxes, SPACE?, mailbox | |
95 | |
96 | |
97 /*************************************************************************** | |
98 * CHAR = <any ASCII character> ; ( 0-177, 0.-127.) | |
99 ****************************************************************************/ | |
100 CHAR = 0x00..0x7F | |
101 | |
102 | |
103 /*************************************************************************** | |
104 * comment = "(" *(ctext / quoted-pair / comment) ")" | |
105 ****************************************************************************/ | |
106 comment | |
107 -> '(', comment_choice,')' | |
108 | |
109 comment_choice | |
110 -> ctext | |
111 -> quoted_pair | |
112 -> comment | |
113 | |
114 | |
115 /*************************************************************************** | |
116 * CR = <ASCII CR, carriage return> ; ( 15, 13.) | |
117 ****************************************************************************/ | |
118 CR = 0x0D | |
119 | |
120 | |
121 /*************************************************************************** | |
122 * CRLF = CR LF | |
123 ****************************************************************************/ | |
124 CRLF | |
125 -> "\r\n" //CR,LF | |
126 | |
127 | |
128 /*************************************************************************** | |
129 * ctext = <any CHAR excluding "(", ; => may be folded | |
130 * ")", "\" & CR, & including | |
131 * linear-white-space> | |
132 ****************************************************************************/ | |
133 ctext | |
134 -> CHAR - ctext_specials | |
135 ->linear_white_space | |
136 | |
137 ctext_specials = '(' + ')' + '\\' + CR | |
138 | |
139 | |
140 /*************************************************************************** | |
141 * CTL = <any ASCII control ; ( 0- 37, 0.- 31.) | |
142 * character and DEL> ; ( 177, 127.) | |
143 ****************************************************************************/ | |
144 CTL = 0x00..0x1F + 0x7F | |
145 | |
146 | |
147 | |
148 /*************************************************************************** | |
149 * date = 1*2DIGIT month 2DIGIT ; day month year | |
150 * ; e.g. 20 Jun 82 | |
151 ****************************************************************************/ | |
152 date | |
153 -> day_numb,SPACE, month,SPACE, year | |
154 | |
155 day_numb | |
156 -> number | |
157 | |
158 year | |
159 -> number | |
160 | |
161 number | |
162 -> DIGIT | |
163 -> number, DIGIT | |
164 | |
165 /*************************************************************************** | |
166 * dates = orig-date ; Original | |
167 * [ resent-date ] ; Forwarded | |
168 ****************************************************************************/ | |
169 dates | |
170 -> orig_date | |
171 -> orig_date, SPACE, resent_date | |
172 | |
173 | |
174 /*************************************************************************** | |
175 * date-time = [ day "," ] date time ; dd mm yy | |
176 * ; hh:mm:ss zzz | |
177 ****************************************************************************/ | |
178 date_time | |
179 -> [ day, ','] , date, time | |
180 | |
181 | |
182 /*************************************************************************** | |
183 * day = "Mon" / "Tue" / "Wed" / "Thu" | |
184 * / "Fri" / "Sat" / "Sun" | |
185 ****************************************************************************/ | |
186 day | |
187 -> "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun" | |
188 | |
189 | |
190 | |
191 /*************************************************************************** | |
192 * delimiters = specials / linear-white-space / comment | |
193 ****************************************************************************/ | |
194 delimeters | |
195 -> specials | |
196 -> linear_white_space | |
197 -> comment | |
198 | |
199 /*************************************************************************** | |
200 * destination = "To" ":" 1#address ; Primary | |
201 * / "Resent-To" ":" 1#address | |
202 * / "cc" ":" 1#address ; Secondary | |
203 * / "Resent-cc" ":" 1#address | |
204 * / "bcc" ":" #address ; Blind carbon | |
205 * / "Resent-bcc" ":" #address | |
206 ****************************************************************************/ | |
207 destination | |
208 -> "To",':',addresses | |
209 -> "Resent-To",':',addresses | |
210 -> "cc",':',addresses | |
211 -> "Recent-cc",':',addresses | |
212 -> "bcc",':', address? | |
213 -> "Resent-bcc",':', address? | |
214 | |
215 addresses | |
216 -> address | |
217 -> addresses,SPACE,address | |
218 | |
219 /*************************************************************************** | |
220 * DIGIT = <any ASCII decimal digit> ; ( 60- 71, 48.- 57.) | |
221 ****************************************************************************/ | |
222 DIGIT = '0-9' | |
223 | |
224 /*************************************************************************** | |
225 * domain = sub-domain *("." sub-domain) | |
226 ****************************************************************************/ | |
227 domain | |
228 -> multiple_sub_domains | |
229 | |
230 multiple_sub_domains | |
231 -> sub_domain | |
232 -> multiple_sub_domains,'.',sub_domain | |
233 | |
234 /*************************************************************************** | |
235 * domain-literal = "[" *(dtext / quoted-pair) "]" | |
236 ****************************************************************************/ | |
237 domain_literal | |
238 -> '[', literal_fill..., ']' | |
239 | |
240 literal_fill | |
241 -> dtext | |
242 -> quoted_pair | |
243 | |
244 | |
245 | |
246 /*************************************************************************** | |
247 * domain-ref = atom ; symbolic reference | |
248 ****************************************************************************/ | |
249 domain_ref | |
250 -> atom | |
251 | |
252 | |
253 /*************************************************************************** | |
254 * dtext = <any CHAR excluding "[", ; => may be folded | |
255 * "]", "\" & CR, & including | |
256 * linear-white-space> | |
257 ****************************************************************************/ | |
258 dtext | |
259 -> CHAR - dtext_specials | |
260 -> linear_white_space | |
261 | |
262 //Added SPACE and TAB otherwise grammer would be ambiguous since they also appear in | |
263 //definition of liner_white_space | |
264 | |
265 dtext_specials = '[' + ']' + '\\'+ CR + SPACE + HTAB | |
266 | |
267 /*************************************************************************** | |
268 * extension-field = | |
269 * <Any field which is defined in a document | |
270 * published as a formal extension to this | |
271 * specification; none will have names beginning | |
272 * with the string "X-"> | |
273 ****************************************************************************/ | |
274 | |
275 | |
276 | |
277 | |
278 /*************************************************************************** | |
279 * field = field-name ":" [ field-body ] CRLF | |
280 ****************************************************************************/ | |
281 field | |
282 -> field_name, ':',[field_body],CRLF | |
283 | |
284 | |
285 /*************************************************************************** | |
286 * fields = dates ; Creation time, | |
287 * source ; author id & one | |
288 * 1*destination ; address required | |
289 * *optional-field ; others optional | |
290 ****************************************************************************/ | |
291 fields | |
292 -> fields_makeup | |
293 -> fields, fields_makeup | |
294 | |
295 fields_makeup | |
296 -> dates | |
297 -> source | |
298 -> destination | |
299 -> optional_field | |
300 | |
301 | |
302 /*************************************************************************** | |
303 * field-body = field-body-contents | |
304 * [CRLF LWSP-char field-body] | |
305 ****************************************************************************/ | |
306 field_body | |
307 -> field_body_contents, [CRLF,LWSP_char,field_body] | |
308 | |
309 | |
310 /*************************************************************************** | |
311 * field-body-contents = | |
312 * <the ASCII characters making up the field-body, as | |
313 * defined in the following sections, and consisting | |
314 * of combinations of atom, quoted-string, and | |
315 * specials tokens, or else consisting of texts> | |
316 ****************************************************************************/ | |
317 field_body_contents | |
318 -> CHAR... | |
319 | |
320 /*************************************************************************** | |
321 * field-name = 1*<any CHAR, excluding CTLs, SPACE, and ":"> | |
322 ****************************************************************************/ | |
323 field_name | |
324 -> (0x21..0x7E) - 0x3A | |
325 | |
326 | |
327 /*************************************************************************** | |
328 * group = phrase ":" [#mailbox] ";" | |
329 ****************************************************************************/ | |
330 group | |
331 -> "phrase", ':', multiple_mailboxes,';' | |
332 | |
333 | |
334 | |
335 /*************************************************************************** | |
336 * hour = 2DIGIT ":" 2DIGIT [":" 2DIGIT] | |
337 * ; 00:00:00 - 23:59:59 | |
338 ****************************************************************************/ | |
339 hour | |
340 -> DIGIT,DIGIT,':',DIGIT,DIGIT,[':',DIGIT,DIGIT] | |
341 | |
342 /*************************************************************************** | |
343 * HTAB = <ASCII HT, horizontal-tab> ; ( 11, 9.) | |
344 ****************************************************************************/ | |
345 HTAB = 0x09 | |
346 | |
347 /*************************************************************************** | |
348 * LF = <ASCII LF, linefeed> ; ( 12, 10.) | |
349 ****************************************************************************/ | |
350 LF = 0x0A | |
351 | |
352 /*************************************************************************** | |
353 * linear-white-space = 1*([CRLF] LWSP-char) ; semantics = SPACE | |
354 * ; CRLF => folding | |
355 ****************************************************************************/ | |
356 linear_white_space | |
357 -> {linear_space}... | |
358 | |
359 linear_space | |
360 -> CRLF,LWSP_char | |
361 -> LWSP_char | |
362 | |
363 /*************************************************************************** | |
364 * local-part = word *("." word) ; uninterpreted | |
365 * ; case-preserved | |
366 ****************************************************************************/ | |
367 local_part | |
368 -> word,SPACE,{'.',word}... | |
369 | |
370 | |
371 /*************************************************************************** | |
372 * LWSP-char = SPACE / HTAB ; semantics = SPACE | |
373 ****************************************************************************/ | |
374 LWSP_char = SPACE + HTAB | |
375 | |
376 | |
377 /*************************************************************************** | |
378 * mailbox = addr-spec ; simple address | |
379 * / phrase route-addr ; name & addr-spec | |
380 ****************************************************************************/ | |
381 mailbox | |
382 -> addr_spec | |
383 -> "phrase",SPACE,route_addr | |
384 | |
385 | |
386 /*************************************************************************** | |
387 * message = fields *( CRLF *text ) ; Everything after | |
388 * ; first null line | |
389 * ; is message body | |
390 ****************************************************************************/ | |
391 message | |
392 -> fields, {CRLF, text?}... | |
393 | |
394 | |
395 /*************************************************************************** | |
396 * month = "Jan" / "Feb" / "Mar" / "Apr" | |
397 * / "May" / "Jun" / "Jul" / "Aug" | |
398 * / "Sep" / "Oct" / "Nov" / "Dec" | |
399 ****************************************************************************/ | |
400 month | |
401 -> "Jan" | |
402 -> "Feb" | |
403 -> "Mar" | |
404 -> "Apr" | |
405 -> "May" | |
406 -> "Jun" | |
407 -> "Jul" | |
408 -> "Aug" | |
409 -> "Sep" | |
410 -> "Oct" | |
411 -> "Nov" | |
412 -> "Dec" | |
413 | |
414 | |
415 | |
416 | |
417 /*************************************************************************** | |
418 * msg-id = "<" addr-spec ">" ; Unique message id | |
419 ****************************************************************************/ | |
420 msg_id | |
421 -> '<',addr_spec,'>' | |
422 | |
423 | |
424 | |
425 /*************************************************************************** | |
426 * optional-field = | |
427 * / "Message-ID" ":" msg-id | |
428 * / "Resent-Message-ID" ":" msg-id | |
429 * / "In-Reply-To" ":" *(phrase / msg-id) | |
430 * / "References" ":" *(phrase / msg-id) | |
431 * / "Keywords" ":" #phrase | |
432 * / "Subject" ":" *text | |
433 * / "Comments" ":" *text | |
434 * / "Encrypted" ":" 1#2word | |
435 * / extension-field ; To be defined | |
436 * / user-defined-field ; May be pre-empted | |
437 ****************************************************************************/ | |
438 optional_field | |
439 -> optional_fields | |
440 | |
441 optional_fields | |
442 -> "Message-ID" , ':', msg_id | |
443 | |
444 | |
445 /*************************************************************************** | |
446 * orig-date = "Date" ":" date-time | |
447 ****************************************************************************/ | |
448 orig_date | |
449 -> "Date", ':', date_time | |
450 | |
451 | |
452 /*************************************************************************** | |
453 * originator = authentic ; authenticated addr | |
454 * [ "Reply-To" ":" 1#address] ) | |
455 ****************************************************************************/ | |
456 originator | |
457 -> authentic, ["Reply-To", ':', addresses] | |
458 | |
459 /*************************************************************************** | |
460 * phrase = 1*word ; Sequence of words | |
461 ****************************************************************************/ | |
462 phrase | |
463 -> word... | |
464 | |
465 | |
466 | |
467 /*************************************************************************** | |
468 * qtext = <any CHAR excepting <">, ; => may be folded | |
469 * "\" & CR, and including | |
470 * linear-white-space> | |
471 ****************************************************************************/ | |
472 qtext | |
473 -> CHAR - qtext_specials | |
474 -> linear_white_space | |
475 | |
476 //Added SPACE and HTAB to reduce an ambiguous grammer conflict | |
477 | |
478 qtext_specials = '"' + '\\' + CR + SPACE + HTAB | |
479 | |
480 | |
481 /*************************************************************************** | |
482 * quoted-pair = "\" CHAR ; may quote any char | |
483 ****************************************************************************/ | |
484 quoted_pair | |
485 -> '\\',CHAR | |
486 | |
487 /*************************************************************************** | |
488 * quoted-string = <"> *(qtext/quoted-pair) <">; Regular qtext or | |
489 * ; quoted chars. | |
490 ****************************************************************************/ | |
491 quoted_string | |
492 -> '"', QUOTED?...,'"' | |
493 | |
494 QUOTED | |
495 -> qtext | |
496 -> quoted_pair | |
497 | |
498 | |
499 | |
500 /*************************************************************************** | |
501 * received = "Received" ":" ; one per relay | |
502 * ["from" domain] ; sending host | |
503 * ["by" domain] ; receiving host | |
504 * ["via" atom] ; physical path | |
505 * *("with" atom) ; link/mail protocol | |
506 * ["id" msg-id] ; receiver msg id | |
507 * ["for" addr-spec] ; initial form | |
508 * ";" date-time ; time received | |
509 ****************************************************************************/ | |
510 received | |
511 -> "Received",':',received_fields..., ';',rec_date_time | |
512 | |
513 received_fields | |
514 -> from,from_domain | |
515 -> "by",by_domain | |
516 -> "via",via_atom | |
517 -> "with",with_atom | |
518 -> "id",rec_msg_id | |
519 -> "for",for_addr_spec | |
520 | |
521 | |
522 from | |
523 -> "from" | |
524 | |
525 from_domain | |
526 -> domain | |
527 | |
528 by_domain | |
529 -> domain | |
530 | |
531 via_atom | |
532 -> atom | |
533 | |
534 with_atom | |
535 -> atom | |
536 | |
537 rec_msg_id | |
538 ->msg_id | |
539 | |
540 for_addr_spec | |
541 -> addr_spec | |
542 | |
543 rec_date_time | |
544 -> date_time | |
545 | |
546 /*************************************************************************** | |
547 * resent = resent-authentic | |
548 * [ "Resent-Reply-To" ":" 1#address] ) | |
549 ****************************************************************************/ | |
550 resent | |
551 -> resent_authentic,["Resent-Reply-To", ':', addresses] | |
552 | |
553 | |
554 /*************************************************************************** | |
555 * resent-authentic = | |
556 * = "Resent-From" ":" mailbox | |
557 * / ( "Resent-Sender" ":" mailbox | |
558 * "Resent-From" ":" 1#mailbox ) | |
559 ****************************************************************************/ | |
560 resent_authentic | |
561 -> "Resent-Sender",':',mailbox | |
562 -> "Resent-From",':',multiple_mailboxes | |
563 | |
564 /*************************************************************************** | |
565 * resent-date = "Resent-Date" ":" date-time | |
566 ****************************************************************************/ | |
567 resent_date | |
568 -> "Resent-Date",':',date_time | |
569 | |
570 | |
571 /*************************************************************************** | |
572 * return = "Return-path" ":" route-addr ; return address | |
573 ****************************************************************************/ | |
574 return | |
575 -> "Return-path",':',route_addr | |
576 | |
577 /*************************************************************************** | |
578 * route = 1#("@" domain) ":" ; path-relative | |
579 ****************************************************************************/ | |
580 route | |
581 -> route_list,':' | |
582 | |
583 sub_route | |
584 -> '@',domain | |
585 | |
586 route_list | |
587 -> sub_route | |
588 -> route_list, sub_route | |
589 | |
590 | |
591 | |
592 /*************************************************************************** | |
593 * route-addr = "<" [route] addr-spec ">" | |
594 ****************************************************************************/ | |
595 route_addr | |
596 -> '<',[route],addr_spec, '>' | |
597 | |
598 | |
599 /*************************************************************************** | |
600 * source = [ trace ] ; net traversals | |
601 * originator ; original mail | |
602 * [ resent ] ; forwarded | |
603 ****************************************************************************/ | |
604 source | |
605 -> trace?,originator,resent? | |
606 | |
607 | |
608 /*************************************************************************** | |
609 * SPACE = <ASCII SP, space> ; ( 40, 32.) | |
610 ****************************************************************************/ | |
611 SPACE = 0x20 | |
612 | |
613 | |
614 /*************************************************************************** | |
615 * specials = "(" / ")" / "<" / ">" / "@" ; Must be in quoted- | |
616 * / "," / ";" / ":" / "\" / <"> ; string, to use | |
617 * / "." / "[" / "]" ; within a word. | |
618 ****************************************************************************/ | |
619 specials = '(' + ')' + '<' + '>' + '@' + ',' + ';' + ':' + '\\' + '"' + '.' + '[' + ']' | |
620 | |
621 | |
622 /*************************************************************************** | |
623 * sub-domain = domain-ref / domain-literal | |
624 ****************************************************************************/ | |
625 sub_domain | |
626 -> domain_ref | |
627 -> domain_literal | |
628 | |
629 /*************************************************************************** | |
630 * text = <any CHAR, including bare ; => atoms, specials, | |
631 * CR & bare LF, but NOT ; comments and | |
632 * including CRLF> ; quoted-strings are | |
633 * ; NOT recognized. | |
634 ****************************************************************************/ | |
635 text | |
636 -> text_char | |
637 | |
638 text_char | |
639 -> 0x00..0x7F | |
640 | |
641 | |
642 /*************************************************************************** | |
643 * time = hour zone ; ANSI and Military | |
644 ****************************************************************************/ | |
645 time | |
646 -> hour, SPACE, zone | |
647 | |
648 /*************************************************************************** | |
649 * trace = return ; path to sender | |
650 * 1*received ; receipt tags | |
651 ****************************************************************************/ | |
652 trace | |
653 -> return,SPACE,received... | |
654 | |
655 /*************************************************************************** | |
656 user-defined-field = | |
657 <Any field which has not been defined | |
658 in this specification or published as an | |
659 extension to this specification; names for | |
660 such fields must be unique and may be | |
661 pre-empted by published extensions> | |
662 ****************************************************************************/ | |
663 | |
664 | |
665 /*************************************************************************** | |
666 * word = atom / quoted-string | |
667 ****************************************************************************/ | |
668 word | |
669 -> atom | |
670 -> quoted_string | |
671 | |
672 | |
673 /*************************************************************************** | |
674 * zone = "UT" / "GMT" ; Universal Time | |
675 * ; North American : UT | |
676 * / "EST" / "EDT" ; Eastern: - 5/ - 4 | |
677 * / "CST" / "CDT" ; Central: - 6/ - 5 | |
678 * / "MST" / "MDT" ; Mountain: - 7/ - 6 | |
679 * / "PST" / "PDT" ; Pacific: - 8/ - 7 | |
680 * / 1ALPHA ; Military: Z = UT; | |
681 * <"> = <ASCII quote mark> ; ( 42, 34.) | |
682 ****************************************************************************/ | |
683 zone | |
684 -> "UT" | |
685 -> "GMT" | |
686 -> "EST" | |
687 -> "EDT" | |
688 -> "CST" | |
689 -> "CDT" | |
690 -> "MST" | |
691 -> "MDT" | |
692 -> "PST" | |
693 -> "PDT" | |
694 -> ALPHA | |
695 -> 0x22 | |
696 | |
697 |