aboutsummaryrefslogtreecommitdiff
path: root/lib/qparser/analyzer.ml
diff options
context:
space:
mode:
authorChimrod <>2024-02-04 10:37:04 +0100
committerChimrod <>2024-02-08 14:12:45 +0100
commit6fd720c07e3e361932e01bfbdbe4637c8f610649 (patch)
tree26f983295d8674a08fc9367aaac820c0ace675bc /lib/qparser/analyzer.ml
parent35ef1827a216a1deb6d15f916ff197b0c75bc83e (diff)
Added a general context for each test
Diffstat (limited to 'lib/qparser/analyzer.ml')
-rw-r--r--lib/qparser/analyzer.ml19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/qparser/analyzer.ml b/lib/qparser/analyzer.ml
index e3a2774..6d09021 100644
--- a/lib/qparser/analyzer.ml
+++ b/lib/qparser/analyzer.ml
@@ -4,19 +4,25 @@
See [syntax/S]
*)
let parse :
- type a.
- (module Qsp_syntax.S.Analyzer with type Location.t = a) ->
+ type a context.
+ (module Qsp_syntax.S.Analyzer
+ with type Location.t = a
+ and type context = context) ->
Lexbuf.t ->
+ context ->
(a * Qsp_syntax.Report.t list, Qsp_syntax.Report.t) Result.t =
- fun (module S : Qsp_syntax.S.Analyzer with type Location.t = a) ->
+ fun (module S : Qsp_syntax.S.Analyzer
+ with type Location.t = a
+ and type context = context) ->
let module Parser = Parser.Make (S) in
let module IncrementalParser =
Interpreter.Interpreter (Parser.MenhirInterpreter) in
- fun l ->
+ fun l context ->
let lexer = Lexbuf.tokenize Lexer.main l in
let init = Parser.Incremental.main (fst (Lexbuf.positions l)) in
+ (* Firslty, check if we are able to read the whole syntax from the source *)
let evaluation =
try IncrementalParser.of_lexbuf lexer l init with
| Lexer.LexError message ->
@@ -35,8 +41,11 @@ let parse :
Error err
in
+ (* Then apply the checks over the result of the parsing *)
evaluation
- |> Result.map (fun r -> (r, S.Location.v r))
+ |> Result.map (fun r ->
+ let r' = r context in
+ (r', S.Location.v r'))
|> Result.map_error (fun e ->
let message =
match e.IncrementalParser.code with