mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Restore full expression printing when --debug is set
This commit is contained in:
parent
89e90271c1
commit
98f712365e
@ -635,6 +635,7 @@ let run_inline_tests
|
|||||||
not (String.starts_with ~prefix:"OCAMLRUNPARAM=" s))
|
not (String.starts_with ~prefix:"OCAMLRUNPARAM=" s))
|
||||||
|> Seq.cons "CATALA_OUT=-"
|
|> Seq.cons "CATALA_OUT=-"
|
||||||
|> Seq.cons "CATALA_COLOR=never"
|
|> Seq.cons "CATALA_COLOR=never"
|
||||||
|
|> Seq.cons "CATALA_PLUGINS="
|
||||||
|> Array.of_seq
|
|> Array.of_seq
|
||||||
in
|
in
|
||||||
let pid =
|
let pid =
|
||||||
|
@ -183,7 +183,7 @@ module Flags = struct
|
|||||||
"_build" / "default" / "compiler" / "plugins";
|
"_build" / "default" / "compiler" / "plugins";
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
value & opt_all dir default & info ["plugin-dir"] ~docv:"DIR" ~env ~doc
|
value & opt_all string default & info ["plugin-dir"] ~docv:"DIR" ~env ~doc
|
||||||
|
|
||||||
let disable_warnings =
|
let disable_warnings =
|
||||||
value
|
value
|
||||||
|
@ -553,7 +553,8 @@ module Commands = struct
|
|||||||
List.iter
|
List.iter
|
||||||
(fun ((var, _), result) ->
|
(fun ((var, _), result) ->
|
||||||
Message.emit_result "@[<hov 2>%s@ =@ %a@]" var
|
Message.emit_result "@[<hov 2>%s@ =@ %a@]" var
|
||||||
(Print.UserFacing.value (get_lang options options.input_file))
|
(if options.Cli.debug then Print.expr ~debug:false ()
|
||||||
|
else Print.UserFacing.value (get_lang options options.input_file))
|
||||||
result)
|
result)
|
||||||
results
|
results
|
||||||
|
|
||||||
@ -861,11 +862,13 @@ let main () =
|
|||||||
in
|
in
|
||||||
List.iter
|
List.iter
|
||||||
(fun d ->
|
(fun d ->
|
||||||
match Sys.is_directory d with
|
if d = "" then ()
|
||||||
| true -> Plugin.load_dir d
|
else
|
||||||
| false -> Message.emit_debug "Could not read plugin directory %s" d
|
match Sys.is_directory d with
|
||||||
| exception Sys_error _ ->
|
| true -> Plugin.load_dir d
|
||||||
Message.emit_debug "Could not read plugin directory %s" d)
|
| false -> Message.emit_debug "Could not read plugin directory %s" d
|
||||||
|
| exception Sys_error _ ->
|
||||||
|
Message.emit_debug "Could not read plugin directory %s" d)
|
||||||
plugins_dirs;
|
plugins_dirs;
|
||||||
Dynlink.allow_only ["Runtime_ocaml__Runtime"];
|
Dynlink.allow_only ["Runtime_ocaml__Runtime"];
|
||||||
(* We may use dynlink again, but only for runtime modules: no plugin
|
(* We may use dynlink again, but only for runtime modules: no plugin
|
||||||
|
@ -954,7 +954,8 @@ module UserFacing = struct
|
|||||||
if Z.equal n Z.zero then 0 else 1 + ndigits (Z.div n (Z.of_int 10))
|
if Z.equal n Z.zero then 0 else 1 + ndigits (Z.div n (Z.of_int 10))
|
||||||
in
|
in
|
||||||
aux 0
|
aux 0
|
||||||
(if Z.equal int_part Z.zero then None else Some (Cli.globals.max_prec_digits - ndigits int_part))
|
(if Z.equal int_part Z.zero then None
|
||||||
|
else Some (Cli.globals.max_prec_digits - ndigits int_part))
|
||||||
rem
|
rem
|
||||||
(* It would be nice to print ratios as % but that's impossible to guess.
|
(* It would be nice to print ratios as % but that's impossible to guess.
|
||||||
Trying would lead to inconsistencies where some comparable numbers are in %
|
Trying would lead to inconsistencies where some comparable numbers are in %
|
||||||
|
@ -17,7 +17,18 @@ scope RentComputation:
|
|||||||
```
|
```
|
||||||
|
|
||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -t -s HousingComputation
|
$ catala Interpret -t -s HousingComputation --debug
|
||||||
|
[DEBUG] Collecting rules...
|
||||||
|
[DEBUG] Reading files...
|
||||||
|
[DEBUG] Parsing tests/test_scope/good/scope_call3.catala_en
|
||||||
|
[DEBUG] Name resolution...
|
||||||
|
[DEBUG] Desugaring...
|
||||||
|
[DEBUG] Disambiguating...
|
||||||
|
[DEBUG] Linting...
|
||||||
|
[DEBUG] Typechecking...
|
||||||
|
[DEBUG] Translating to default calculus...
|
||||||
|
[DEBUG] Typechecking again...
|
||||||
|
[DEBUG] Starting interpretation...
|
||||||
[LOG] ≔ HousingComputation.f: <function>
|
[LOG] ≔ HousingComputation.f: <function>
|
||||||
[LOG] ☛ Definition applied:
|
[LOG] ☛ Definition applied:
|
||||||
┌─⯈ tests/test_scope/good/scope_call3.catala_en:8.14-8.20:
|
┌─⯈ tests/test_scope/good/scope_call3.catala_en:8.14-8.20:
|
||||||
@ -68,7 +79,30 @@ $ catala Interpret -t -s HousingComputation
|
|||||||
[LOG] ≔ HousingComputation.f.output: 3
|
[LOG] ≔ HousingComputation.f.output: 3
|
||||||
[LOG] ← HousingComputation.f
|
[LOG] ← HousingComputation.f
|
||||||
[LOG] ≔ HousingComputation.result: 3
|
[LOG] ≔ HousingComputation.result: 3
|
||||||
|
[DEBUG] End of interpretation
|
||||||
[RESULT] Computation successful! Results:
|
[RESULT] Computation successful! Results:
|
||||||
[RESULT] f = <function>
|
[RESULT]
|
||||||
|
f = λ (x: integer) →
|
||||||
|
error_empty
|
||||||
|
⟨true
|
||||||
|
⊢ (let result : RentComputation =
|
||||||
|
(λ (RentComputation_in: RentComputation_in) →
|
||||||
|
let g : integer → integer =
|
||||||
|
λ (x1: integer) →
|
||||||
|
error_empty ⟨true ⊢ x1 + 1⟩
|
||||||
|
in
|
||||||
|
let f : integer → integer =
|
||||||
|
λ (x1: integer) →
|
||||||
|
error_empty ⟨true ⊢ g (x1 + 1)⟩
|
||||||
|
in
|
||||||
|
{ RentComputation f = f; })
|
||||||
|
{RentComputation_in}
|
||||||
|
in
|
||||||
|
let result1 : RentComputation =
|
||||||
|
{ RentComputation f = λ (param0: integer) → result.f param0; }
|
||||||
|
in
|
||||||
|
if true then result1 else result1).
|
||||||
|
f
|
||||||
|
x⟩
|
||||||
[RESULT] result = 3
|
[RESULT] result = 3
|
||||||
```
|
```
|
||||||
|
@ -23,15 +23,70 @@ scope RentComputation:
|
|||||||
|
|
||||||
|
|
||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret -s RentComputation
|
$ catala Interpret -s RentComputation --debug
|
||||||
|
[DEBUG] Collecting rules...
|
||||||
|
[DEBUG] Reading files...
|
||||||
|
[DEBUG] Parsing tests/test_scope/good/scope_call4.catala_en
|
||||||
|
[DEBUG] Name resolution...
|
||||||
|
[DEBUG] Desugaring...
|
||||||
|
[DEBUG] Disambiguating...
|
||||||
|
[DEBUG] Linting...
|
||||||
|
[DEBUG] Typechecking...
|
||||||
|
[DEBUG] Translating to default calculus...
|
||||||
|
[DEBUG] Typechecking again...
|
||||||
|
[DEBUG] Starting interpretation...
|
||||||
|
[DEBUG] End of interpretation
|
||||||
[RESULT] Computation successful! Results:
|
[RESULT] Computation successful! Results:
|
||||||
[RESULT] f1 = <function>
|
[RESULT]
|
||||||
[RESULT] f2 = <function>
|
f1 = λ (x: integer) →
|
||||||
|
error_empty ⟨true ⊢ let x1 : integer = x + 1 in
|
||||||
|
error_empty ⟨true ⊢ x1 + 1⟩⟩
|
||||||
|
[RESULT]
|
||||||
|
f2 = λ (x: integer) →
|
||||||
|
error_empty ⟨true ⊢ let x1 : integer = x + 1 in
|
||||||
|
error_empty ⟨true ⊢ x1 + 1⟩⟩
|
||||||
```
|
```
|
||||||
|
|
||||||
```catala-test-inline
|
```catala-test-inline
|
||||||
$ catala Interpret_Lcalc -s RentComputation --avoid_exceptions --optimize
|
$ catala Interpret_Lcalc -s RentComputation --avoid_exceptions --optimize --debug
|
||||||
|
[DEBUG] Collecting rules...
|
||||||
|
[DEBUG] Reading files...
|
||||||
|
[DEBUG] Parsing tests/test_scope/good/scope_call4.catala_en
|
||||||
|
[DEBUG] Name resolution...
|
||||||
|
[DEBUG] Desugaring...
|
||||||
|
[DEBUG] Disambiguating...
|
||||||
|
[DEBUG] Linting...
|
||||||
|
[DEBUG] Typechecking...
|
||||||
|
[DEBUG] Translating to default calculus...
|
||||||
|
[DEBUG] Optimizing default calculus...
|
||||||
|
[DEBUG] Typechecking again...
|
||||||
|
[DEBUG] Compiling program into lambda calculus...
|
||||||
|
[DEBUG] Optimizing lambda calculus...
|
||||||
|
[DEBUG] Starting interpretation...
|
||||||
|
[DEBUG] End of interpretation
|
||||||
[RESULT] Computation successful! Results:
|
[RESULT] Computation successful! Results:
|
||||||
[RESULT] f1 = ESome <function>
|
[RESULT]
|
||||||
[RESULT] f2 = ESome <function>
|
f1 =
|
||||||
|
ESome
|
||||||
|
(λ (x: integer) →
|
||||||
|
ESome
|
||||||
|
match
|
||||||
|
(match (ESome (λ (x1: integer) → ESome (x1 + 1))) with
|
||||||
|
| ENone _ → ENone _
|
||||||
|
| ESome g → g (x + 1))
|
||||||
|
with
|
||||||
|
| ENone _ → raise NoValueProvided
|
||||||
|
| ESome f1 → f1)
|
||||||
|
[RESULT]
|
||||||
|
f2 =
|
||||||
|
ESome
|
||||||
|
(λ (x: integer) →
|
||||||
|
ESome
|
||||||
|
match
|
||||||
|
(match (ESome (λ (x1: integer) → ESome (x1 + 1))) with
|
||||||
|
| ENone _ → ENone _
|
||||||
|
| ESome g → g (x + 1))
|
||||||
|
with
|
||||||
|
| ENone _ → raise NoValueProvided
|
||||||
|
| ESome f2 → f2)
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user