Giter Club home page Giter Club logo

lisp's Introduction

An interpreter for a custom lisp dialect.

Ideas

The core language should be as simple as possible, complex features should be implemented in terms of the primitives where possible and reasonable. Let can be implemented with lambda, loops can be implemented with recusion, etc.

Differences

This lisp is intended to be similar to Emacs lisp, but functions and values are unified into a single namespace like in scheme.

There is only one equality function, “=”, no eq, eql, equal, etc.

Limitations

This language is very unstable and many things are not implemented yet.

Working with Carpet Lisp

NOTE: You will need rust’s nightly toolchain installed to build this project.

Building

git clone https://github.com/Jturnerusa/lisp
cd lisp
cargo build

Running

Currently, the core lib is passed as an environment variable.

export CARPET_LISP_PATH="$PWD/lib/lisp"

Sample lisp for testing:

(require list)

(def fib (lambda (n)
           (if (< n 2)
               n
               (+ (fib (- n 1)) (fib (- n 2))))))

(named-let loop ((n 1))
  (print (fib n))
  (if (< n 10)
      (loop (+ n 1))
    nil))

Run the sample:

cargo run --bin eval sample.lisp

This should result in a fibonaci sequence up to 10 indices:

1
1
2
3
5
8
13
21
34
55

Features

List of native functions:

  • +
  • -
  • *
  • /
  • cons
  • car
  • cdr
  • list
  • apply
  • cons?
  • function?
  • symbol?
  • string?
  • int?
  • char?
  • nil?
  • apply
  • lambda
  • defmacro
  • def
  • set!
  • eval-when-compile
  • quote
  • if
  • ===
  • >
  • <
  • assert
  • decl
  • map-create
  • map-insert!
  • map-retrieve
  • map-items
  • module
  • export
  • require

Roadmap

  • Native Functions (string slicing, utils, etc.)
  • control flow graph for type system

lisp's People

Contributors

jturnerusa avatar xxc3nsoredxx avatar embeddedpenguin avatar

Stargazers

 avatar genBTC avatar  avatar  avatar Kacper Słomiński avatar

Watchers

 avatar

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.