Skip to content

Report error in Reason syntax (take 2) #1880

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

Merged
merged 2 commits into from
Aug 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions jscomp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ OCAML_SRC_TOOLS=../vendor/ocaml/tools

print-% : ; @echo $* = $($*)

INCLUDES= -I +compiler-libs -I stubs -I ext -I common -I syntax -I depends -I core -I bsb -I ounit -I ounit_tests -I super_errors
INCLUDES= -I +compiler-libs -I stubs -I ext -I common -I syntax -I depends -I core -I bsb -I ounit -I ounit_tests -I super_errors -I reason_outcome_printer

.mli.cmi:
$(NATIVE) $(INCLUDES) $(COMPFLAGS) -c $<
Expand Down Expand Up @@ -347,10 +347,12 @@ BSB_SRCS= bsb_config\
bsb_templates\
bsb_init
SUPER_ERRORS_SRCS=super_misc super_warnings super_typecore super_typetexp super_location super_main
REASON_OUTCOME_PRINTER_SRCS=tweaked_reason_oprint reason_outcome_printer_main

BSB_CMXS=$(addprefix bsb/, $(addsuffix .cmx, $(BSB_SRCS)))
BSB_CMOS=$(addprefix bsb/, $(addsuffix .cmo, $(BSB_SRCS)))
SUPER_ERRORS_CMXS=$(addprefix super_errors/, $(addsuffix .cmx, $(SUPER_ERRORS_SRCS)))
REASON_OUTCOME_PRINTER_CMXS=$(addprefix reason_outcome_printer/, $(addsuffix .cmx, $(REASON_OUTCOME_PRINTER_SRCS)))
MAIN_SRCS= jsgen_main jscmj_main bsb/bsb_main bsb/bsb_helper_main
MAIN_CMXS=$(addsuffix .cmx, $(MAIN_SRCS))

Expand All @@ -377,8 +379,12 @@ super.cmxa:$(SUPER_ERRORS_CMXS)
ocamlopt.opt -a $^ -o $@
super.cma:$(SUPER_ERRORS_CMOS)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not defined btw

ocamlc.opt -a $^ -o $@
reason_outcome_printer.cmxa:$(REASON_OUTCOME_PRINTER_CMXS)
ocamlopt.opt -a $^ -o $@
reason_outcome_printer.cma:$(REASON_OUTCOME_PRINTER_CMOS)
ocamlc.opt -a $^ -o $@

check: $(EXT_CMXS) $(COMMON_CMXS) $(SYNTAX_CMXS) $(DEPENDS_CMXS) $(CORE_CMXS) $(BSB_CMXS) $(OTHER_CORE_CMXS) $(MAIN_CMXS) $(SUPER_ERRORS_CMXS) $(OUNIT_CMXS) $(OUNIT_TESTS_CMXS)
check: $(EXT_CMXS) $(COMMON_CMXS) $(SYNTAX_CMXS) $(DEPENDS_CMXS) $(CORE_CMXS) $(BSB_CMXS) $(OTHER_CORE_CMXS) $(MAIN_CMXS) $(SUPER_ERRORS_CMXS) $(REASON_OUTCOME_PRINTER_CMXS) $(OUNIT_CMXS) $(OUNIT_TESTS_CMXS)

bin/bsb.exe: bs_hash.cmxa ext.cmxa common.cmxa bsb.cmxa bsb/bsb_main.cmx
$(NATIVE) -I +compiler-libs -g ocamlcommon.cmxa unix.cmxa str.cmxa $^ -o $@
Expand All @@ -389,7 +395,7 @@ bin/bsb_helper.exe: bs_hash.cmxa ext.cmxa common.cmxa bsb.cmxa bsb/bsb_helper_m
# bin/bsc: ext.cmxa common.cmxa depends.cmxa syntax.cmxa core.cmxa
# $(NATIVE) -g -linkall -I +compiler-libs ocamlcommon.cmxa $^ -o $@

bin/bsc.exe: bs_hash.cmxa ext.cmxa common.cmxa syntax.cmxa depends.cmxa core.cmxa super.cmxa core/js_main.cmx
bin/bsc.exe: bs_hash.cmxa ext.cmxa common.cmxa syntax.cmxa depends.cmxa core.cmxa super.cmxa reason_outcome_printer.cmxa core/js_main.cmx
@echo "Linking"
$(NATIVE) -g -linkall -I +compiler-libs ocamlcommon.cmxa $^ -o $@

Expand All @@ -413,7 +419,7 @@ bin/jsgen.exe:bs_hash.cmxa ext.cmxa jsgen_main.cmx


