Closed michallepicki closed 3 years ago
~Hmm I think this adds a 0 when it's not necessary as well. I'll fix it sometime but~ (edit: fixed) the question whether this is the correct place to fix it is still valid :)
Alternatively I could fix this here I think ?
@michallepicki yes! the second place feels a lot cleaner since its where all the OCaml->Erlang specific conversions are made. The printer should just assume the Erlang AST is valid.
Additionally, we could add a Erlang.Ast_helpers.Const.float_of_string
function to do this parsing.
@ostera There's this helper already: https://github.com/AbstractMachinesLab/caramel/blob/main/erlang/src/erl_ast_helper.ml#L54 - should I modify it instead of adding a new function? It is already being called in the Fun module linked before ( https://github.com/AbstractMachinesLab/caramel/blob/main/caramel/compiler/ocaml_to_erlang/fun.ml#L14 )
@michallepicki yup! I think we can use that one as well.
One last alternative would be to start implementing the AST invariants module to return an error if the float's are wrong.
Like, the OCaml_to_Erlang module should be responsible of formatting the floats right, the AST modules should help you verify that it is indeed right.
@ostera I cannot request a review on the PR but it should be ready to go once CI passes. I added a small test for this kind of float literals.
closes #55
(not sure if changing the
erl_printer
is the correct fix so I'm happy to change if it's not)