WIP: Refactoring of the front-end.

This commit is contained in:
Christian Rinderknecht 2020-01-27 16:36:04 +01:00
parent fc3385389b
commit 8047e98124
2 changed files with 10 additions and 6 deletions

View File

@ -55,13 +55,12 @@ module Errors =
in Trace.error ~data:[] title message
end
let parse (module IO : IO) parser =
let module Unit = PreUnit (IO) in
let parse (module Unit : ParserUnit.S) parser =
let local_fail error =
Trace.fail
@@ Errors.generic
@@ Unit.format_error ~offsets:IO.options#offsets
IO.options#mode error in
@@ Unit.format_error ~offsets:Unit.IO.options#offsets
Unit.IO.options#mode error in
match parser () with
Stdlib.Ok semantic_value -> Trace.ok semantic_value
@ -121,7 +120,9 @@ let parse (module IO : IO) parser =
Hint: Change the name.\n",
None, invalid))
let parse_file source =
let parse_file :
string -> (Unit.Parser.ast, string Region.reg) Stdlib.result =
fun source ->
let module IO =
struct
let ext = PreIO.ext

View File

@ -6,7 +6,10 @@ module type IO =
val options : EvalOpt.options
end
let parse_file generic_error (module Unit : ParserUnit.S) parse =
let parse_file generic_error
(module Unit : ParserUnit.S)
(parse: unit -> (Unit.Parser.ast, string Region.reg) Stdlib.result)
: (Unit.Parser.ast, string Region.reg) Stdlib.result =
let lib_path =
match Unit.IO.options#libs with
[] -> ""