BibTeX.ebnf 568 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# BibTeX-Grammar

@ testing     = True
@ whitespace  = /\s*/
@ ignorecase  = True
@ comment     = /%.*(?:\n|$)/

bibliography = { preamble | comment | entry }

preamble      = "@Preamble{" /"/ PREAMBLE /"/~ §"}"
comment       = "@Comment{" COMMENT §"}"
entry         = /@/ entry_type "{" KEY { "," NAME §"=" field_content } §"}"

field_content = /\{/ content §"}" | PLAIN_CONTENT
content       = { /(?:\\.|[^\\{}])*/ ( /\{/ content /\}/ ) }

PREAMBLE      = /[^"]*/
COMMENT       = /[^}]*/
KEY           = /[^,}]*/~
NAME          = /\w+/~
PLAIN_CONTENT = /[^,}]*/