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 --- bin/qsp_parser.ml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'bin') diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml index 1d846e0..3980ad5 100644 --- a/bin/qsp_parser.ml +++ b/bin/qsp_parser.ml @@ -41,12 +41,9 @@ let filter_report : filters -> Report.t list -> Report.t -> Report.t list = (** Read the source file until getting a report (the whole location has been read properly), or until the first syntax error. *) -let parse_location : - (module Qparser.Lexer.Encoding) -> Sedlexing.lexbuf -> filters -> unit = - fun encoding lexbuf filters -> - let result = - Qparser.Analyzer.parse (module Qsp_syntax.Type_of) encoding lexbuf - in +let parse_location : Sedlexing.lexbuf -> filters -> unit = + fun lexbuf filters -> + let result = Qparser.Analyzer.parse (module Qsp_syntax.Type_of) lexbuf in let result = Result.map @@ -78,23 +75,17 @@ let () = let ic = Stdlib.open_in file_name in (*let lexer = Lexing.from_channel ~with_positions:true ic in*) - let lexer, mod_ = + let lexer = match Filename.extension file_name with - | ".qsrc" -> - ( Sedlexing.Utf8.from_channel ic, - (module Sedlexing.Utf8 : Qparser.Lexer.Encoding) ) - | ".txt" -> - ( Sedlexing.Utf16.from_channel ic (Some Little_endian), - (module struct - let lexeme lexbuf = Sedlexing.Utf8.lexeme lexbuf - end : Qparser.Lexer.Encoding) ) + | ".qsrc" -> Sedlexing.Utf8.from_channel ic + | ".txt" -> Sedlexing.Utf16.from_channel ic (Some Little_endian) | _ -> raise (Failure "unknown extension") in let () = try while true do - parse_location mod_ lexer filters + parse_location lexer filters done with Qparser.Lexer.EOF -> () in -- cgit v1.2.3