diff options
author | Chimrod <> | 2023-09-27 13:31:14 +0200 |
---|---|---|
committer | Chimrod <> | 2023-09-29 10:00:21 +0200 |
commit | 40f7b4c7398db2b832b71e3dfb8afb53116fad51 (patch) | |
tree | fc36e0fe685a3c1bc36a6d8821fbdd369d75a40c /test | |
parent | 46fd5a31d2e07b9df10d07dd900b529aca06a795 (diff) |
Switched to sedlex instead of ocamllex
Diffstat (limited to 'test')
-rw-r--r-- | test/dune | 1 | ||||
-rw-r--r-- | test/qsp_parser_test.ml | 10 |
2 files changed, 9 insertions, 2 deletions
@@ -2,6 +2,7 @@ (name qsp_parser_test) (libraries alcotest + sedlex qparser qsp_syntax fmt diff --git a/test/qsp_parser_test.ml b/test/qsp_parser_test.ml index b833fe5..6bf249d 100644 --- a/test/qsp_parser_test.ml +++ b/test/qsp_parser_test.ml @@ -7,10 +7,16 @@ let _position = (Lexing.dummy_pos, Lexing.dummy_pos) type 'a location = 'a * 'a Ast.statement list [@@deriving eq, show] +(** Run the parser with the given expression and return the result *) let parse : string -> T.pos location = fun content -> - let lexing = Lexing.from_string content in - Parser.main Qparser.Lexer.token lexing + let lexing = Sedlexing.Latin1.from_string content in + + match Qparser.Analyzer.parse (module Qsp_syntax.Tree) lexing with + | Ok e -> e + | Error e -> + let msg = Format.asprintf "%a" Qparser.Analyzer.format_error e in + raise (Failure msg) let location : T.pos location Alcotest.testable = let equal = equal_location (fun _ _ -> true) in |