summaryrefslogtreecommitdiff
path: root/test/mailbox.lm
blob: df45a65a8ddd001355be8c63be40131a8eada8d4 (plain)
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

# lines, and fromlines 
lex
	rl day /[A-Z][a-z][a-z]/
	rl month /[A-Z][a-z][a-z]/
	rl year /[0-9][0-9][0-9][0-9]/
	rl time /[0-9][0-9] ':' [0-9][0-9]  ( ':' [0-9][0-9] )? /
	rl letterZone /[A-Z][A-Z][A-Z]/
	rl numZone /[+\-][0-9][0-9][0-9][0-9]/
	rl zone / letterZone | numZone/
	rl dayNum /[0-9 ][0-9]/

	# These are the different formats of the date minus an obscure
	# type that has a funny string 'remote from xxx' on the end. Taken
	# from c-client in the imap-2000 distribution.
	rl date / day ' ' month ' ' dayNum ' ' time ' '
		( year | year ' ' zone | zone ' ' year ) /

	# From lines separate messages. We will exclude from_line from a message
	# body line.  This will cause us to stay in message line up until an
	# entirely correct from line is matched.
	token from_line / 'From ' (any-'\n')* ' ' date '\n' /
	token simple_line / [^\n]* '\n' /
end

rl hchar /print - [ :]/
token header_name /hchar+/

token colon /':' ' '*/
token header_content / ([^\n] | '\n' [ \t])* '\n'/
token blank_line / '\n' /

def header 
	[header_name colon header_content]

def message 
	[from_line header* blank_line simple_line*]

def start 
	[message*]

parse S: start[ stdin ]
print_xml( S.tree )