-
Notifications
You must be signed in to change notification settings - Fork 2
/
lambdapi_parser.expected
2141 lines (2141 loc) · 127 KB
/
lambdapi_parser.expected
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[@@@ocaml.text
" Parsing functions for the Lambdapi syntax based on the Earley library. See\n https://github.com/rlepigre/ocaml-earley/blob/master/README.md for details\n on using the library and its syntax extension. "]
open Earley_core
open Extra
open Syntax
open Files
open Pos
[@@@ocaml.text
" {b NOTE} we maintain the invariant that errors reported by the parser have\n a position. To help enforce that, we avoid opening the [Console] module so\n that [Console.fatal] and [Console.fatal_no_pos] are not in scope. To raise\n an error in the parser, only the following function should be used. "]
let parser_fatal : Pos.pos -> ('a, 'b) Console.koutfmt -> 'a =
fun loc -> fun fmt -> Console.fatal (Some loc) fmt[@@ocaml.doc
" [parser_fatal loc fmt] is a wrapper for [Console.fatal] that enforces that\n the error has an attached source code position. "]
module Prefix :
sig
type 'a t
val init : unit -> 'a t[@@ocaml.doc
" [init ()] initializes a new (empty) prefix tree. "]
val reset : 'a t -> unit[@@ocaml.doc
" [reset t] resets [t] to an empty prefix tree [t]. "]
val add : 'a t -> string -> 'a -> unit[@@ocaml.doc
" [add k v t] inserts the value [v] with the key [k] (possibly replacing\n a previous value associated to [k]) in the tree [t]. Note that key [k]\n should not be [\"\"], otherwise [Invalid_argument] is raised. "]
val grammar : 'a t -> 'a Earley.grammar[@@ocaml.doc
" [grammar t] is an [Earley] grammar parsing the longest possible prefix\n of the input corresponding to a word of [t]. The corresponding, stored\n value is returned. It fails if no such longest prefix exist. "]
type 'a saved[@@ocaml.doc
" Type of a saved prefix tree. Prefix trees are imperative, so they need\n to be manually saved and restored to enforce reentrancy. Note that the\n parser may call itself through dependency loading "]
val save : 'a t -> 'a saved[@@ocaml.doc
" [save t] returns a snapshot of the internal state of [t]. "]
val restore : 'a t -> 'a saved -> unit[@@ocaml.doc
" [restore t s] restores the internal state of [t] as it was at the time\n of calling [save]. "]
end =
struct
type 'a tree =
| Node of 'a option * (char * 'a tree) list
type 'a t = 'a tree Stdlib.ref
let init : unit -> 'a t = fun _ -> ref (Node (None, []))
let reset : 'a t -> unit = fun t -> t := (Node (None, []))
let add : 'a t -> string -> 'a -> unit =
fun t ->
fun k ->
fun v ->
if k = "" then invalid_arg "Prefix.add";
(let rec add i (Node (vo, l)) =
match try Some (k.[i]) with | _ -> None with
| None -> Node ((Some v), l)
| Some c ->
let l =
try
let t = List.assoc c l in (c, (add (i + 1) t)) ::
(List.remove_assoc c l)
with
| Not_found -> (c, (add (i + 1) (Node (None, [])))) :: l in
Node (vo, l) in
t := (add 0 (!t)))
let grammar : 'a t -> 'a Earley.grammar =
fun t ->
let fn buf pos =
let rec fn best (Node (vo, l)) buf pos =
let best =
match vo with | None -> best | Some v -> Some (v, buf, pos) in
try
let (c, buf, pos) = Input.read buf pos in
fn best (List.assoc c l) buf pos
with
| Not_found ->
(match best with
| None -> Earley.give_up ()
| Some best -> best) in
fn None (!t) buf pos in
Earley.black_box fn Charset.full false "<tree>"
type 'a saved = 'a tree
let save : 'a t -> 'a saved = Stdlib.(!)
let restore : 'a t -> 'a saved -> unit = Stdlib.(:=)
end
[@@@ocaml.text " Prefix trees for greedy parsing among a set of string. "]
[@@@ocaml.text " Type of a prefix tree. "]
let unops : unop Prefix.t = Prefix.init ()[@@ocaml.doc
" Currently defined unary operators. "]
let unop = Prefix.grammar unops[@@ocaml.doc " Parser for a unary operator. "]
let binops : binop Prefix.t = Prefix.init ()[@@ocaml.doc
" Currently defined binary operators. "]
let binop = Prefix.grammar binops[@@ocaml.doc
" Parser for a binary operator. "]
let declared_ids : string Prefix.t = Prefix.init ()[@@ocaml.doc
" Currently defined identifiers. "]
let declared_id = Prefix.grammar declared_ids[@@ocaml.doc
" Parser for a declared identifier. "]
let forbidden_in_ops =
["(";
")";
".";
"\206\187";
"\206\160";
"$";
"[";
"]";
"{";
"}";
"?";
":";
"\226\134\170";
"\226\138\162";
"\226\134\146";
"@";
",";
";";
"\"";
"'";
"\226\137\148";
"//";
" ";
"\r";
"\n";
"\t";
"\b"] @ (List.init 10 string_of_int)[@@ocaml.doc
" The following should not appear as substrings of binary operators, as they\n would introduce ambiguity in the parsing. "]
let get_ops : Pos.pos -> p_module_path -> unit =
fun loc ->
fun p ->
let p = List.map fst p in
let sign =
try PathMap.find p (let open Timed in !Sign.loaded)
with
| Not_found ->
parser_fatal loc "Module [%a] not loaded (used for binops)."
Path.pp p in
let fn s (_, unop) = Prefix.add unops s unop in
StrMap.iter fn (let open Timed in !(let open Sign in sign.sign_unops));
(let fn s (_, binop) = Prefix.add binops s binop in
StrMap.iter fn
(let open Timed in !(let open Sign in sign.sign_binops));
(let fn s = Prefix.add declared_ids s s in
StrSet.iter fn
(let open Timed in !(let open Sign in sign.sign_idents))))[@@ocaml.doc
" [get_ops loc p] loads the unary and binary operators associated to module\n [p] and report possible errors at location [loc]. This operation requires\n the module [p] to be loaded (i.e., compiled). The declared identifiers are\n also retrieved at the same time. "]
let blank = Blanks.line_comments "//"[@@ocaml.doc
" Blank function (for comments and white spaces). "]
let id_charset = Charset.from_string "a-zA-Z0-9_'"[@@ocaml.doc
" Set of identifier characters. "]
module KW =
(Keywords.Make)(struct let id_charset = id_charset
let reserved = [] end)
[@@@ocaml.text " Keyword module. "]
let _ = KW.reserve "KIND"[@@ocaml.doc
" Reserve [\"KIND\"] to disallow it as an identifier. "]
let _abort_ = KW.create "abort"[@@ocaml.doc
" Keyword declarations. Keep alphabetical order. "]
let _admit_ = KW.create "admit"
let _apply_ = KW.create "apply"
let _as_ = KW.create "as"
let _assert_ = KW.create "assert"
let _assertnot_ = KW.create "assertnot"
let _compute_ = KW.create "compute"
let _constant_ = KW.create "constant"
let _definition_ = KW.create "definition"
let _focus_ = KW.create "focus"
let _in_ = KW.create "in"
let _injective_ = KW.create "injective"
let _intro_ = KW.create "assume"
let _let_ = KW.create "let"
let _open_ = KW.create "open"
let _print_ = KW.create "print"
let _private_ = KW.create "private"
let _proof_ = KW.create "proof"
let _proofterm_ = KW.create "proofterm"
let _protected_ = KW.create "protected"
let _qed_ = KW.create "qed"
let _refine_ = KW.create "refine"
let _refl_ = KW.create "reflexivity"
let _require_ = KW.create "require"
let _rewrite_ = KW.create "rewrite"
let _rule_ = KW.create "rule"
let _set_ = KW.create "set"
let _simpl_ = KW.create "simpl"
let _sym_ = KW.create "symmetry"
let _symbol_ = KW.create "symbol"
let _theorem_ = KW.create "theorem"
let _type_ = KW.create "type"
let _TYPE_ = KW.create "TYPE"
let _why3_ = KW.create "why3"
let _wild_ = KW.create "_"
let _with_ = KW.create "with"
let sanity_check : Pos.pos -> string -> unit =
fun loc ->
fun s ->
if s = "" then parser_fatal loc "Invalid token (empty).";
if KW.mem s then parser_fatal loc "Invalid token (reserved).";
if String.for_all (Charset.mem id_charset) s
then parser_fatal loc "Invalid token (only identifier characters).";
(let check_substring w =
if String.is_substring w s
then parser_fatal loc "Invalid token (has [%s] as a substring)." w in
List.iter check_substring forbidden_in_ops)[@@ocaml.doc
" [sanity_check pos s] checks that the token [s] is appropriate for an infix\n operator or a declared identifier. If it is not the case, then the [Fatal]\n exception is raised. "]
let nat_lit =
let num_cs = Charset.from_string "0-9" in
let fn buf pos =
let nb = ref 1 in
while Charset.mem num_cs (Input.get buf (pos + (!nb))) do incr nb done;
((int_of_string (String.sub (Input.line buf) pos (!nb))), buf,
(pos + (!nb))) in
Earley.black_box fn num_cs false "<nat>"[@@ocaml.doc
" Natural number literal. "]
let float_lit =
let num_cs = Charset.from_string "0-9" in
let fn buf pos =
let nb = ref 1 in
while Charset.mem num_cs (Input.get buf (pos + (!nb))) do incr nb done;
if (Input.get buf (pos + (!nb))) = '.'
then
(incr nb;
while Charset.mem num_cs (Input.get buf (pos + (!nb))) do incr nb done);
((float_of_string (String.sub (Input.line buf) pos (!nb))), buf,
(pos + (!nb))) in
Earley.black_box fn num_cs false "<float>"[@@ocaml.doc
" Floating-point number literal. "]
let string_lit =
let body_cs = List.fold_left Charset.del Charset.full ['"'; '\n'] in
let fn buf pos =
let nb = ref 1 in
while Charset.mem body_cs (Input.get buf (pos + (!nb))) do incr nb done;
if (Input.get buf (pos + (!nb))) <> '"' then Earley.give_up ();
((String.sub (Input.line buf) (pos + 1) ((!nb) - 1)), buf,
((pos + (!nb)) + 1)) in
Earley.black_box fn (Charset.singleton '"') false "<string>"[@@ocaml.doc
" String literal. "]
let alpha =
let alpha = Charset.from_string "a-zA-Z" in
let fn buf pos =
let nb = ref 1 in
while Charset.mem alpha (Input.get buf (pos + (!nb))) do incr nb done;
((String.sub (Input.line buf) pos (!nb)), buf, (pos + (!nb))) in
Earley.black_box fn alpha false "<alpha>"[@@ocaml.doc
" Sequence of alphabetical characters. "]
let regular_ident =
let head_cs = Charset.from_string "a-zA-Z_" in
let body_cs = Charset.from_string "a-zA-Z0-9_'" in
let fn buf pos =
let nb = ref 1 in
while Charset.mem body_cs (Input.get buf (pos + (!nb))) do incr nb done;
((String.sub (Input.line buf) pos (!nb)), buf, (pos + (!nb))) in
Earley.black_box fn head_cs false "<r-ident>"[@@ocaml.doc
" Regular identifier (regexp [\"[a-zA-Z_][a-zA-Z0-9_']*\"]). "]
let escaped_ident : bool -> string Earley.grammar =
fun with_delim ->
let fn buf pos =
let s = Buffer.create 20 in
let (c, buf, pos) = Input.read buf (pos + 1) in
if c <> '|' then Earley.give_up ();
if with_delim then Buffer.add_string s "{|";
(let rec work buf pos =
let (c, buf, pos) = Input.read buf pos in
let next_c = Input.get buf pos in
if (c = '|') && (next_c = '}')
then (buf, (pos + 1))
else
if c <> '\255'
then (Buffer.add_char s c; work buf pos)
else Earley.give_up () in
let (buf, pos) = work buf pos in
if with_delim then Buffer.add_string s "|}";
((Buffer.contents s), buf, pos)) in
let p_name = if with_delim then "{|<e-ident>|}" else "<e-ident>" in
Earley.black_box fn (Charset.singleton '{') false p_name[@@ocaml.doc
" [escaped_ident with_delim] is a parser for a single escaped identifier. An\n escaped identifier corresponds to an arbitrary sequence of characters that\n starts with [\"{|\"], ends with [\"|}\"], and does not contain [\"|}\"]. Or said\n otherwise, they are recognised by regexp [\"{|\\([^|]\\|\\(|[^}]\\)\\)|*|}\"]. If\n [with_delim] is [true] then the returned string includes both the starting\n and the ending delimitors. They are otherwise omited. "]
let escaped_ident_no_delim = escaped_ident false
let escaped_ident = escaped_ident true
let any_ident = Earley_core.Earley.declare_grammar "any_ident"
let _ =
Earley_core.Earley.set_grammar any_ident
(Earley_core.Earley.alternatives
(List.cons declared_id
(List.cons
(Earley_core.Earley.fsequence regular_ident
(Earley_core.Earley.empty (fun id -> KW.check id; id)))
(List.cons escaped_ident []))))
[@@@ocaml.text " Any identifier (regular or escaped). "]
let ident = Earley_core.Earley.declare_grammar "ident"
let _ =
Earley_core.Earley.set_grammar ident
(Earley_core.Earley.fsequence any_ident
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun id -> in_pos _loc id)))
[@@@ocaml.text " Identifier (regular and non-keyword, or escaped). "]
let arg_ident = Earley_core.Earley.declare_grammar "arg_ident"
let _ =
Earley_core.Earley.set_grammar arg_ident
(Earley_core.Earley.alternatives
(List.cons
(Earley_core.Earley.fsequence _wild_
(Earley_core.Earley.empty (fun _default_0 -> None)))
(List.cons
(Earley_core.Earley.fsequence ident
(Earley_core.Earley.empty (fun id -> Some id))) [])))
let meta = Earley_core.Earley.declare_grammar "meta"
let _ =
Earley_core.Earley.set_grammar meta
(Earley_core.Earley.fsequence_ignore (Earley_core.Earley.string "?" "?")
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.no_blank_test ())
(Earley_core.Earley.fsequence
(Earley_core.Earley.alternatives
(List.cons escaped_ident (List.cons regular_ident [])))
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun id ->
if id = "_" then Earley.give_up (); in_pos _loc id)))))
[@@@ocaml.text
" Metavariable identifier (regular or escaped, prefixed with ['?']). "]
let patt = Earley_core.Earley.declare_grammar "patt"
let _ =
Earley_core.Earley.set_grammar patt
(Earley_core.Earley.fsequence_ignore (Earley_core.Earley.string "$" "$")
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.no_blank_test ())
(Earley_core.Earley.fsequence
(Earley_core.Earley.alternatives
(List.cons escaped_ident (List.cons regular_ident [])))
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun id ->
if id = "_" then None else Some (in_pos _loc id))))))
[@@@ocaml.text
" Pattern variable identifier (regular or escaped, prefixed with ['$']). "]
let path_elem = Earley_core.Earley.declare_grammar "path_elem"
let _ =
Earley_core.Earley.set_grammar path_elem
(Earley_core.Earley.alternatives
(List.cons
(Earley_core.Earley.fsequence escaped_ident_no_delim
(Earley_core.Earley.empty (fun id -> (id, true))))
(List.cons
(Earley_core.Earley.fsequence regular_ident
(Earley_core.Earley.empty
(fun id -> KW.check id; (id, false)))) [])))
[@@@ocaml.text " Any path member identifier (escaped idents are stripped). "]
let path = Earley_core.Earley.declare_grammar "path"
let _ =
Earley_core.Earley.set_grammar path
(Earley_core.Earley.fsequence path_elem
(Earley_core.Earley.fsequence
(Earley_core.Earley.greedy
(Earley_core.Earley.apply (fun f -> f [])
(Earley_core.Earley.fixpoint' (fun l -> l)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "." ".")
(Earley_core.Earley.fsequence path_elem
(Earley_core.Earley.empty
(fun _default_0 -> _default_0))))
(fun x -> fun f -> fun l -> f (List.cons x l)))))
(Earley_core.Earley.empty (fun ms -> fun m -> m :: ms))))
[@@@ocaml.text " Module path (dot-separated identifiers. "]
let qident = Earley_core.Earley.declare_grammar "qident"
let _ =
Earley_core.Earley.set_grammar qident
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply (fun f -> f [])
(Earley_core.Earley.fixpoint' (fun l -> l)
(Earley_core.Earley.fsequence path_elem
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "." ".")
(Earley_core.Earley.empty (fun _default_0 -> _default_0))))
(fun x -> fun f -> fun l -> f (List.cons x l))))
(Earley_core.Earley.fsequence any_ident
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun id -> fun mp -> in_pos _loc (mp, id)))))
[@@@ocaml.text " [qident] parses a single (possibly qualified) identifier. "]
let property = Earley_core.Earley.declare_grammar "property"
let _ =
Earley_core.Earley.set_grammar property
(Earley_core.Earley.alternatives
(List.cons
(Earley_core.Earley.fsequence _injective_
(Earley_core.Earley.empty (fun _default_0 -> Terms.Injec)))
(List.cons
(Earley_core.Earley.fsequence _constant_
(Earley_core.Earley.empty (fun _default_0 -> Terms.Const)))
[])))
[@@@ocaml.text " [symtag] parses a single symbol tag. "]
let exposition = Earley_core.Earley.declare_grammar "exposition"
let _ =
Earley_core.Earley.set_grammar exposition
(Earley_core.Earley.alternatives
(List.cons
(Earley_core.Earley.fsequence _private_
(Earley_core.Earley.empty (fun _default_0 -> Terms.Privat)))
(List.cons
(Earley_core.Earley.fsequence _protected_
(Earley_core.Earley.empty (fun _default_0 -> Terms.Protec)))
[])))
[@@@ocaml.text " [exposition] parses the exposition tag of a symbol."]
type prio =
| PAtom
| PAppl
| PUnaO
| PBinO
| PFunc [@@ocaml.doc " Priority level for an expression (term or type). "]
let (term, term__set__grammar) = Earley_core.Earley.grammar_prio "term"
let env = Earley_core.Earley.declare_grammar "env"
let arg = Earley_core.Earley.declare_grammar "arg"
let _ =
term__set__grammar
((List.cons
((fun (p : prio) -> p >= PBinO),
(Earley_core.Earley.iter
(Earley_core.Earley.fsequence (term PBinO)
(Earley_core.Earley.fsequence binop
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun b ->
fun t ->
let (min_pl, min_pr) =
let (_, assoc, p, _) = b in
let p_plus_epsilon = p +. 1e-6 in
match assoc with
| Assoc_none ->
(p_plus_epsilon, p_plus_epsilon)
| Assoc_left -> (p, p_plus_epsilon)
| Assoc_right -> (p_plus_epsilon, p) in
let _ =
match t.elt with
| P_BinO (_, (_, _, p, _), _) when
p < min_pl -> Earley.give_up ()
| _ -> () in
Earley_core.Earley.fsequence (term PBinO)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun u ->
let _ =
match u.elt with
| P_BinO
(_, (_, _, p, _), _)
->
if p < min_pr
then
Earley.give_up ()
| _ -> () in
in_pos _loc
(P_BinO (t, b, u))))))))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence _TYPE_
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf __loc__start__pos
__loc__end__buf __loc__end__pos in
fun _default_0 -> in_pos _loc P_Type))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence
(Earley_core.Earley.option false
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "@" "@")
(Earley_core.Earley.empty true)))
(Earley_core.Earley.fsequence qident
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos __loc__end__buf
__loc__end__pos in
fun qid ->
fun expl ->
in_pos _loc (P_Iden (qid, expl)))))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence _wild_
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos __loc__end__buf
__loc__end__pos in
fun _default_0 -> in_pos _loc P_Wild))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence meta
(Earley_core.Earley.fsequence
(Earley_core.Earley.option [] env)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos __loc__end__buf
__loc__end__pos in
fun e ->
fun m ->
in_pos _loc
(P_Meta (m, (Array.of_list e))))))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence patt
(Earley_core.Earley.fsequence
(Earley_core.Earley.option [] env)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun e ->
fun p ->
in_pos _loc
(P_Patt
(p, (Array.of_list e))))))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "(" "(")
(Earley_core.Earley.fsequence (term PFunc)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string ")" ")")
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate __loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun t ->
in_pos _loc (P_Wrap t)))))))
(List.cons
((fun (p : prio) -> p >= PAtom),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "{" "{")
(Earley_core.Earley.fsequence (term PFunc)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string "}" "}")
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun t ->
in_pos _loc (P_Expl t)))))))
(List.cons
((fun (p : prio) -> p >= PAppl),
(Earley_core.Earley.fsequence (term PAppl)
(Earley_core.Earley.fsequence
(term PAtom)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos ->
let _loc =
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun u ->
fun t ->
in_pos _loc
(P_Appl (t, u)))))))
(List.cons
((fun (p : prio) -> p >= PFunc),
(Earley_core.Earley.fsequence
(term PBinO)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\226\134\146" "\226\134\146")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf ->
fun __loc__start__pos ->
fun __loc__end__buf ->
fun __loc__end__pos
->
let _loc =
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun b ->
fun a ->
in_pos _loc
(P_Impl
(a, b))))))))
(List.cons
((fun (p : prio) -> p >= PFunc),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\206\160" "\206\160")
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply
(fun f -> f [])
(Earley_core.Earley.fixpoint1'
(fun l -> l) arg
(fun x ->
fun f ->
fun l ->
f (List.cons x l))))
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"," ",")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.empty_pos
(fun __loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc =
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun b ->
fun xs ->
in_pos
_loc
(P_Prod
(xs, b)))))))))
(List.cons
((fun (p : prio) -> p >= PFunc),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\206\160" "\206\160")
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply
(fun f -> f [])
(Earley_core.Earley.fixpoint1'
(fun l -> l) arg_ident
(fun x ->
fun f ->
fun l ->
f
(List.cons x
l))))
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
":" ":")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"," ",")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun b ->
fun a ->
fun xs ->
in_pos
_loc
(P_Prod
([
(xs,
(Some a),
false)],
b)))))))))))
(List.cons
((fun (p : prio) -> p >= PFunc),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\206\187" "\206\187")
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply
(fun f -> f [])
(Earley_core.Earley.fixpoint1'
(fun l -> l) arg
(fun x ->
fun f ->
fun l ->
f
(List.cons
x l))))
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"," ",")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun t ->
fun xs ->
in_pos
_loc
(P_Abst
(xs, t)))))))))
(List.cons
((fun (p : prio) -> p >= PFunc),
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\206\187" "\206\187")
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply
(fun f -> f [])
(Earley_core.Earley.fixpoint1'
(fun l -> l)
arg_ident
(fun x ->
fun f ->
fun l ->
f
(List.cons
x l))))
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
":" ":")
(Earley_core.Earley.fsequence
(term PFunc)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"," ",")
(Earley_core.Earley.fsequence
(term
PFunc)
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun t ->
fun a ->
fun xs ->
in_pos
_loc
(P_Abst
([
(xs,
(Some a),
false)],
t)))))))))))
(List.cons
((fun (p : prio) ->
p >= PFunc),
(Earley_core.Earley.fsequence
_let_
(Earley_core.Earley.fsequence
ident
(Earley_core.Earley.fsequence
(Earley_core.Earley.apply
(fun f ->
f [])
(Earley_core.Earley.fixpoint'
(fun l ->
l) arg
(fun x ->
fun f ->
fun l ->
f
(List.cons
x l))))
(Earley_core.Earley.fsequence
(Earley_core.Earley.option
None
(Earley_core.Earley.apply
(fun x ->
Some x)
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
":" ":")
(Earley_core.Earley.fsequence
(term
PFunc)
(Earley_core.Earley.empty
(fun
_default_0
->
_default_0))))))
(Earley_core.Earley.fsequence_ignore
(Earley_core.Earley.string
"\226\137\148"
"\226\137\148")
(Earley_core.Earley.fsequence
(term
PFunc)
(Earley_core.Earley.fsequence
_in_
(Earley_core.Earley.fsequence
(term
PFunc)
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun u ->
fun
_default_0
->
fun t ->
fun b ->
fun a ->
fun x ->
fun
_default_1
->
in_pos
_loc
(P_LLet
(x, a, b,
t, u)))))))))))))
(List.cons
((fun (p : prio) ->
p >= PAtom),
(Earley_core.Earley.fsequence
nat_lit
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun n ->
in_pos
_loc
(P_NLit n)))))
(List.cons
((fun (p : prio) ->
p >= PUnaO),
(Earley_core.Earley.fsequence
unop
(Earley_core.Earley.fsequence
(term PUnaO)
(Earley_core.Earley.empty_pos
(fun
__loc__start__buf
->
fun
__loc__start__pos
->
fun
__loc__end__buf
->
fun
__loc__end__pos
->
let _loc
=
locate
__loc__start__buf
__loc__start__pos
__loc__end__buf
__loc__end__pos in
fun t ->
fun u ->
let min_p
=
let
(_, p, _)
= u in p in