blob: 0a339fc6244b0db444320f9478e05389880705f7 (
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
|
# A grammar file for reading BNF notation
# FIXME: Too many errors!
[space]: %x20\t
[id]: a-zA-Z\-_+*@
[rule_name_char]: ^[]:%x20\n
[notnewline]: ^\n\r
[class_range_char]: ^\n\r\^\\
[class_single_char]: ^\n\r\^\\\-
[any]:
[double_string_char]: ^"\n
[single_string_char]: ^'\n
--
BNF: "#" notnewlines empty BNF
BNF: predicate_section "--\n" empty rules_section
BNF: rules_section
BNF:
spaces: [space] spaces
spaces: [space]
optional_spaces: [space] optional_spaces
optional_spaces:
empty: [space] empty
empty: "\n" empty
empty: "\r" empty
empty: "\n#" notnewlines
empty:
notnewlines: [notnewline] notnewlines
notnewlines:
predicate_section: predicate empty "\n" predicate_section
predicate_section:
predicate: "[" ids "]:" optional_spaces class
ids: [id] ids
ids: [id]
# Yes, a class specification can be empty, in which case the predicate
# matches everything.
class: positive_class
class: "^" positive_class
positive_class: positive_specification positive_class
positive_class:
positive_specification: class_single_chars
positive_specification: class_range_chars "-" class_range_chars
class_single_chars: [class_single_char]
class_single_chars: "\\" [any]
class_range_chars: [class_range_char]
class_range_chars: "\\" [any]
rules_section: rule empty "\n" rules_section
rules_section:
rule: rule_name optional_spaces ":" optional_spaces rule_rhs
rule_name: [rule_name_char] rule_name
rule_name:
spaces_or_escaped_newline: optional_spaces
spaces_or_escaped_newline: "\\\n"
rule_rhs: ids spaces_or_escaped_newline rule_rhs
rule_rhs: '[' ids ']' spaces_or_escaped_newline rule_rhs
rule_rhs: '"' double_string_chars '"' spaces_or_escaped_newline rule_rhs
rule_rhs: "'" single_string_chars "'" spaces_or_escaped_newline rule_rhs
rule_rhs:
double_string_chars: [double_string_char]
double_string_chars: "\\" [any]
double_string_chars: [double_string_char] double_string_char
double_string_chars: "\\" [any] double_string_chars
single_string_chars: [single_string_char]
single_string_chars: "\\" [any]
single_string_chars: [single_string_char] single_string_char
single_string_chars: "\\" [any] single_string_chars
|