occam-grammars 1.0.677 → 1.0.680
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example.js +2 -2
- package/lib/florence/bnf.js +2 -2
- package/package.json +1 -1
- package/src/florence/bnf.js +165 -165
package/src/florence/bnf.js
CHANGED
|
@@ -1,388 +1,388 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const bnf = `document ::=
|
|
3
|
+
const bnf = `document ::= ( topLevelDeclaration | verticalSpace | error )+ ;
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
topLevelDeclaration ::=
|
|
7
|
+
topLevelDeclaration ::= typeDeclaration
|
|
8
8
|
|
|
9
|
-
|
|
|
9
|
+
| variableDeclaration
|
|
10
10
|
|
|
11
|
-
|
|
|
11
|
+
| combinatorDeclaration
|
|
12
12
|
|
|
13
|
-
|
|
|
13
|
+
| constructorDeclaration
|
|
14
14
|
|
|
15
|
-
|
|
|
15
|
+
| disjointTypeDeclaration
|
|
16
16
|
|
|
17
|
-
|
|
|
17
|
+
| metavariableDeclaration
|
|
18
18
|
|
|
19
|
-
|
|
|
19
|
+
| dependentTypeDeclaration
|
|
20
20
|
|
|
21
|
-
|
|
|
21
|
+
| rule
|
|
22
22
|
|
|
23
|
-
|
|
|
23
|
+
| axiom
|
|
24
24
|
|
|
25
|
-
|
|
|
25
|
+
| lemma
|
|
26
26
|
|
|
27
|
-
|
|
|
27
|
+
| theorem
|
|
28
28
|
|
|
29
|
-
|
|
|
29
|
+
| conjecture
|
|
30
30
|
|
|
31
|
-
|
|
|
31
|
+
| metalemma
|
|
32
32
|
|
|
33
|
-
|
|
|
33
|
+
| metatheorem
|
|
34
34
|
|
|
35
35
|
;
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
verticalSpace ::=
|
|
39
|
+
verticalSpace ::= <END_OF_LINE>+ ;
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
error. ::=
|
|
43
|
+
error. ::= . ;
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
typeDeclaration ::=
|
|
47
|
+
typeDeclaration ::= "Type" type ( ":" type )? <END_OF_LINE> ;
|
|
48
48
|
|
|
49
|
-
variableDeclaration ::=
|
|
49
|
+
variableDeclaration ::= "Variable" variable ( ":" type )? <END_OF_LINE> ;
|
|
50
50
|
|
|
51
|
-
combinatorDeclaration ::=
|
|
51
|
+
combinatorDeclaration ::= "Combinator" statement... <END_OF_LINE> ;
|
|
52
52
|
|
|
53
|
-
constructorDeclaration ::=
|
|
53
|
+
constructorDeclaration ::= "Constructor" term... ( ":" type )? <END_OF_LINE> ;
|
|
54
54
|
|
|
55
|
-
disjointTypeDeclaration ::=
|
|
55
|
+
disjointTypeDeclaration ::= "DisjointType" disjointType ":" type ( "," type )+ <END_OF_LINE> ;
|
|
56
56
|
|
|
57
|
-
metavariableDeclaration ::=
|
|
57
|
+
metavariableDeclaration ::= "Metavariable" metavariable ":" metaType <END_OF_LINE> ;
|
|
58
58
|
|
|
59
|
-
dependentTypeDeclaration ::=
|
|
59
|
+
dependentTypeDeclaration ::= "DependentType" dependentType ":" type <END_OF_LINE> ;
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
|
|
63
|
-
rule ::=
|
|
63
|
+
rule ::= "Rule" parenthesisedLabels <END_OF_LINE>
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
(
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
( "Premises" <END_OF_LINE> premise premise+ )
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
|
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
( "Premise" <END_OF_LINE> premise )
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
)?
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
"Conclusion" <END_OF_LINE> conclusion
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
ruleProof? ;
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
ruleProof ::=
|
|
81
|
+
ruleProof ::= "Proof" <END_OF_LINE> ruleDerivation ;
|
|
82
82
|
|
|
83
|
-
ruleSubproof ::=
|
|
83
|
+
ruleSubproof ::= (
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
( "Premises" <END_OF_LINE> premise premise+ )
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
|
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
( "Premise" <END_OF_LINE> premise )
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
)
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
ruleSubDerivation ;
|
|
94
94
|
|
|
95
|
-
ruleDerivation ::=
|
|
95
|
+
ruleDerivation ::= (
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
( ruleSubproof | qualifiedMetastatement | unqualifiedMetastatement )+
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
"Therefore" <END_OF_LINE>
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
)?
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
( qualifiedMetastatement | unqualifiedMetastatement ) ;
|
|
104
104
|
|
|
105
|
-
ruleSubDerivation ::=
|
|
105
|
+
ruleSubDerivation ::= (
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
"Hence" <END_OF_LINE>
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
( ruleSubproof | qualifiedMetastatement | unqualifiedMetastatement )+
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
)?
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
"Then" <END_OF_LINE>
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
( qualifiedMetastatement | unqualifiedMetastatement ) ;
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
|
|
119
|
-
metalemma ::=
|
|
119
|
+
metalemma ::= "Metalemma" parenthesisedLabels? <END_OF_LINE>
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
(
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
(
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
"Suppose" <END_OF_LINE> metaSupposition+
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
"Then" <END_OF_LINE> metaConsequent
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
)
|
|
130
130
|
|
|
131
|
-
|
|
131
|
+
|
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
metaConsequent
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
)
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
metaproof ;
|
|
138
138
|
|
|
139
|
-
metatheorem ::=
|
|
139
|
+
metatheorem ::= "Metatheorem" parenthesisedLabels <END_OF_LINE>
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
(
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
(
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
"Suppose" <END_OF_LINE> metaSupposition+
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
"Then" <END_OF_LINE> metaConsequent
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
)
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
|
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
metaConsequent
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
)
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
metaproof ;
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
metaproof ::=
|
|
161
|
+
metaproof ::= "Proof" <END_OF_LINE> metaDerivation ;
|
|
162
162
|
|
|
163
|
-
metaSubproof ::=
|
|
163
|
+
metaSubproof ::= "Suppose" <END_OF_LINE> metaSupposition+ metaSubDerivation ;
|
|
164
164
|
|
|
165
|
-
metaDerivation ::=
|
|
165
|
+
metaDerivation ::= (
|
|
166
166
|
|
|
167
|
-
|
|
167
|
+
( metaSubproof | qualifiedMetastatement | unqualifiedMetastatement )+
|
|
168
168
|
|
|
169
|
-
|
|
169
|
+
"Therefore" <END_OF_LINE>
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
)?
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
( qualifiedMetastatement | unqualifiedMetastatement ) ;
|
|
174
174
|
|
|
175
|
-
metaSubDerivation ::=
|
|
175
|
+
metaSubDerivation ::= (
|
|
176
176
|
|
|
177
|
-
|
|
177
|
+
"Hence" <END_OF_LINE>
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
( metaSubproof | qualifiedMetastatement | unqualifiedMetastatement )+
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
)?
|
|
182
182
|
|
|
183
|
-
|
|
183
|
+
"Then" <END_OF_LINE>
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
( qualifiedMetastatement | unqualifiedMetastatement ) ;
|
|
186
186
|
|
|
187
|
-
axiom ::=
|
|
187
|
+
axiom ::= "Axiom" parenthesisedLabels <END_OF_LINE>
|
|
188
188
|
|
|
189
|
-
|
|
189
|
+
(
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
(
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
"Suppose" <END_OF_LINE> supposition+
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
"Then" <END_OF_LINE> consequent
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
)
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
|
|
|
200
200
|
|
|
201
|
-
|
|
201
|
+
consequent
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
) ;
|
|
204
204
|
|
|
205
|
-
lemma ::=
|
|
205
|
+
lemma ::= "Lemma" parenthesisedLabels? <END_OF_LINE>
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
(
|
|
208
208
|
|
|
209
|
-
|
|
209
|
+
(
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
"Suppose" <END_OF_LINE> supposition+
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
"Then" <END_OF_LINE> consequent
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
)
|
|
216
216
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
|
|
|
218
|
+
|
|
219
|
+
consequent
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
)
|
|
222
222
|
|
|
223
|
-
|
|
223
|
+
proof ;
|
|
224
224
|
|
|
225
|
-
theorem ::=
|
|
225
|
+
theorem ::= "Theorem" parenthesisedLabels <END_OF_LINE>
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
(
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
(
|
|
230
230
|
|
|
231
|
-
|
|
231
|
+
"Suppose" <END_OF_LINE> supposition+
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
"Then" <END_OF_LINE> consequent
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
)
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
|
|
|
238
238
|
|
|
239
|
-
|
|
239
|
+
consequent
|
|
240
240
|
|
|
241
|
-
|
|
241
|
+
)
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
proof ;
|
|
244
244
|
|
|
245
|
-
conjecture ::=
|
|
245
|
+
conjecture ::= "Conjecture" parenthesisedLabels <END_OF_LINE>
|
|
246
246
|
|
|
247
|
-
|
|
247
|
+
(
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
(
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
"Suppose" <END_OF_LINE> supposition+
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
"Then" <END_OF_LINE> consequent
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
)
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
|
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
consequent
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
)
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
proof? ;
|
|
264
264
|
|
|
265
265
|
|
|
266
266
|
|
|
267
|
-
proof ::=
|
|
267
|
+
proof ::= "Proof" <END_OF_LINE> derivation ;
|
|
268
268
|
|
|
269
|
-
subproof ::=
|
|
269
|
+
subproof ::= "Suppose" <END_OF_LINE> supposition+ subDerivation ;
|
|
270
270
|
|
|
271
|
-
derivation ::=
|
|
271
|
+
derivation ::= (
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
( subproof | qualifiedStatement | unqualifiedStatement )+
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
"Therefore" <END_OF_LINE>
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
)?
|
|
278
278
|
|
|
279
|
-
|
|
279
|
+
( qualifiedStatement | unqualifiedStatement ) ;
|
|
280
280
|
|
|
281
|
-
subDerivation ::=
|
|
281
|
+
subDerivation ::= (
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
"Hence" <END_OF_LINE>
|
|
284
284
|
|
|
285
|
-
|
|
285
|
+
( subproof | qualifiedStatement | unqualifiedStatement )+
|
|
286
286
|
|
|
287
|
-
|
|
287
|
+
)?
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
"Then" <END_OF_LINE>
|
|
290
290
|
|
|
291
|
-
|
|
291
|
+
( qualifiedStatement | unqualifiedStatement ) ;
|
|
292
292
|
|
|
293
293
|
|
|
294
294
|
|
|
295
|
-
premise ::=
|
|
295
|
+
premise ::= unqualifiedMetastatement ;
|
|
296
296
|
|
|
297
|
-
conclusion ::=
|
|
297
|
+
conclusion ::= unqualifiedMetastatement ;
|
|
298
298
|
|
|
299
299
|
|
|
300
300
|
|
|
301
|
-
metaSupposition ::=
|
|
301
|
+
metaSupposition ::= unqualifiedMetastatement ;
|
|
302
302
|
|
|
303
|
-
metaConsequent ::=
|
|
303
|
+
metaConsequent ::= unqualifiedMetastatement ;
|
|
304
304
|
|
|
305
305
|
|
|
306
306
|
|
|
307
|
-
supposition ::=
|
|
307
|
+
supposition ::= unqualifiedStatement ;
|
|
308
308
|
|
|
309
|
-
consequent ::=
|
|
309
|
+
consequent ::= unqualifiedStatement ;
|
|
310
310
|
|
|
311
311
|
|
|
312
312
|
|
|
313
|
-
unqualifiedMetastatement.. ::=
|
|
313
|
+
unqualifiedMetastatement.. ::= metastatement... <END_OF_LINE>
|
|
314
314
|
|
|
315
|
-
|
|
|
315
|
+
| nonsense... <END_OF_LINE>
|
|
316
316
|
|
|
317
317
|
;
|
|
318
318
|
|
|
319
|
-
qualifiedMetastatement.. ::=
|
|
319
|
+
qualifiedMetastatement.. ::= metastatement... qualification <END_OF_LINE>
|
|
320
320
|
|
|
321
|
-
|
|
|
321
|
+
| nonsense... qualification <END_OF_LINE>
|
|
322
322
|
|
|
323
323
|
;
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
|
|
327
|
-
unqualifiedStatement.. ::=
|
|
327
|
+
unqualifiedStatement.. ::= statement... <END_OF_LINE>
|
|
328
328
|
|
|
329
|
-
|
|
|
329
|
+
| nonsense... <END_OF_LINE>
|
|
330
330
|
|
|
331
331
|
;
|
|
332
332
|
|
|
333
|
-
qualifiedStatement.. ::=
|
|
333
|
+
qualifiedStatement.. ::= statement... qualification <END_OF_LINE>
|
|
334
334
|
|
|
335
|
-
|
|
|
335
|
+
| nonsense... qualification <END_OF_LINE>
|
|
336
336
|
|
|
337
337
|
;
|
|
338
338
|
|
|
339
339
|
|
|
340
340
|
|
|
341
|
-
qualification ::=
|
|
341
|
+
qualification ::= ( "by" | "from" ) reference ;
|
|
342
342
|
|
|
343
343
|
|
|
344
344
|
|
|
345
|
-
dependentType ::=
|
|
345
|
+
dependentType ::= [type]<NO_WHITESPACE>"(" argument... ")" ;
|
|
346
346
|
|
|
347
|
-
disjointType ::=
|
|
347
|
+
disjointType ::= [type] ( "|" [type] )+ ;
|
|
348
348
|
|
|
349
|
-
metaType ::=
|
|
349
|
+
metaType ::= [meta-type] ;
|
|
350
350
|
|
|
351
|
-
type ::=
|
|
351
|
+
type ::= [type] ;
|
|
352
352
|
|
|
353
353
|
|
|
354
354
|
|
|
355
355
|
parenthesisedLabels ::= "(" labels... ")" ;
|
|
356
356
|
|
|
357
|
-
labels ::=
|
|
357
|
+
labels ::= label ( "," label )* ;
|
|
358
358
|
|
|
359
359
|
|
|
360
360
|
|
|
361
|
-
reference. ::=
|
|
361
|
+
reference. ::= [name] ( <NO_WHITESPACE>"(" term... ")" )? ;
|
|
362
362
|
|
|
363
|
-
label. ::=
|
|
363
|
+
label. ::= [name] ( <NO_WHITESPACE>"(" term... ")" )? ;
|
|
364
364
|
|
|
365
365
|
|
|
366
366
|
|
|
367
|
-
nonsense. ::=
|
|
367
|
+
nonsense. ::= ( [type] | [symbol] | [operator] | [special] | [secondary-keyword] | [meta-type] | [name] | [unassigned] )+ ;
|
|
368
368
|
|
|
369
369
|
|
|
370
370
|
|
|
371
|
-
metavariable ::=
|
|
371
|
+
metavariable ::= [name] ( <NO_WHITESPACE>"(" argument... ")" )? ;
|
|
372
372
|
|
|
373
|
-
variable ::=
|
|
373
|
+
variable ::= [name] ;
|
|
374
374
|
|
|
375
375
|
|
|
376
376
|
|
|
377
|
-
metaArgument ::=
|
|
377
|
+
metaArgument ::= statement ( )
|
|
378
378
|
|
|
379
|
-
|
|
|
379
|
+
| metaType ( )
|
|
380
380
|
|
|
381
381
|
;
|
|
382
382
|
|
|
383
|
-
argument ::=
|
|
383
|
+
argument ::= term ( )
|
|
384
384
|
|
|
385
|
-
|
|
|
385
|
+
| type ( )
|
|
386
386
|
|
|
387
387
|
;`;
|
|
388
388
|
|