GithubHelp home page GithubHelp logo

drjdn / p5scm Goto Github PK

View Code? Open in Web Editor NEW
6.0 1.0 1.0 197 KB

This a simple scheme implementation using pa_schemer from camlp5

License: MIT License

Makefile 1.12% OCaml 98.68% Scheme 0.02% Standard ML 0.18%

p5scm's Introduction

A Scheme Implementation using Pa_schemer from Camlp5

This repository contains a scheme implementation based on pa_schemer.ml which is included as an extension 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

MIT

p5scm's People

Contributors

drjdn avatar chetmurthy avatar

Stargazers

dongyan avatar Alain De Vos avatar Masanori Ogino avatar Ryan Moore avatar Philip Zucker avatar Seb Mondet avatar

Watchers

 avatar

Forkers

chetmurthy

p5scm's Issues

Wish: labeled arguments

I only want this for christmas: labeled arguments

Maybe this way?

(print :(~name (get_client_name 3923)))

thank you very much.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.