From 5e0b521a2ccce4bd19cf5d08176616f760180c11 Mon Sep 17 00:00:00 2001 From: Chimrod <> Date: Fri, 29 Sep 2023 09:05:45 +0200 Subject: Made the lexer buffer abstract --- lib/analyzer.ml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/analyzer.ml') diff --git a/lib/analyzer.ml b/lib/analyzer.ml index a6f5e51..547b3da 100644 --- a/lib/analyzer.ml +++ b/lib/analyzer.ml @@ -5,18 +5,19 @@ *) let parse : (module Qsp_syntax.S.Analyzer with type Location.repr = 'a) -> - (module Encoding.S) -> Sedlexing.lexbuf -> ('a, Qsp_syntax.Report.t) Result.t = - fun (type a) (module S : Qsp_syntax.S.Analyzer with type Location.repr = a) - (module E : Encoding.S) -> + fun (type a) (module S : Qsp_syntax.S.Analyzer with type Location.repr = a) -> let module Parser = Parser.Make (S) in let module IncrementalParser = Interpreter.Interpreter (Parser.MenhirInterpreter) in fun lexbuf -> - IncrementalParser.of_lexbuf lexbuf - (Lexer.lexer (module E)) - Parser.Incremental.main + let l = Lexbuf.from_lexbuf lexbuf in + let lexer = Lexbuf.tokenize Lexer.token l in + + let init = Parser.Incremental.main (fst (Lexbuf.positions l)) in + + IncrementalParser.of_lexbuf lexer l init |> Result.map_error (fun e -> let message = match e.IncrementalParser.code with @@ -38,5 +39,5 @@ let parse : (* Discard the remaining file to read. The parser is now in a blank state, it does not make sense to keep feeding it with the new tokens. *) - Lexer.discard lexbuf; + Lexer.discard l; report) -- cgit v1.2.3