-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
playground: reason syntax and react ppx #602
Merged
Merged
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
0653696
playground: make jsoo_main compile
jchavarri bea1835
Merge branch 'main' into playground-1
jchavarri 6944289
playground: updates after merging main
jchavarri eb98362
Merge branch 'main' into playground-1
jchavarri 0809424
playground: use private melange comp libs
jchavarri 9cbe9c5
playground: pick up change in translmod
jchavarri ec1fbe3
playground: better error handling
jchavarri ba38c05
playground: remove hardcoded BS_BROWSER
jchavarri ca209c4
opam: add jsoo
jchavarri d1ce4ed
playground: update in-code comment
jchavarri 01c797b
playground: add new profile browser
jchavarri 4e64b6f
playground: build in ci
jchavarri b178930
Revert "playground: pick up change in translmod"
jchavarri 0137a6b
Merge branch 'main' into playground-1
jchavarri b9a2554
playground: add dev mode for faster builds
jchavarri 08be825
playground: apply ppxlib driver on structure
jchavarri b23d4f4
playground: add comment
jchavarri 5ef2d1f
Merge branch 'main' into playground-1
jchavarri 42b51ef
add parse/print funs, run reactjs ppx
jchavarri 24d0f07
dump without /./
jchavarri e05becc
Merge branch 'main' into playground-1
jchavarri 5f7c877
playground: fix errors after merging main
jchavarri dc56afc
Merge branch 'main' into playground-1
jchavarri 529df6a
fixes after merge
jchavarri abdb6ae
remove unneeded exposure of ppx_entry
jchavarri df0a373
remove d_browser
jchavarri 655102b
playground: update makefile with new paths
jchavarri ef574d0
add test for playground
jchavarri c4ad80d
playground: remove obsolete comment
jchavarri 1620cbc
playground: open melange_comp_libs in flags
jchavarri f478585
playground: add more tests
jchavarri 9329c87
playground: remove str_of_formatted
jchavarri fe2640f
Merge branch 'playground-1' into playground-2
jchavarri adb9bd2
playground: add re syntax test
jchavarri 68cc036
playground: add failing test with bs.deriving
jchavarri a255638
playground: fix test by replacing bs.deriving with deriving
jchavarri 22b299b
Revert "dump without /./"
jchavarri d864f73
remove ext_string usage
jchavarri d4c3146
Merge branch 'playground-1' into playground-2
jchavarri dd570f7
playground: fix hanging with "//" input
jchavarri fa67bf6
Merge branch 'main' into playground-2
jchavarri 9065ed0
playground: add test for melange ppx
jchavarri 1b89c2f
fix error
anmonteiro c216727
playground: update tests
jchavarri d9ced26
Merge branch 'main' into playground-2
jchavarri 5e9789c
update reason
anmonteiro a3e2a0e
Merge branch 'main' into playground-2
anmonteiro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,17 +23,7 @@ | |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) | ||
|
||
module Js = Jsoo_common.Js | ||
(** *) | ||
|
||
(* | ||
Error: | ||
* { | ||
* row: 12, | ||
* column: 2, //can be undefined | ||
* text: "Missing argument", | ||
* type: "error" // or "warning" or "info" | ||
* } | ||
*) | ||
let () = | ||
Bs_conditional_initial.setup_env (); | ||
Clflags.binary_annotations := false | ||
|
@@ -43,7 +33,12 @@ let error_of_exn e = | |
| Some (`Ok e) -> Some e | ||
| Some `Already_displayed | None -> None | ||
|
||
let implementation ~use_super_errors impl str : Js.Unsafe.obj = | ||
module Convert = | ||
Ppxlib_ast.Convert | ||
(Ppxlib_ast__.Versions.OCaml_414) | ||
(Ppxlib_ast__.Versions.OCaml_current) | ||
|
||
let compile impl str : Js.Unsafe.obj = | ||
let modulename = "Test" in | ||
(* let env = !Toploop.toplevel_env in *) | ||
(* Res_compmisc.init_path false; *) | ||
|
@@ -54,71 +49,65 @@ let implementation ~use_super_errors impl str : Js.Unsafe.obj = | |
(* Question ?? *) | ||
(* let finalenv = ref Env.empty in *) | ||
let types_signature = ref [] in | ||
if use_super_errors then ( | ||
Misc.Color.setup (Some Always); | ||
Lazy.force Super_main.setup); | ||
|
||
try | ||
Js_config.jsx_version := 3; | ||
(* default *) | ||
let ast = impl (Lexing.from_string str) in | ||
let ast = Ppx_entry.rewrite_implementation ast in | ||
let ast : Parsetree.structure = | ||
let ppxlib_ast : Ppxlib_ast__.Versions.OCaml_414.Ast.Parsetree.structure = | ||
Obj.magic (ast : Parsetree.structure) | ||
in | ||
let converted = | ||
Convert.copy_structure (Ppxlib.Driver.map_structure ppxlib_ast) | ||
in | ||
(Obj.magic converted : Parsetree.structure) | ||
in | ||
let typed_tree = | ||
let a, b, _, signature = | ||
let { Typedtree.structure; coercion; shape = _; signature }, _finalenv = | ||
Typemod.type_implementation_more modulename modulename modulename env | ||
ast | ||
in | ||
(* finalenv := c ; *) | ||
types_signature := signature; | ||
(a, b) | ||
(structure, coercion) | ||
in | ||
typed_tree |> Translmod.transl_implementation modulename | ||
|> (* Printlambda.lambda ppf *) fun { Lambda.code = lam } -> | ||
|> (* Printlambda.lambda ppf *) fun { Lambda.code = lam; _ } -> | ||
let buffer = Buffer.create 1000 in | ||
let () = | ||
Js_dump_program.pp_deps_program ~output_prefix:"" | ||
(* does not matter here *) NodeJS | ||
(Lam_compile_main.compile "" lam) | ||
~package_info:Js_packages_info.empty | ||
~output_info:{ Js_packages_info.module_system = NodeJS; suffix = Js } | ||
(Ext_pp.from_buffer buffer) | ||
(Lam_compile_main.compile "" lam) | ||
in | ||
let v = Buffer.contents buffer in | ||
Js.Unsafe.(obj [| ("js_code", inject @@ Js.string v) |]) | ||
(* Format.fprintf output_ppf {| { "js_code" : %S }|} v ) *) | ||
with e -> ( | ||
match error_of_exn e with | ||
| Some error -> | ||
Location.report_error Format.err_formatter error; | ||
Jsoo_common.mk_js_error error.loc error.msg | ||
| Some error -> Jsoo_common.mk_js_error error | ||
| None -> | ||
Js.Unsafe.( | ||
obj [| ("js_error_msg", inject @@ Js.string (Printexc.to_string e)) |])) | ||
|
||
let compile impl ~use_super_errors = implementation ~use_super_errors impl | ||
let export (field : string) v = Js.Unsafe.set Js.Unsafe.global field v | ||
|
||
(* To add a directory to the load path *) | ||
|
||
let dir_directory d = Config.load_path := d :: !Config.load_path | ||
let () = dir_directory "/static" | ||
let () = Load_path.add_dir "/static" | ||
|
||
let make_compiler name impl = | ||
export name | ||
let () = | ||
export "ocaml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps we should call this feel free to do in a future PR, I don't want to unblock this one further |
||
Js.Unsafe.( | ||
obj | ||
[| | ||
( "compile", | ||
inject | ||
@@ Js.wrap_meth_callback (fun _ code -> | ||
compile impl ~use_super_errors:false (Js.to_string code)) ); | ||
( "compile_super_errors", | ||
inject | ||
@@ Js.wrap_meth_callback (fun _ code -> | ||
compile impl ~use_super_errors:true (Js.to_string code)) ); | ||
("version", Js.Unsafe.inject (Js.string Bs_version.version)); | ||
compile Parse.implementation (Js.to_string code)) ); | ||
("version", inject @@ Js.string Melange_version.version); | ||
("parseRE", inject @@ Jsoo_common.Reason.parseRE); | ||
("parseML", inject @@ Jsoo_common.Reason.parseML); | ||
("printRE", inject @@ Jsoo_common.Reason.printRE); | ||
("printML", inject @@ Jsoo_common.Reason.printML); | ||
|]) | ||
|
||
let () = make_compiler "ocaml" Parse.implementation | ||
|
||
(* local variables: *) | ||
(* compile-command: "ocamlbuild -use-ocamlfind -pkg compiler-libs -no-hygiene driver.cmo" *) | ||
(* end: *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this reasonml/reason#2350, which was fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like. I have no idea why it's reappearing now, maybe because in playground case we don't have EOF?