7 stable releases

1.0.6 Jun 29, 2022
1.0.5 Jun 6, 2022
1.0.4 Apr 10, 2022
1.0.1 Apr 9, 2022
1.0.0 Apr 5, 2022

#373 in Programming languages

31 downloads per month

MIT license

50KB
1K SLoC

Lithia

lisp implemented in rust

Name

Name comes from another name for Lithium Oxide

Functions

  • quote Returns whatever its given, used for when you don't want to evaluate something
  • exit Exit lisp interpreter, number may be provided for exit code
  • =, set Sets a variable
  • def Define a global
  • defunc Define a global function
  • eval Evaluates the given object and what it returns
  • print Display an object
  • read Reads a line into objects
  • include Reads a file and evaluates it, returning the last object
  • while While first argument isn't nil, evaluates the rest
  • read Prompts for input and converts it to objects
  • func Creates a function
    • Use:
     (func (arg1 arg2)
     	(body)
     	(body)
     	return_value)
    
  • car, first Gets the first element in a dot-pair
  • cdr, next Gets the second element in a dot-pair

Math functions

  • +, add
  • -, sub
  • *, mul
  • /, div
  • %, mod
  • ==, eq
  • !=, ne

lib.rs:

This crate provides a LISP implementation for embedding within rust programs

With support for providing rust functions as LISP functions within the environment

Usage

This crate is on crates.io and can be used by adding lithia to your dependencies in your project's Cargo.toml.

[dependencies]
lithia = "*"

Example: simple REPL

let code = "(while t (print (eval (read))))".to_string()

let mut globals = HashMap::new();
let ret = Lisp::new(&mut globals)
.add_stdenv().unwrap()
.eval(&code);

Dependencies

~2.2–3MB
~53K SLoC