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

A simple S-expression parser (and evaluator) in Rust

License

Notifications You must be signed in to change notification settings

darkf/rust_sexpr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!")
    }
}

About

A simple S-expression parser (and evaluator) in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages