summaryrefslogtreecommitdiff
path: root/meta/grammar.html
blob: 074c4a142625636d2d712c4566acbeb23fd1d086 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/fonts/fonts.css">
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
<link rel="manifest" href="/favicon/site.webmanifest">
<style>
:root 	{font-size: 15px;}
body 	{background-color: #111; margin: 2rem;}
pre 	{color: #ddd; font-family: jetbrains-mono-regular, Consolas, Menlo, monospace; font-style: normal; font-size: 1rem; line-height: 1.5em; white-space: pre-wrap;}
pre a	{color: #ddd;}
pre a:link	{text-decoration: none; color: #ddd;}
pre a:visited	{text-decoration: none; color: #ddd;}
pre a:hover	{text-decoration: none; color: #111; background-color: #ddd;}
pre a:active	{text-decoration: none; color: #ddd;}
</style>
<title></title>
<meta http-equiv="last-modified" content="2021-11-16 12:20:05-05:00" />
</head>

<body>
<pre>
grammar		: rule (rule-separator rule)*

rule		: non-terminal separator ':' separator expression

rule-separator	: \x0A \x0A+

separator	: (\x09 | \x20)+
		| \x0A (\x09 | \x20)*

non-terminal	: ([A-Z] | [a-z] | [-_]) ([0-9] | [A-Z] | [a-z] | [-_])*

expression	: layer-0
		| layer-1
		| layer-2

layer-0		: terminal
		| non-terminal

layer-1		: optional
		| repetition
		| free-monoid

layer-2		: alternation
		| concatenation
		| exception

terminal	: string
		| hex-literal
		| character-set
		| extension

optional	: layer-0 '?'
		| '(' (layer-1 | layer-2) ')' '?'

repetition	: layer-0 '+'
		| '(' (layer-1 | layer-2) ')' '+'

free-monoid	: layer-0 '*'
		| '(' (layer-1 | layer-2) ')' '*'

alternation	: alt-operand separator '|' separator alt-operand

concatenation	: con-operand ' ' con-operand

exception	: exc-operand ' - ' exc-operand

alt-operand	: layer-0
		| layer-1
		| '(' layer-2 ')'
		| alternation
		| concatenation

con-operand	: layer-0
		| layer-1
		| '(' layer-2 ')'
		| concatenation

exc-operand	: layer-0
		| layer-1
		| '(' layer-2 ')'

string		: "'" (anything - "'")* "'"
		| '"' (anything - '"')* '"'

hex-literal	: '\x' ([0-9] | [A-F])+

character-set	: '[' (character-list | character-range | extension) ']'

character-list	: anything+
		| hex-literal+

character-range	: anything '-' anything
		| hex-literal '-' hex-literal

extension	: '<' anything+ '>'

anything	: [&lt;all valid UTF-8 characters&gt;]
</pre>
</body>
</html>