Skip to content
This repository has been archived by the owner on Nov 3, 2020. It is now read-only.

Latest commit

 

History

History
30 lines (20 loc) · 745 Bytes

README.md

File metadata and controls

30 lines (20 loc) · 745 Bytes

rust_sexpr is a library for parsing S-expressions, and contains a simple globally-scoped evaluator for a LISP-like language.

Building

For both the s-expr library and lisplike,

$ rustc --lib lisplike.rc

For just the s-expr library,

$ rustc --lib sexpr.rs

To run the unit tests, compile with --test.

Usage

extern mod sexpr;

fn main() {
    let value: Option<sexpr::Value> = sexpr::from_str("(1 2 3.5)");
    match value {
    	Some(expr) =>
    	  assert_eq!(expr, sexpr::List(~[sexpr::Num(1.0), sexpr::Num(2.0), sexpr::Num(3.5)])),
    	None =>
    	  fail!("There was an error parsing the S-expression!")
    }
}