Skip to content

Commit 66803b9

Browse files
committed
Remove ml support from playground.
1 parent 5f6df5e commit 66803b9

File tree

1 file changed

+10
-51
lines changed

1 file changed

+10
-51
lines changed

jscomp/jsoo/jsoo_playground_main.ml

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,13 @@ let export (field : string) v =
6060
;;
6161

6262
module Lang = struct
63-
type t = OCaml | Res
63+
type t = Res
6464

6565
let from_string t = match t with
66-
| "ocaml" | "ml" -> Some OCaml
6766
| "res" -> Some Res
6867
| _ -> None
6968

7069
let to_string t = match t with
71-
| OCaml -> "ml"
7270
| Res -> "res"
7371
end
7472

@@ -221,15 +219,6 @@ let get_filename ~(lang: Lang.t) opt =
221219
| Some fname -> fname
222220
| None -> BundleConfig.default_filename lang
223221

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-
233222
module ResDriver = struct
234223
(* For now we are basically overriding functionality from Res_driver *)
235224
open Res_driver
@@ -367,8 +356,6 @@ module Compile = struct
367356
| Typetexp.Error _
368357
| Typecore.Error _
369358
| Typemod.Error _ -> "type_error"
370-
| Lexer.Error _
371-
| Syntaxerr.Error _ -> "syntax_error"
372359
| _ -> "other_error"
373360
in
374361
let full_msg =
@@ -473,10 +460,7 @@ module Compile = struct
473460
Warnings.parse_options false warn_flags;
474461
let filename = get_filename ~lang config.filename in
475462
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
480464
Clflags.open_modules := open_modules;
481465
(* let env = !Toploop.toplevel_env in *)
482466
(* Res_compmisc.init_path (); *)
@@ -529,19 +513,6 @@ module Compile = struct
529513
let filename = get_filename ~lang:from filename in
530514
try
531515
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 ()
545516
| (Res, Res) ->
546517
(* Essentially pretty printing.
547518
* IMPORTANT: we need forPrinter:true when parsing code here,
@@ -550,7 +521,6 @@ module Compile = struct
550521
ResDriver.parse_implementation ~for_printer:true ~sourcefile:filename ~src
551522
in
552523
Res_printer.print_implementation ~width:80 structure ~comments
553-
| (OCaml, OCaml) -> src
554524
in
555525
Js.Unsafe.(obj [|
556526
"code", inject @@ Js.string code;
@@ -571,7 +541,6 @@ let () =
571541

572542
module Export = struct
573543
let make_compiler ~config ~lang =
574-
let open Lang in
575544
let open Js.Unsafe in
576545
let base_attrs =
577546
[|"compile",
@@ -581,24 +550,16 @@ module Export = struct
581550
(Compile.implementation ~config ~lang (Js.to_string code)));
582551
"version",
583552
inject @@
584-
Js.string
585-
(match lang with
586-
| Res -> Bs_version.version
587-
| OCaml -> Sys.ocaml_version);
553+
Js.string Bs_version.version;
588554
|] in
589555
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+
|]
602563
in
603564
obj attrs
604565

@@ -639,8 +600,6 @@ module Export = struct
639600
Js.Unsafe.(obj [|
640601
"version",
641602
inject @@ Js.string Bs_version.version;
642-
"ocaml",
643-
inject @@ make_compiler ~config ~lang:OCaml;
644603
"rescript",
645604
inject @@ make_compiler ~config ~lang:Res;
646605
"convertSyntax",

0 commit comments

Comments
 (0)