forked from FamilySearch/GEDCOM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.abnf
143 lines (91 loc) · 3.7 KB
/
grammar.abnf
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
; This document is in ABNF, see <https://tools.ietf.org/html/std68>
; This document uses RFC 7405 to add case-sensitive literals to ABNF.
; ------------- Characters -------------
banned = %x00-08 / %x0B-0C / %x0E-1F ; C0 other than LF CR and Tab
/ %x7F ; DEL
/ %x80-9F ; C1
/ %xD800-DFFF ; Surrogates
/ %xFFFE-FFFF ; invalid
; All other rules assume the absence of any banned characters
digit = %x30-39 ; 0 through 9
nonzero = %x31-39 ; 1 through 9
ucletter = %x41-5A ; A through Z
underscore = %x5F ; _
atsign = %x40 ; @
; ------------- Lines -------------
Line = Level D [Xref D] Tag [D LineVal] EOL
Level = "0" / nonzero *digit
D = %x20 ; space
Xref = atsign 1*tagchar atsign ; but not "@VOID@"
Tag = stdTag / extTag
LineVal = pointer / lineStr
EOL = %x0D [%x0A] / %x0A ; CR-LF, CR, or LF
stdTag = ucletter *tagchar
extTag = underscore 1*tagchar
tagchar = ucletter / digit / underscore
pointer = voidPtr / Xref
voidPtr = %s"@VOID@"
nonAt = %x09 / %x20-3F / %x41-10FFFF ; non-EOL, non-@
nonEOL = %x09 / %x20-10FFFF ; non-EOL
lineStr = (nonAt / atsign atsign) *nonEOL ; leading @ doubled
; ------------- Text -------------
anychar = %x09-10FFFF ; but not banned, as with all ABNF rules
Text = *anychar
; ------------- Integer -------------
Integer = 1*digit
; ------------- Enumeration -------------
stdEnum = stdTag / Integer
Enum = stdEnum / extTag
; ------------- Date -------------
DateValue = [ date / DatePeriod / dateRange / dateApprox ]
DateExact = day D month D year ; in Gregorian calendar
DatePeriod = [ %s"TO" D date ]
/ %s"FROM" D date [ D %s"TO" D date ]
; note both DateValue and DatePeriod can be the empty string
date = [calendar D] [[day D] month D] year [D epoch]
dateRange = %s"BET" D date D %s"AND" D date
/ %s"AFT" D date
/ %s"BEF" D date
dateApprox = (%s"ABT" / %s"CAL" / %s"EST") D date
dateRestrict = %s"FROM" / %s"TO" / %s"BET" / %s"AND" / %s"BEF"
/ %s"AFT" / %s"ABT" / %s"CAL" / %s"EST"
calendar = %s"GREGORIAN" / %s"JULIAN" / %s"FRENCH_R" / %s"HEBREW"
/ extTag
day = Integer
year = Integer
month = stdTag / extTag ; constrained by calendar
epoch = %s"BCE" / extTag ; constrained by calendar
; ------------- Time -------------
Time = hour ":" minute [":" second ["." fraction]] [%s"Z"]
hour = digit / ("0" / "1") digit / "2" ("0" / "1" / "2" / "3")
minute = ("0" / "1" / "2" / "3" / "4" / "5") digit
second = ("0" / "1" / "2" / "3" / "4" / "5") digit
fraction = 1*digit
; ------------- Age -------------
Age = [ageBound D] ageDuration
ageBound = "<" / ">"
ageDuration = years [D months] [D weeks] [D days]
/ months [D weeks] [D days]
/ weeks [D days]
/ days
years = Integer %x79 ; 35y
months = Integer %x6D ; 11m
weeks = Integer %x77 ; 8w
days = Integer %x64 ; 21d
; ------------- List -------------
list = listItem *(listDelim listItem)
listItem = [ nocommasp / nocommasp *nocomma nocommasp ]
listDelim = *D "," *D
nocomma = %x09-2B / %x2D-10FFFF
nocommasp = %x09-1D / %x21-2B / %x2D-10FFFF
List-Text = list
List-Enum = Enum *(listDelim Enum)
; ------------- Personal Name -------------
PersonalName = nameStr
/ [nameStr] "/" [nameStr] "/" [nameStr]
nameChar = %x20-2E / %x30-10FFFF ; any but '/' and '\t'
nameStr = 1*nameChar
; ------------- Media Type -------------
MediaType = type "/" subtype parameters
; ------------- Special -------------
Special = Text