package p5scm

  1. Overview
  2. Docs
Scheme via camlp5

Install

dune-project
 Dependency

Authors

Maintainers

Sources

0.5.0.tar.gz
md5=e0fe733bb7a8cccc94bfbbd3b58e6d76
sha512=4f4efad8bb7b2ab5cfc0fff9bb48e45df8e7396d288d52f5c84b53919e1979720bbd909e82e714e1eb6fe8d3b83c14656167199373a197a6082eab2457fea94d

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

Source file parse.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
(*
 The MIT License                                                                              

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

open Lexer_utils

let parse_with_error lexbuf =
  try Parser.prog Lexer.tok lexbuf with
  | Parser.Error -> failwith (pspos lexbuf)

let parse_from_chan chan =
  let lexbuf = Lexing.from_channel chan in
  parse_with_error lexbuf

let parse_from_string str =
  let lexbuf = Lexing.from_string str in
  parse_with_error lexbuf

let parse_to_tp lexbuf =
  let ast = parse_with_error lexbuf in
  let p5str = Pp_ast.ast_to_p5scm ast in
  Trans.scm_to_tp p5str

let parse_to_tp_lst lexbuf =
  let ast = parse_with_error lexbuf in
  let p5str = Pp_ast.ast_to_p5scm ast in
  Trans.scm_to_tp_lst p5str

let parse_to_bin chan =
  let lexbuf = Lexing.from_channel chan in
  let ast = parse_with_error lexbuf in
  let p5str = Pp_ast.ast_to_p5scm ast in  
  Trans.scm_to_bin p5str

let parse_to_file chan =
  let lexbuf = Lexing.from_channel chan in
  let ast = parse_with_error lexbuf in
  let p5str = Pp_ast.ast_to_p5scm ast in  
  Trans.scm_to_bin_file p5str (Filename.temp_file ~temp_dir:"./" "test" ".ml")