diff options
Diffstat (limited to 'lib/analyzer.ml')
-rw-r--r-- | lib/analyzer.ml | 15 |
1 files changed, 8 insertions, 7 deletions
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) |