package logtk

  1. Overview
  2. Docs
Core types and algorithms for logic

Install

Dune Dependency

Authors

Maintainers

Sources

1.6.tar.gz
md5=97cdb2f90468e9e27c7bbe3b4fb160bb
sha512=fee73369f673a91dfa9e265fc69be08b32235e10a495f3af6477d404fcd01e3452a0d012b150f3d7f97c00af2f6045019ad039164bf698f70d771231cc4efe5d

doc/src/logtk.parsers/Util_dk.ml.html

Source file Util_dk.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

(* This file is free software, part of Zipperposition. See file "license" for more details. *)

(** {1 Utils for Dedkuti} *)

open Logtk

module E = CCResult
module A = UntypedAST
module T = STerm

type parser_res = (UntypedAST.statement Iter.t, string) CCResult.t
type 'a parser_ = 'a -> parser_res

let parse_lexbuf_ lex =
  Parse_dk.file Lex_dk.token lex |> Iter.of_list

let parse_lexbuf file : parser_res =
  try parse_lexbuf_ file |> E.return
  with e -> E.of_exn e

let parse_stdin () : parser_res =
  let lexbuf = Lexing.from_channel stdin in
  ParseLocation.set_file lexbuf "stdin";
  parse_lexbuf lexbuf

let parse_file file : parser_res =
  if file="stdin"
  then parse_stdin()
  else
    try
      CCIO.with_in file
        (fun ic ->
           let lexbuf = Lexing.from_channel ic in
           ParseLocation.set_file lexbuf file;
           parse_lexbuf_ lexbuf)
      |> E.return
    with
    | Sys_error e ->
      E.fail (Util.err_spf "sys_error when parsing `%s`:@ %s" file e)
    | e -> E.of_exn e
OCaml

Innovation. Community. Security.