From 8047e98124da2679073ab8df15f90114a0a6cd4c Mon Sep 17 00:00:00 2001 From: Christian Rinderknecht Date: Mon, 27 Jan 2020 16:36:04 +0100 Subject: [PATCH] WIP: Refactoring of the front-end. --- src/passes/1-parser/pascaligo.ml | 11 ++++++----- src/passes/1-parser/wrapper.ml | 5 ++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/passes/1-parser/pascaligo.ml b/src/passes/1-parser/pascaligo.ml index 4d982fe78..4ca440d7e 100644 --- a/src/passes/1-parser/pascaligo.ml +++ b/src/passes/1-parser/pascaligo.ml @@ -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 diff --git a/src/passes/1-parser/wrapper.ml b/src/passes/1-parser/wrapper.ml index 665933466..9b36b4b2c 100644 --- a/src/passes/1-parser/wrapper.ml +++ b/src/passes/1-parser/wrapper.ml @@ -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 [] -> ""