2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

LaTeX.ebnf 1.21 KB
Newer Older
Eckhart Arnold's avatar
Eckhart Arnold committed
1
2
# latex Grammar

3
@ whitespace = /[ \t]*\n?(?!\s*\n)[ \t]*/  # whitespace, including at most one linefeed
4
@ comment    = /%.*(?:\n|$)/
Eckhart Arnold's avatar
Eckhart Arnold committed
5

6
7
8
9
latexdoc   = preamble document
preamble   = { command }+

genericenv = beginenv sequence §endenv
10
11
beginenv   = "\begin" §( "{" name "}" )
endenv     = "\end" §( "{" ::name "}" )
Eckhart Arnold's avatar
Eckhart Arnold committed
12

13
name       = /\w+/~
Eckhart Arnold's avatar
Eckhart Arnold committed
14

15
16
comand     = cmdname [ config ] block
cmdname    = /\\\w+/
17
config     = "[" cfgtext §"]"
Eckhart Arnold's avatar
Eckhart Arnold committed
18

19
sequence   = { partext | parblock }
Eckhart Arnold's avatar
Eckhart Arnold committed
20

21
22
parblock   = "{" { partext | parblock } §"}"
block      = "{" { text | block } §"}"
Eckhart Arnold's avatar
Eckhart Arnold committed
23

24
partext    = text | PARSEP
25
text       = cfgtext | brackets
26
cfgtext    = chunk | escaped | WSPC
Eckhart Arnold's avatar
Eckhart Arnold committed
27

Eckhart Arnold's avatar
Eckhart Arnold committed
28
29
30
ESCAPED    = /\\[%$&]/
BRACKET    = /[\[\]]/                   # left or right square bracket: [ ]
TEXTCHUNK  = /[^\\%$&\{\}\[\]\s\n]+/    # some piece of text excluding whitespace,
31
                                        # linefeed and special characters
32
33
34
WSPC       = /[ \t]*\n?(?!\s*\n)[ \t]*/ # whitespace, including at most one linefeed
LF         = /[ \t]*\n(?!\s*\n)/        # a linefeed, but not an empty line (i.e. par)
PARSEP     = /\s*\n\s*\n/               # at least one empty line, i.e.
35
                                        # [whitespace] linefeed [whitespace] linefeed
Eckhart Arnold's avatar
Eckhart Arnold committed
36