anchor.diff:  let run_generic_error st message =
     ((QueryNOK, JsonStr message), Inl st)
   
  +let collect_errors () =
  +  let errors = FStar.Errors.report_all() in
  +  FStar.Errors.clear ();
  +  errors
  +
  +let run_segment (st: repl_state) (code: string) =
  +  let frag = { frag_text = code; frag_line = 1; frag_col = 0 } in
  +
  +  let collect_decls () =
  +    match Parser.Driver.parse_fragment frag with
  +    | Parser.Driver.Empty -> []
  +    | Parser.Driver.Decls decls
  +    | Parser.Driver.Modul (Parser.AST.Module (_, decls))
  +    | Parser.Driver.Modul (Parser.AST.Interface (_, decls, _)) -> decls in
  +
  +  let json_of_decl d =
  +    JsonAssoc [("range", json_of_def_range d.Parser.AST.drange)] in
  +
  +  match with_captured_errors st.repl_env (fun _ -> Some <| collect_decls ()) with
  +    | None ->
  +      let errors = collect_errors () |> List.map json_of_issue in
  +      ((QueryNOK, JsonList errors), Inl st)
  +    | Some decls ->
  +      let js_of_decl decl =
  +        JsonAssoc [("def_range", json_of_def_range decl.Parser.AST.drange)] in
  +      let js_decls =
  +        JsonList <| List.map js_of_decl decls in
  +      ((QueryOK, JsonAssoc [("decls", js_decls)]), Inl st)
  +
   let run_vfs_add st opt_fname contents =
     let fname = Util.dflt st.repl_fname opt_fname in
     Parser.ParseIt.add_vfs_entry fname contents;
  
positive.code:   else
      let st' = pop_repl st in
      ((QueryOK, JsonNull), Inl st')
  
  let collect_errors () =
    let errors = FStar.Errors.report_all() in
    FStar.Errors.clear ();
    errors
  
  (** Compute and load all dependencies of `filename`.
  
  
negative.code:   ["autocomplete"; "autocomplete/context";
     "compute"; "compute/reify"; "compute/pure-subterms";
     "describe-protocol"; "describe-repl"; "exit";
     "lookup"; "lookup/context"; "lookup/documentation"; "lookup/definition";
     "peek"; "pop"; "push"; "search"; "segment";
     "vfs-add"]
  
  exception InvalidQuery of string
  type query_status = | QueryOK | QueryNOK | QueryViolatesProtocol
  