Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

LaTeX.ebnf 5.52 KB
Newer Older
Eckhart Arnold's avatar
Eckhart Arnold committed
1
# LaTeX-Grammar for DHParser
Eckhart Arnold's avatar
Eckhart Arnold committed
2

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

7

Eckhart Arnold's avatar
Eckhart Arnold committed
8
9
10
11
12
latexdoc       = preamble document
preamble       = { command }+

document       = [PARSEP] "\begin{document}" [PARSEP]
                 frontpages [PARSEP]
13
14
                 (Chapters | Sections) [PARSEP]
                 [Bibliography] [Index] [PARSEP]
Eckhart Arnold's avatar
Eckhart Arnold committed
15
16
17
                 "\end{document}" [PARSEP] §EOF
frontpages     = sequence

Eckhart Arnold's avatar
Eckhart Arnold committed
18
19
20
21
22
23
24

#######################################################################
#
# document structure
#
#######################################################################

Eckhart Arnold's avatar
Eckhart Arnold committed
25
26
Chapters       = { Chapter [PARSEP] }+
Chapter        = "\Chapter" block [PARSEP] { sequence | Sections }
Eckhart Arnold's avatar
Eckhart Arnold committed
27

Eckhart Arnold's avatar
Eckhart Arnold committed
28
29
Sections       = { Section [PARSEP] }+
Section        = "\Section" block [PARSEP] { sequence | SubSections }
Eckhart Arnold's avatar
Eckhart Arnold committed
30

Eckhart Arnold's avatar
Eckhart Arnold committed
31
32
SubSections    = { SubSection [PARSEP] }+
SubSection     = "\SubSection" block [PARSEP] { sequence | SubSubSections }
Eckhart Arnold's avatar
Eckhart Arnold committed
33

34
SubSubSections = { SubSubSection [PARSEP] }+
Eckhart Arnold's avatar
Eckhart Arnold committed
35
36
SubSubSection  = "\SubSubSection" block [PARSEP] { sequence | Paragraphs }

Eckhart Arnold's avatar
Eckhart Arnold committed
37
38
Paragraphs     = { Paragraph [PARSEP] }+
Paragraph      = "\paragraph" block [PARSEP] { sequence | SubParagraphs }
Eckhart Arnold's avatar
Eckhart Arnold committed
39

Eckhart Arnold's avatar
Eckhart Arnold committed
40
41
SubParagraphs  = { SubParagraph [PARSEP] }+
SubParagraph   = "\subparagpaph" block [PARSEP] { sequence }
Eckhart Arnold's avatar
Eckhart Arnold committed
42

43
44
Bibliography   = "\bibliography" block [PARSEP]
Index          = "\printindex" [PARSEP]
Eckhart Arnold's avatar
Eckhart Arnold committed
45
46
47
48
49
50
51


#######################################################################
#
# document content
#
#######################################################################
52

Eckhart Arnold's avatar
Eckhart Arnold committed
53

Eckhart Arnold's avatar
Eckhart Arnold committed
54
55
#### block environments ####

56
block_environment   = known_environment | generic_block
57
known_environment   = itemize | enumerate | figure | table | quotation
58
                    | verbatim
59
generic_block       = begin_generic_block sequence §end_generic_block
60
61
begin_generic_block = -&LB begin_environment -&LB
end_generic_block   = -&LB  end_environment  -&LB
Eckhart Arnold's avatar
Eckhart Arnold committed
62
63

itemize             = "\begin{itemize}" [PARSEP] { item } §"\end{itemize}"
64
enumerate           = "\begin{enumerate}" [PARSEP] {item } §"\end{enumerate}"
Eckhart Arnold's avatar
Eckhart Arnold committed
65
66
item                = "\item" [PARSEP] sequence

67
68
69
70
71
72
73
figure              = "\begin{figure}" sequence "\end{figure}"
quotation           = ("\begin{quotation}" sequence "\end{quotation}")
                    | ("\begin{quote}" sequence "\end{quote}")
verbatim            = "\begin{verbatim}" sequence "\end{verbatim}"
table               = "\begin{tabular}" table_config sequence "\end{tabular}"
table_config        = "{" /[lcr|]+/~ "}"

Eckhart Arnold's avatar
Eckhart Arnold committed
74
75
76
77

#### paragraphs and sequences of paragraphs ####

block_of_paragraphs = /{/ sequence §/}/
78
sequence            = { (paragraph | block_environment ) [PARSEP] }+
Eckhart Arnold's avatar
Eckhart Arnold committed
79