depend:
$(CAMLDEP) -absname -native -I stubs -I ext -I common -I syntax -I depends -I core -I ounit -I ounit_tests -I bsb -I super_errors \
$(CAMLDEP) -absname -native -I stubs -I ext -I common -I syntax -I depends -I core -I ounit -I ounit_tests -I bsb -I super_errors -I reason_outcome_printer \
$(addprefix stubs/, $(addsuffix .ml, $(STUB_SRCS))) \
$(addprefix stubs/, $(addsuffix .mli, $(STUB_SRCS))) \
$(addprefix ext/, $(addsuffix .ml, $(EXT_SRCS))) \
Expand All @@ -432,6 +438,8 @@ depend:
$(addprefix ounit/, $(addsuffix .ml, $(OUNIT_SRCS))) \
$(addprefix super_errors/, $(addsuffix .ml, $(SUPER_ERRORS_SRCS))) \
$(addprefix super_errors/, $(addsuffix .mli, $(SUPER_ERRORS_SRCS))) \
$(addprefix reason_outcome_printer/, $(addsuffix .ml, $(REASON_OUTCOME_PRINTER_SRCS))) \
$(addprefix reason_outcome_printer/, $(addsuffix .mli, $(REASON_OUTCOME_PRINTER_SRCS))) \
$(addprefix ounit_tests/, $(addsuffix .mli, $(OUNIT_TESTS_SRCS))) \
$(addprefix ounit_tests/, $(addsuffix .ml, $(OUNIT_TESTS_SRCS))) \
bsb/*.ml bsb/*.mli *.ml *.mli > all.depend
Expand Down Expand Up @@ -498,7 +506,7 @@ bin/bsppx.ml:./bin/bspack.exe
$< -U BS_DEBUG -bs-MD -module-alias Config=ConfigDummy -I bin -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I stubs -I common -I ext -I syntax -I core -bs-main Bsppx_main -o $@

bin/whole_compiler.ml:./bin/bspack.exe
$< -U BS_DEBUG -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Js_main -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I $(OCAML_SRC_TYPING) -I $(OCAML_SRC_BYTECOMP) -I $(OCAML_SRC_DRIVER)/ -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors
$< -U BS_DEBUG -bs-MD -prelude-str 'module Config = Config_whole_compiler' -bs-exclude-I config -o $@ -bs-main Js_main -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I $(OCAML_SRC_TYPING) -I $(OCAML_SRC_BYTECOMP) -I $(OCAML_SRC_DRIVER)/ -I stubs -I ext -I syntax -I depends -I common -I core -I super_errors -I reason_outcome_printer

bin/bsdep.ml:./bin/bspack.exe
$< -D BS_OCAMLDEP=true -U BS_DEBUG -bs-MD -module-alias Config=ConfigDummy -I bin -I $(OCAML_SRC_UTILS) -I $(OCAML_SRC_PARSING) -I $(OCAML_SRC_DRIVER) -I $(OCAML_SRC_TOOLS) -I common -I ext -I syntax -I depends -I core -I stubs -bs-main Ocamldep -o $@
Expand Down
7 changes: 6 additions & 1 deletion jscomp/core/js_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ let buckle_script_flags =
" Better error message combined with other tools "
)
::
("-bs-print-errors-in-reason-syntax",
Arg.Unit Reason_outcome_printer_main.setup,
" Print compiler errors in Reason syntax"
)
::
("-bs-no-implicit-include", Arg.Set Clflags.no_implicit_current_dir
, " Don't include current dir implicitly")
::
Expand Down Expand Up @@ -250,4 +255,4 @@ let _ =
begin
Location.report_exception ppf x;
exit 2
end
end
1 change: 1 addition & 0 deletions jscomp/reason_outcome_printer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello! This is the subdirectory for making BuckleScript's compiler errors output in Reason syntax. For more information on how it's implemented, please see the header comment in the file itself.
10 changes: 10 additions & 0 deletions jscomp/reason_outcome_printer/reason_outcome_printer_main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(* This is used by js_main.ml *)
let setup () =
Oprint.out_value := Tweaked_reason_oprint.print_out_value;
Oprint.out_type := Tweaked_reason_oprint.print_out_type;
Oprint.out_class_type := Tweaked_reason_oprint.print_out_class_type;
Oprint.out_module_type := Tweaked_reason_oprint.print_out_module_type;
Oprint.out_sig_item := Tweaked_reason_oprint.print_out_sig_item;
Oprint.out_signature := Tweaked_reason_oprint.print_out_signature;
Oprint.out_type_extension := Tweaked_reason_oprint.print_out_type_extension;
Oprint.out_phrase := Tweaked_reason_oprint.print_out_phrase
Loading