-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtree-sitter-menhir.ebnf
171 lines (129 loc) · 3.17 KB
/
tree-sitter-menhir.ebnf
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
//
// From tree-sitter-menhir/src/grammar.json
//
//
// EBNF to generate railroad diagram at
// (IPV6) https://www.bottlecaps.de/rr/ui
// (IPV4) https://rr.red-dove.com/ui
//
source_file ::=
declaration* '%%' rule* ( '%%' postlude? )?
_high_prec_bar ::=
'|'
_low_prec_bar ::=
'|'
lid ::=
[a-zß-öø-ÿ_][a-zA-Z_À-ÖØ-öø-ÿ0-9]*
uid ::=
[A-ZÀ-ÖØ-Þ][a-zA-Z_À-ÖØ-öø-ÿ0-9]*
qid ::=
'"'[\x23-\x5b\x5d-\x7e\x20\x21]+'"'
symbol ::=
lid
| uid
| qid
declaration ::=
header
| '%parameter' type
| '%token' type? terminal_alias_attrs ( ','? terminal_alias_attrs )*
| priority_keyword symbol ( ','? symbol )*
| '%type' type strict_actual ( ','? strict_actual )*
| '%start' type? non_terminal ( ','? non_terminal )*
| '%attribute' strict_actual ( ','? strict_actual )* attribute+
| grammar_attribute
| '%on_error_reduce' strict_actual ( ','? strict_actual )*
| ';'
terminal_alias_attrs ::=
uid qid? attribute*
priority_keyword ::=
'%left'
| '%right'
| '%nonassoc'
non_terminal ::=
lid
rule ::=
old_rule
| new_rule
old_rule ::=
flags? symbol attribute* ( '(' symbol ( ',' symbol )* ')' )? ':' _low_prec_bar? production_group ( _high_prec_bar production_group )* ';'*
flags ::=
'%public'
| '%inline'
| '%public' '%inline'
| '%inline' '%public'
production_group ::=
producer* precedence? ( _high_prec_bar producer* precedence? )* ( action | type ) precedence?
precedence ::=
'%prec' symbol
producer ::=
( lid '=' )? actual attribute* ';'*
strict_actual ::=
symbol
| symbol '(' strict_actual ( ',' strict_actual )* ')'
| strict_actual modifier
actual ::=
symbol
| symbol '(' lax_actual ( ',' lax_actual )* ')'
| actual modifier
lax_actual ::=
symbol
| symbol '(' lax_actual ( ',' lax_actual )* ')'
| actual modifier
| production_group ( _high_prec_bar production_group )*
modifier ::=
'?'
| '*'
| '+'
new_rule ::=
'%public'? 'let' lid attribute* ( '(' symbol ( ',' symbol )* ')' )? equality_symbol expression
equality_symbol ::=
'=='
| ':='
expression ::=
'|'? seq_expression ( '|' seq_expression )*
seq_expression ::=
symbol_expression continuation
| pattern '=' symbol_expression continuation
| symbol_expression
| action_expression
continuation ::=
';' seq_expression
symbol_expression ::=
symbol attribute*
| symbol '(' expression ( ',' expression )* ')' attribute*
| symbol_expression modifier attribute*
action_expression ::=
menhir_action
| precedence menhir_action
| menhir_action precedence
menhir_action ::=
action
| type
pattern ::=
lid
| '_'
| '~'
| '(' ')'
| '(' pattern ( ',' pattern )* ')'
line_comment ::=
'\/\/.'*
comment ::=
( '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' )
header ::=
'%{' ocaml? '%}'
action ::=
'{' ocaml? '}'
attribute ::=
'[@' ocaml? ']'
grammar_attribute ::=
'%[@' ocaml? ']'
type ::=
'<' ocaml_type? '>'
postlude ::=
ocaml
ocaml ::=
_ocaml
_ocaml ::=
( '{' _ocaml? '}' | '[' _ocaml? ']' | '"'([^"\]|'\x00'|'\'('.'|'#x0A'))*'"' | "'"([^'\]|"\x00"|"\"[\"'ntbr ]|"\"[0-9][0-9][0-9]|"\x"[0-9A-Fa-f][0-9A-Fa-f]|"\o"[0-3][0-7][0-7])"'" | "'"?[A-Za-z_][a-zA-Z0-9_']* | [^{}#x5B#x5D"'%(A-Za-z_]+ | '%' | '(' )+
ocaml_type ::=
'->'?|'#x5B>'?|[^-#x5B>]++