This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "Bar"
|
||||
|
|
@ -0,0 +1 @@
|
|||
let y = 56
|
||||
|
|
@ -0,0 +1 @@
|
|||
val y : int
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "Cppome"
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
(rule
|
||||
(copy copy-sources/pped.pp.re pped.re))
|
||||
|
||||
(rule
|
||||
(copy copy-sources/pped.rei.pp pped.rei))
|
||||
|
||||
(library
|
||||
(name rlib)
|
||||
(public_name rlib)
|
||||
(modules bar cppome foo hello pped)
|
||||
(lint
|
||||
(per_module
|
||||
((pps reasonppx -- -lint true)
|
||||
hello
|
||||
cppome)
|
||||
((action
|
||||
(run ./pp/reasononlypp.exe -lint %{input-file}))
|
||||
foo
|
||||
bar
|
||||
pped)))
|
||||
(preprocess
|
||||
(per_module
|
||||
((pps reasonppx)
|
||||
foo)
|
||||
((pps reasonppx -- -lint false)
|
||||
hello)
|
||||
((action
|
||||
(run ./pp/reasononlypp.exe %{input-file}))
|
||||
cppome))))
|
||||
|
||||
(executable
|
||||
(name rbin)
|
||||
(modules rbin)
|
||||
(lint
|
||||
(action
|
||||
(run ./pp/reasononlypp.exe -lint %{input-file})))
|
||||
(preprocess
|
||||
(action
|
||||
(run ./pp/reasononlypp.exe %{input-file})))
|
||||
(libraries rlib))
|
||||
|
||||
(alias
|
||||
(name install-file)
|
||||
(deps rlib.install)
|
||||
(action
|
||||
(echo "%{read:rlib.install}")))
|
||||
|
||||
(alias
|
||||
(name runtest)
|
||||
(deps
|
||||
(:< rbin.exe))
|
||||
(action
|
||||
(run %{<})))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.9)
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "Foo"
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1 @@
|
|||
let run () = print_endline "hello world"
|
||||
|
|
@ -0,0 +1 @@
|
|||
val run : unit -> unit
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(executable
|
||||
(name reasononlypp))
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
let lint = ref false
|
||||
let fname = ref None
|
||||
let usage =
|
||||
Printf.sprintf "%s [-lint] file" (Filename.basename Sys.executable_name)
|
||||
let anon s =
|
||||
match !fname with
|
||||
| None -> fname := Some s
|
||||
| Some _ -> raise (Arg.Bad "file must only be given once")
|
||||
|
||||
let is_ascii s =
|
||||
try
|
||||
for i=0 to String.length s - 1 do
|
||||
if Char.code (s.[i]) > 127 then raise Exit
|
||||
done;
|
||||
true
|
||||
with Exit ->
|
||||
false
|
||||
|
||||
let () =
|
||||
Arg.parse
|
||||
["-lint", Arg.Set lint, "lint instead of preprocessing"
|
||||
] anon usage;
|
||||
let fname =
|
||||
match !fname with
|
||||
| None -> raise (Arg.Bad "file must be provided")
|
||||
| Some f -> f in
|
||||
|
||||
if Filename.check_suffix fname ".re"
|
||||
|| Filename.check_suffix fname ".rei" then (
|
||||
if !lint && (Filename.check_suffix fname ".pp.re"
|
||||
|| Filename.check_suffix fname ".pp.rei") then (
|
||||
Format.eprintf "reason linter doesn't accept preprocessed file %s" fname;
|
||||
);
|
||||
let ch = open_in fname in
|
||||
let rec loop () =
|
||||
match input_line ch with
|
||||
| exception End_of_file -> ()
|
||||
| line when is_ascii line ->
|
||||
if not !lint then (
|
||||
print_endline line
|
||||
);
|
||||
loop ()
|
||||
| _ ->
|
||||
Format.eprintf "%s isn't source code@.%!" fname;
|
||||
exit 1
|
||||
in
|
||||
loop ();
|
||||
close_in ch;
|
||||
exit 0
|
||||
) else (
|
||||
Format.eprintf "%s is not a reason source@.%!" fname;
|
||||
exit 1
|
||||
)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
(library
|
||||
(name reasonppx)
|
||||
(wrapped false)
|
||||
(kind ppx_rewriter)
|
||||
(libraries ppxlib))
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
let lint = ref false
|
||||
|
||||
let () =
|
||||
Ppxlib.Driver.add_arg "-lint" (Arg.Bool (fun l -> lint := l)) ~doc:"";
|
||||
Ppxlib.Driver.register_transformation
|
||||
"reasonppx"
|
||||
~impl:(fun s ->
|
||||
if !lint then (
|
||||
exit 0
|
||||
) else (
|
||||
s
|
||||
)
|
||||
)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
open Rlib
|
||||
|
||||
let () =
|
||||
Cppome.run ();
|
||||
Hello.run ();
|
||||
Bar.run ();
|
||||
Foo.run ()
|
||||
;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
Tests for reason
|
||||
|
||||
Build and run a reason binary:
|
||||
|
||||
$ dune build @runtest
|
||||
Cppome
|
||||
hello world
|
||||
Bar
|
||||
Foo
|
||||
|
||||
We make sure to install reason source files:
|
||||
|
||||
$ dune build @install-file 2>&1 | grep ".re"
|
||||
"_build/install/default/lib/rlib/bar.re"
|
||||
"_build/install/default/lib/rlib/cppome.re"
|
||||
"_build/install/default/lib/rlib/cppome.rei"
|
||||
"_build/install/default/lib/rlib/foo.rei"
|
||||
"_build/install/default/lib/rlib/hello.re"
|
||||
"_build/install/default/lib/rlib/hello.rei"
|
||||
"_build/install/default/lib/rlib/pped.re"
|
||||
"_build/install/default/lib/rlib/pped.rei"
|
||||
|
||||
virtual libraries in reason
|
||||
$ PATH="_build/install/default/bin:$PATH" dune build --root vlib-impl @all
|
||||
Entering directory 'vlib-impl'
|
||||
Leaving directory 'vlib-impl'
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.7)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name ReproImpl)
|
||||
(public_name repro.lib-impl)
|
||||
(implements repro.lib))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(library
|
||||
(name Repro)
|
||||
(public_name repro.lib)
|
||||
(virtual_modules v))
|
||||
Loading…
Add table
Add a link
Reference in a new issue