2019-09-10 15:19:15 +02:00
|
|
|
open Trace
|
2019-09-11 13:56:39 +02:00
|
|
|
open Helpers
|
|
|
|
|
|
|
|
let parse_file_program source_filename syntax =
|
|
|
|
let%bind syntax = syntax_to_variant syntax (Some source_filename) in
|
|
|
|
let%bind simplified = parsify syntax source_filename in
|
|
|
|
ok simplified
|
|
|
|
|
2019-09-19 01:34:37 +02:00
|
|
|
let compile_file_entry : string -> string -> s_syntax -> _ result =
|
2019-09-11 13:56:39 +02:00
|
|
|
fun source_filename entry_point syntax ->
|
|
|
|
let%bind simplified = parse_file_program source_filename syntax in
|
|
|
|
Of_simplified.compile_function_entry simplified entry_point
|
|
|
|
|
2019-09-19 01:34:37 +02:00
|
|
|
let compile_file_contract_entry : string -> string -> s_syntax -> _ result =
|
2019-09-18 18:49:33 +02:00
|
|
|
fun source_filename entry_point syntax ->
|
|
|
|
let%bind simplified = parse_file_program source_filename syntax in
|
2019-09-20 18:56:55 +02:00
|
|
|
let%bind compiled_contract = Of_simplified.compile_contract_entry simplified entry_point in
|
|
|
|
ok compiled_contract
|
2019-09-18 18:49:33 +02:00
|
|
|
|
2019-09-25 10:49:14 +02:00
|
|
|
let compile_expression_as_function : string -> s_syntax -> _ result =
|
|
|
|
fun expression syntax ->
|
|
|
|
let%bind syntax = syntax_to_variant syntax None in
|
2019-09-11 13:56:39 +02:00
|
|
|
let%bind simplified = parsify_expression syntax expression in
|
2019-09-25 10:49:14 +02:00
|
|
|
Of_simplified.compile_expression_as_function simplified
|
2019-09-15 13:12:19 +02:00
|
|
|
|
|
|
|
let type_file ?(debug_simplify = false) ?(debug_typed = false)
|
|
|
|
syntax (source_filename:string) : Ast_typed.program result =
|
|
|
|
let%bind syntax = syntax_to_variant syntax (Some source_filename) in
|
|
|
|
let%bind simpl = parsify syntax source_filename in
|
|
|
|
(if debug_simplify then
|
|
|
|
Format.(printf "Simplified : %a\n%!" Ast_simplified.PP.program simpl)
|
|
|
|
) ;
|
|
|
|
let%bind typed =
|
|
|
|
trace (simple_error "typing") @@
|
|
|
|
Typer.type_program simpl in
|
|
|
|
(if debug_typed then (
|
|
|
|
Format.(printf "Typed : %a\n%!" Ast_typed.PP.program typed)
|
|
|
|
)) ;
|
|
|
|
ok typed
|