-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatex_grammar.treetop
More file actions
59 lines (44 loc) · 952 Bytes
/
latex_grammar.treetop
File metadata and controls
59 lines (44 loc) · 952 Bytes
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
grammar Latex
rule document
token+ <Document>
end
rule token
verbatim / command / text
end
rule command
'\\' operation '[' options ']' '{' parameters '}' <Command> / command_no_parameters / command_no_options / command_simple
end
rule command_no_parameters
'\\' operation '[' options ']' <Command>
end
rule command_no_options
'\\' operation '{' parameters '}' <Command>
end
rule command_simple
'\\' operation '{}' <Command> / '\\' operation <Command>
end
rule operation
plain_text
end
rule parameters
parameter ',' parameters <Parameters> / parameter <Parameter>
end
rule parameter
command / plain_text
end
rule options
parameters
end
rule plain_text
[^\\^\{^\}^\,^\[^\]]+ <Text>
end
rule verbatim
'\\begin{lstlisting}' ('[' [^\]]* ']')? verbatim_text '\\end{lstlisting}' <Verbatim>
end
rule verbatim_text
(!'\\end{lstlisting}' [\w\W])* <Text>
end
rule text
[^\\]+ <Text>
end
end