aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/qsp_parser.ml20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/qsp_parser.ml b/bin/qsp_parser.ml
index f2b21f9..0459fe2 100644
--- a/bin/qsp_parser.ml
+++ b/bin/qsp_parser.ml
@@ -43,14 +43,22 @@ let () =
let file_name = List.hd file_names in
let ic = Stdlib.open_in file_name in
+
(*let lexer = Lexing.from_channel ~with_positions:true ic in*)
- let lexer = Sedlexing.Utf8.from_channel ic in
- let result =
- Qparser.Analyzer.parse
- (module Qsp_syntax.Type_of)
- (module Sedlexing.Utf8)
- lexer
+ let lexer, mod_ =
+ 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.Utf16.lexeme lexbuf Little_endian true
+ end : Qparser.Lexer.Encoding) )
+ | _ -> raise (Failure "unknown extension")
in
+
+ let result = Qparser.Analyzer.parse (module Qsp_syntax.Type_of) mod_ lexer in
match result with
| Ok f -> (
let report = List.fold_left (f []) ~init:[] ~f:(filter_report filters) in