lispp

A Lisp interpreter in C++.


Project Tree

add constructor to Val class

Brett Robinson authored 4 years ago


README.md

lispp

A Lisp interpreter in C++.

Contents

About

lispp is a small Lisp interpreter in C++.

Usage

A quick intro to the language:

; a comment

; a number
2
-8
4.0
3/4

; a string
"octobanana"

; a symbol
*
map
nyble

; a list
'(1 2 3 4)
'(1 "hello" 2 "world")
'(* 2 4)

; a function
(* 2 2)
(- 8 4)

; create a mutable binding
(var x 4)
(var x 8)

; create an immutable binding
(let name "octobanana")
(let name 8) ; error constant binding

; create a function
(fn [x] (* 2 x))

; create, bind, and call a function
(let double (fn [x] (* 2 x)))
(double 4) ; 8

; create and call an anonymous function
((fn [x] (* 2 x)) 4) ; 8

; prevent evaluation of expression
(quote (1 2 3)) ; (1 2 3)
'(1 2 3) ; (1 2 3)

; index into list or string
(1 "octobanana") ; "c"
(2 '(1 2 3)) ; 3

; get all but the first element in list or string
(@ "octobanana") ; "ctobanana"
(@ '(1 2 3)) ; (2 3)

Pre-Build

This section describes what environments this program may run on, any prior requirements or dependencies needed, and any third party libraries used.

Important

Any shell commands using relative paths are expected to be executed in the root directory of this repository.

Environments

  • Linux (supported)
  • BSD (supported)
  • macOS (supported)

Compilers

  • GCC >= 8.0.0 (supported)
  • Clang >= 7.0.0 (supported)
  • Apple Clang >= 11.0.0 (untested)

Dependencies

  • CMake >= 3.8
  • Boost >= 1.71
  • ICU >= 62.1
  • GMP
  • MPFR

Linked Libraries

  • icui18n (libicui18n) part of the ICU library
  • icuuc (libicuuc) part of the ICU library
  • gmp (libgmp) arbitrary precision arithmetic library
  • mpfr (libmpfr) multiple-precision floating-point arithmetic library

macOS

Using a new version of GCC or Clang is required, as the default Apple Clang compiler does not support C++17 Standard Library features such as std::filesystem.

A new compiler can be installed through a third-party package manager such as Brew. Assuming you have Brew already installed, the following commands should install the latest GCC.

1 2
brew install gcc
brew link gcc

The following CMake argument will then need to be appended to the end of the line when running the shell script. Remember to replace the placeholder <path-to-g++> with the canonical path to the new g++ compiler binary.

1
./RUNME.sh build -- -DCMAKE_CXX_COMPILER='<path-to-g++>'

Build

The included shell script will build the project in release mode using the build subcommand:

1
./RUNME.sh build

Install

The included shell script will install the project in release mode using the install subcommand:

1
./RUNME.sh install

License

This project is licensed under the MIT License.

Copyright (c) 2019 Brett Robinson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Back to Top