package p5scm

  1. Overview
  2. Docs
Scheme via camlp5

Install

Dune Dependency

Authors

Maintainers

Sources

0.2.0.tar.gz
md5=252895e6e1d082eb6ad145fc83098d80
sha512=6412ca42b625e2310f7ab3c24e3e8f2930b4fd8a463b29aa78555812e8df7347937e1974264eb597187f65ed5105e0c5182c8ffffff89080664bef195ac35292

doc/src/p5scm.lib/trans.ml.html

Source file trans.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
42
43
44
45
(*
 The MIT License                                                                              

 Copyright (c) 2021 Jason D. Nielsen <drjdnielsen@gmail.com>
 *)

let add_nl str = str ^ "\n"

let scm_to_mlast str =
  let mlast, _ = Pa_scheme.pa_sch str in
  List.map fst mlast

let scm_to_tp str = Ast2pt.phrase (List.hd (scm_to_mlast str))
let scm_to_tp_lst str = List.map Ast2pt.phrase (scm_to_mlast str)
let scm_to_struct str = Ast2pt.implem "-" (scm_to_mlast str)

let scm_to_ml str =
  let mlast, _ = Pa_scheme.pa_sch str in
  let strml = List.map Pr_o.pr_o (List.map fst mlast) in
  let out = String.concat "" (List.map add_nl strml) in
  out ^ ";;\n"

let scm_to_struct_to_ml str =
  let stast = scm_to_struct str in
  let out = Pprintast.string_of_structure stast in
  out ^ ";;\n"

let scm_to_bin str =
  let mlast, status = Pa_scheme.pa_sch str in
  let phr =
    match status with
    | None -> failwith "No location provied!"
    | Some loc -> mlast, loc
  in
  Pr_dump.pr_dump phr

let scm_to_bin_file str fname =
  let mlast, status = Pa_scheme.pa_sch str in
  let phr =
    match status with
    | None -> failwith "No location provied!"
    | Some loc -> mlast, loc
  in
  Pcaml.output_file := Some fname;
  Pr_dump.pr_dump phr
OCaml

Innovation. Community. Security.