80
81
paragraph           = { !blockcmd text_element //~ }+
text_element       = command | text | block | inline_environment
Eckhart Arnold's avatar
Eckhart Arnold committed
82
83
84
85


#### inline enivronments ####

86
inline_environment  = known_inline_env | generic_inline_env
Eckhart Arnold's avatar
Eckhart Arnold committed
87
known_inline_env    = inline_math
88
generic_inline_env  = (begin_inline_env { text_element }+ §end_inline_env)
Eckhart Arnold's avatar
Eckhart Arnold committed
89
begin_inline_env    = (-!LB begin_environment) | (begin_environment -!LB)
90
91
end_inline_env      = end_environment
                      # (-!LB end_environment)   | (end_environment   -!LB)  # ambiguity with genric_block when EOF
92
93
begin_environment   = "\begin{" §NAME §"}"
end_environment     = "\end{" §::NAME §"}"
Eckhart Arnold's avatar
Eckhart Arnold committed
94

Eckhart Arnold's avatar
Eckhart Arnold committed
95
inline_math         = "$" /[^$]*/ "$"
Eckhart Arnold's avatar
Eckhart Arnold committed
96
97
98


#### commands ####
Eckhart Arnold's avatar
Eckhart Arnold committed
99

100
command             = known_command | generic_command
Eckhart Arnold's avatar
Eckhart Arnold committed
101
known_command       = footnote | includegraphics | caption
Eckhart Arnold's avatar
Eckhart Arnold committed
102
generic_command     = !no_command CMDNAME [[ //~ config ] //~ block ]
Eckhart Arnold's avatar
Eckhart Arnold committed
103

Eckhart Arnold's avatar
Eckhart Arnold committed
104
footnote            = "\footnote" block_of_paragraphs
105
includegraphics     = "\includegraphics" [ config ] block
Eckhart Arnold's avatar
Eckhart Arnold committed
106
caption             = "\caption" block
Eckhart Arnold's avatar
Eckhart Arnold committed
107

108

Eckhart Arnold's avatar
Eckhart Arnold committed
109
110
111
112
113
#######################################################################
#
# low-level text and character sequences
#
#######################################################################
114

115

116
config     = "[" cfgtext §"]"
117
block      = /{/ { text_element } §/}/
Eckhart Arnold's avatar
Eckhart Arnold committed
118

119
120
121
text       = { cfgtext | (BRACKETS //~) }+
cfgtext    = { word_sequence | (ESCAPED //~) }+
word_sequence = { TEXTCHUNK //~ }+
122

Eckhart Arnold's avatar
Eckhart Arnold committed
123
124
125
126
127
no_command = "\begin{" | "\end" | BACKSLASH structural
blockcmd   = BACKSLASH ( ( "begin{" | "end{" )
                         ( "enumerate" | "itemize" | "figure" | "quote"
                         | "quotation" | "tabular") "}"
                       | structural | begin_generic_block | end_generic_block )
128
129
130

structural = "subsection" | "section" | "chapter" | "subsubsection"
           | "paragraph" | "subparagraph" | "item"
131

Eckhart Arnold's avatar
Eckhart Arnold committed
132
133
134
135
136
137
138

#######################################################################
#
# Primitives
#
#######################################################################

139

140
CMDNAME    = /\\(?:(?!_)\w)+/~
141
NAME       = /\w+/~
Eckhart Arnold's avatar
Eckhart Arnold committed
142

143
ESCAPED    = /\\[%$&_\/]/
144
145
146
BRACKETS   = /[\[\]]/                       # left or right square bracket: [ ]
TEXTCHUNK  = /[^\\%$&\{\}\[\]\s\n]+/        # some piece of text excluding whitespace,
                                            # linefeed and special characters
Eckhart Arnold's avatar
Eckhart Arnold committed
147
148
149
LF         = !GAP /[ \t]*\n[ \t]*/          # linefeed but not an empty line
PARSEP     = { GAP }+                       # paragraph separator
GAP        = /[ \t]*(?:\n[ \t]*)+\n/~       # at least one empty line, i.e.
150
                                            # [whitespace] linefeed [whitespace] linefeed
151
LB         = /\s*?\n|$/                     # backwards line break for Lookbehind-Operator
Eckhart Arnold's avatar
Eckhart Arnold committed
152
153
154
155
                                            # beginning of text marker '$' added for test code
BACKSLASH  = /[\\]/

EOF        = /(?!.)/                        # End-Of-File