/
include_ml
127 lines (102 loc) · 3.15 KB
/
include_ml
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
#use "../local-install/lib/ocaml/topfind.camlp5";;
#require "compiler-libs.common" ;;
#require "camlp-streams";;
#require "oUnit";;
#require "fmt";;
#require "rresult";;
#require "pcre2";;
#require "bos";;
(*
#require "camlp5.pa_op";;
Pcaml.inter_phrases := Some ";;\n";;
*)
#require "camlp5.pa_r";;
Pcaml.inter_phrases := Some ";\n";;
(*
#require "camlp5.pr_o";;
*)
#require "camlp5.pr_r";;
Pcaml.inter_phrases := Some ";\n";;
#require "camlp5.parser_quotations";;
(*
#require "camlp5.quotations";;
*)
(*
#require "camlp5.extfun";;
#require "camlp5.extend";;
#require "camlp5.phony_quotations" ;;
*)
#directory "../main";;
Exparser.optim := false ;;
#load "testutil.cmo";;
#load "testutil2.cmo";;
open OUnit2 ;;
open Testutil ;;
open Testutil2 ;;
#load "roundtrip_lexer.cmo";;
open Roundtrip_lexer ;;
let pp_plexing_lexbuf b = Fmt.(pf stdout "<<%s>>" (Plexing.Lexbuf.get b)) ;;
#install_printer pp_plexing_lexbuf ;;
(*
#load "papr_matrix_test.cmo" ;;
#load "r2r_test.cmo" ;;
*)
let pp_loc (loc : Location.t) = Format.print_string "<loc>" ;;
#install_printer pp_loc ;;
let pp_char_stream strm =
let l = Stream.npeek !Toploop.max_printer_depth strm in
Fmt.(pf stdout "<strm<[%a]>>" (list char) l)
;;
#install_printer pp_char_stream ;;
let pp_token_stream strm =
let l = Stream.npeek !Toploop.max_printer_depth strm in
let rec trim_eoi = function
("EOI",_ as x)::_ -> [x]
| h::t -> h::(trim_eoi t)
| [] -> []
in
Fmt.(pf stdout "<strm<[%a]>>" (list ~sep:comma (parens (pair ~sep:comma (quote string) (quote string)))) (trim_eoi l))
;;
#install_printer pp_token_stream ;;
let lexbuf_contents lb =
let open Lexing in
let pos = lb.lex_curr_pos in
let len = lb.lex_buffer_len - lb.lex_curr_pos in
(Bytes.to_string (Bytes.sub lb.lex_buffer pos len))
;;
let pp_lexbuf lb =
Format.print_string "#<lexbuf:<";
Format.print_string (lexbuf_contents lb);
Format.print_string ">>"
;;
#install_printer pp_lexbuf ;;
open Asttypes ;;
open Parsetree ;;
open Longident ;;
let pp_ctyp ty = Fmt.(pf stdout "#<ctyp< %s >>" (Eprinter.apply Pcaml.pr_ctyp Pprintf.empty_pc ty));;
let pp_expr ty = Fmt.(pf stdout "#<expr< %s >>" (Eprinter.apply Pcaml.pr_expr Pprintf.empty_pc ty));;
let pp_patt ty = Fmt.(pf stdout "#<patt< %s >>" (Eprinter.apply Pcaml.pr_patt Pprintf.empty_pc ty));;
let pp_str_item ty = Fmt.(pf stdout "#<str_item< %s >>" (Eprinter.apply Pcaml.pr_str_item Pprintf.empty_pc ty));;
let pp_sig_item ty = Fmt.(pf stdout "#<sig_item< %s >>" (Eprinter.apply Pcaml.pr_sig_item Pprintf.empty_pc ty));;
(*
let pp_ctyp ty = Fmt.(pf stdout "#<ctyp< %a >>" Pa_ppx_base.Pp_MLast.pp_ctyp ty);;
let pp_expr ty = Fmt.(pf stdout "#<expr< %a >>" Pa_ppx_base.Pp_MLast.pp_expr ty);;
let pp_patt ty = Fmt.(pf stdout "#<patt< %a >>" Pa_ppx_base.Pp_MLast.pp_patt ty);;
*)
(*
#install_printer pp_ctyp ;;
#install_printer pp_expr ;;
#install_printer pp_patt ;;
#install_printer pp_str_item ;;
#install_printer pp_sig_item ;;
*)
print_string "================ START ================\n";; flush stdout ;;
let parse_antiquot ep s =
Ploc.call_with Plexer.force_antiquot_loc true
(Grammar.Entry.parse ep) (Stream.of_string s)
;;
(*
;;; Local Variables: ***
;;; mode:tuareg ***
;;; End: ***
*)