summaryrefslogtreecommitdiff
path: root/src/bnf.bnf
blob: df8ef3c883721b5e88e488a8bc0b99bfc3bd3a49 (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
# A grammar file for reading BNF notation

[id]: a-zA-Z-_+*@

[notbracket]: ^[]

[notnewline]: ^\n\r

--

BNF: predicate_section "--\n" rules_section
BNF: rules_section
BNF:

spaces: space spaces
spaces: space

space: " "
space: "\t"

empty: spaces empty
empty: "\n" empty "\n"
empty: "\r" empty "\n"
empty: "#" notnewlines "\n"
empty:

notnewlines: [notnewline] notnewlines
notnewlines:

predicate_section: predicate empty "\n" predicate_section
predicate_section:

predicate: "[" ids "]:" spaces class

ids: [id] ids
ids:

# Yes, a class specification can be empty, in which case the predicate
# is equivalent with the default "any" predicate.

class: positive_class
class: "^" positive_class

positive_class: positive_specification positive_class
positive_class:

positive_specification: enotnewline
positive_specification: enotnewline "-" enotnewline

# Extended not-newline, or escaped not-newline
enotnewline: [notnewline]
enotnewline: "\\" [any]

rules_section: rule empty "\n" rules_section

rule: rule_name ":" spaces rule_rhs
rule: rule_name ":" rule_rhs

rule_name: [notbracket] rule_name
rule_name:

spaces-or-escaped-newline: spaces
spaces-or-escaped-newline: "\\\n"

rule_rhs: ids spaces-or-escaped-newline rule_rhs
rule_rhs: