@@ -60,15 +60,13 @@ let export (field : string) v =
60
60
;;
61
61
62
62
module Lang = struct
63
- type t = OCaml | Res
63
+ type t = Res
64
64
65
65
let from_string t = match t with
66
- | "ocaml" | "ml" -> Some OCaml
67
66
| "res" -> Some Res
68
67
| _ -> None
69
68
70
69
let to_string t = match t with
71
- | OCaml -> " ml"
72
70
| Res -> " res"
73
71
end
74
72
@@ -221,15 +219,6 @@ let get_filename ~(lang: Lang.t) opt =
221
219
| Some fname -> fname
222
220
| None -> BundleConfig. default_filename lang
223
221
224
- let lexbuf_from_string ~filename str =
225
- let lexbuf = Lexing. from_string str in
226
- lexbuf.lex_start_p < - { lexbuf.lex_start_p with pos_fname = filename };
227
- lexbuf.lex_curr_p < - { lexbuf.lex_curr_p with pos_fname = filename };
228
- lexbuf
229
-
230
- let ocaml_parse ~filename str =
231
- lexbuf_from_string ~filename str |> Parse. implementation
232
-
233
222
module ResDriver = struct
234
223
(* For now we are basically overriding functionality from Res_driver *)
235
224
open Res_driver
@@ -367,8 +356,6 @@ module Compile = struct
367
356
| Typetexp. Error _
368
357
| Typecore. Error _
369
358
| Typemod. Error _ -> " type_error"
370
- | Lexer. Error _
371
- | Syntaxerr. Error _ -> " syntax_error"
372
359
| _ -> " other_error"
373
360
in
374
361
let full_msg =
@@ -473,10 +460,7 @@ module Compile = struct
473
460
Warnings. parse_options false warn_flags;
474
461
let filename = get_filename ~lang config.filename in
475
462
let modulename = " Playground" in
476
- let impl = match lang with
477
- | Lang. OCaml -> ocaml_parse ~filename
478
- | Res -> rescript_parse ~filename
479
- in
463
+ let impl = rescript_parse ~filename in
480
464
Clflags. open_modules := open_modules;
481
465
(* let env = !Toploop.toplevel_env in *)
482
466
(* Res_compmisc.init_path (); *)
@@ -529,19 +513,6 @@ module Compile = struct
529
513
let filename = get_filename ~lang: from filename in
530
514
try
531
515
let code = match (from, to_) with
532
- | (OCaml, Res) ->
533
- let structure =
534
- src
535
- |> lexbuf_from_string ~filename
536
- |> Parse. implementation
537
- in
538
- Res_printer. print_implementation ~width: 80 structure ~comments: []
539
- | (Res, OCaml) ->
540
- let (structure, _) =
541
- ResDriver. parse_implementation ~for_printer: false ~sourcefile: filename ~src
542
- in
543
- Pprintast. structure Format. str_formatter structure;
544
- Format. flush_str_formatter ()
545
516
| (Res, Res) ->
546
517
(* Essentially pretty printing.
547
518
* IMPORTANT: we need forPrinter:true when parsing code here,
@@ -550,7 +521,6 @@ module Compile = struct
550
521
ResDriver. parse_implementation ~for_printer: true ~sourcefile: filename ~src
551
522
in
552
523
Res_printer. print_implementation ~width: 80 structure ~comments
553
- | (OCaml, OCaml) -> src
554
524
in
555
525
Js.Unsafe. (obj [|
556
526
" code" , inject @@ Js. string code;
@@ -571,7 +541,6 @@ let () =
571
541
572
542
module Export = struct
573
543
let make_compiler ~config ~lang =
574
- let open Lang in
575
544
let open Js.Unsafe in
576
545
let base_attrs =
577
546
[|" compile" ,
@@ -581,24 +550,16 @@ module Export = struct
581
550
(Compile. implementation ~config ~lang (Js. to_string code)));
582
551
" version" ,
583
552
inject @@
584
- Js. string
585
- (match lang with
586
- | Res -> Bs_version. version
587
- | OCaml -> Sys. ocaml_version);
553
+ Js. string Bs_version. version;
588
554
|] in
589
555
let attrs =
590
- if lang != OCaml then
591
- Array. append base_attrs [|
592
- (" format" ,
593
- inject @@
594
- Js. wrap_meth_callback
595
- (fun _ code ->
596
- (match lang with
597
- | OCaml -> ErrorRet. make_unexpected_error (" OCaml pretty printing not supported" )
598
- | _ -> Compile. syntax_format ?filename:config.filename ~from: lang ~to_: lang (Js. to_string code))))
599
- |]
600
- else
601
- base_attrs
556
+ Array. append base_attrs [|
557
+ (" format" ,
558
+ inject @@
559
+ Js. wrap_meth_callback
560
+ (fun _ code ->
561
+ (Compile. syntax_format ?filename:config.filename ~from:lang ~to_:lang (Js.to_string code ))))
562
+ |]
602
563
in
603
564
obj attrs
604
565
@@ -639,8 +600,6 @@ module Export = struct
639
600
Js.Unsafe. (obj [|
640
601
" version" ,
641
602
inject @@ Js. string Bs_version. version;
642
- " ocaml" ,
643
- inject @@ make_compiler ~config ~lang: OCaml ;
644
603
" rescript" ,
645
604
inject @@ make_compiler ~config ~lang: Res ;
646
605
" convertSyntax" ,
0 commit comments