BibTeX.ebnf 1.22 KB
Newer Older
1
2
# BibTeX-Grammar

3

4
5
6
7
8
9
#######################################################################
#
#  EBNF-Directives
#
######################################################################

10
11
@ whitespace  = /\s*/
@ ignorecase  = True
12
@ comment     = //
13

14
15
16
17
18
19
20

#######################################################################
#
#  Bib-file Structure and Components
#
#######################################################################

21
22
bibliography = { preamble | comment | entry }

Eckhart Arnold's avatar
Eckhart Arnold committed
23
24
preamble      = "@Preamble{" /"/ pre_code /"/~ §"}"
pre_code      = { /[^"%]+/ | /%.*\n/ }
25

Eckhart Arnold's avatar
Eckhart Arnold committed
26
comment       = "@Comment{" text §"}"
27

28
entry         = /@/ type "{" key { "," field §"=" content } [","] §"}"
29
30
type          = WORD
key           = NO_BLANK_STRING
31
field         = WORD
Eckhart Arnold's avatar
Eckhart Arnold committed
32
33
content       = "{" text "}" | plain_content

34
plain_content = COMMA_TERMINATED_STRING
35
text          = { CONTENT_STRING | "{" text "}" }
36
37
38
39
40
41
42
43


#######################################################################
#
#  Regular Expressions
#
#######################################################################

44
WORD          = /\w+/~
45
46
NO_BLANK_STRING         = /[^ \t\n,%]+/~
COMMA_TERMINATED_STRING = { /[^,%]+/ | /(?=%)/~ }
47
CONTENT_STRING = { /[^{}%]+/ | /(?=%)/~ }+
48
49

EOF           =  !/./