package p5scm
Install
Dune Dependency
Authors
Maintainers
Sources
md5=82c945874bf23755b6b01c7e5ac0de7a
sha512=f2b2e3fea71906142c587c4d98657757d9a2f8ffe4e848adbfc5874cc89eb278ba87efa8cbdbb1a4a0bd30bc6c7faf5cf039f83c60334dba067159fe3d8b4d45
Description
This a simple scheme implementation using pa_schemer from camlp5
Published: 12 Dec 2021
README
A Scheme Implementation using Pa_schemer from Camlp5
This repository contains a scheme implementation based on pa_schemer.ml which is included as an extenstion of camlp5. This provides a scheme-like syntax for OCaml. The camlp5 documentation for the scheme extension provides the following comparison between OCaml
and scheme
syntax:
OCaml | Scheme |
---|---|
let x = 42;; | (define x 42) |
let f x = 0;; | (define (f x) 0) |
let rec f x y = 0;; | (definerec (f x y) 0) |
let x = 42 and y = 27 in x + y;; | (let ((x 42) (y 27)) (+ x y)) |
let x = 42 in let y = 27 in x + y;; | (let* ((x 42) (y 27)) (+ x y)) |
module M = struct ... end;; | (module M (struct ...)) |
type 'a t = A of 'a * int | B | (type (t 'a) (sum (A 'a int) (B))) |
fun x y -> x | (lambda (x y) x) |
x; y; z | (begin x y z) |
f x y | (f x y) |
[1; 2; 3] | [1 2 3] |
a, b, c | (values a b c) |
match x with 'A'..'Z' -> "x" | (match x ((range 'A' 'Z') "x"))) |
{x = y; z = t} | {(x y) (z t)} |
p5scm
also provides the following:
OCaml | Scheme |
---|---|
[|1; 2; 3|] | #(1 2 3) |
which is provided via a simple menhir parser that supports all of the syntax above.
Installation
As long as you have a current version of opam, installation is as simple as:
$ opam install p5scm
You can then use it to parse and emit OCaml
bytecode that can then be used in your OCaml project:
$ p5scm file1.scm
You can also start an interpreter for p5scm
:
$ p5sch-utop
which uses utop for code completion and many of the other benefits that it provides. Currently both the #require
and #use
directives of utop
function in the interpreter/REPL (same syntax as utop
however no terminating ;;
required).
Only OCaml
versions >= 4.12.0 are supported by the opam
package. Instructions for adding support for older versions can be found (here).
License
Dependencies (9)
-
conf-perl-string-shellquote
>= "1"
-
utop
>= "2.7.0"
-
ppx_sexp_conv
>= "v0.14.0"
-
sexp_pretty
>= "v0.14.0"
-
camlp5
>= "8.00~alpha05" & < "8.00.03"
-
cppo
>= "1.6.6"
-
menhir
>= "20201214"
-
ocaml
>= "4.12.0" & < "4.14.0"
-
dune
>= "2.7"
Dev Dependencies (1)
-
odoc
with-doc
Used by
None
Conflicts
None