I’m working on a tool for ATD, I want to read the ‘version’ field of a given JSON document and depending on the version use the right
read_ parser from ATD. To do this, I have parameters of type
Lexing.lexbuf as input. If use these lexer_state and lexbuf just to read the version of the JSON file or to parse it, it works, but if I do both, it fails, I guess because they get to an invalid state.
Yojson.lexer_state I can just create a fresh one with
Yojson.init_lexer but what about
Lexing.lexbuf? Is there a way to reuse it on the same file/channel? Should I duplicate it? How?
Thanks for your help.