Skip to content

yeoleobun/rspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rspect - A Scheme Interpreter in Rust

This is a simple Scheme interpreter written in Rust.

Building

To build the interpreter, you need to have Rust and Cargo installed. Navigate to the project directory in your terminal and run:

cargo build --release

Running

To run the interpreter's REPL (Read-Eval-Print Loop), use:

cargo run

This will start an interactive session where you can type Scheme expressions.

To exit the REPL, press Ctrl+C, Ctrl+D, or type exit and press Enter.

Supported Syntax

The interpreter currently supports a subset of Scheme, including:

  • Core Forms:
    • define: Define variables and functions.
    • if: Conditional execution.
    • lambda: Create anonymous functions. Example: ((lambda (x) (* x x)) 5) ; Output: 25
    • quote / ': Prevent evaluation. Example: '(+ 1 2) ; Output: (+ 1 2)
  • Macros (from stdlib.scm):
    • case: Selects a clause based on matching a key. Example: (case (* 2 3) ((1 5 7) "odd") ((2 4 6) "even")) ; Output: "even"
    • let: Bind variables locally. Example: (let ((x 1) (y 2)) (+ x y)) ; Output: 3
    • let*: Sequential local binding. Example: (let* ((x 1) (y (+ x 1))) (* x y)) ; Output: 2
    • letrec: Recursive local binding (for functions). Example: (letrec ((fact (lambda (n) (if (zero? n) 1 (* n (fact (- n 1))))))) (fact 5)) ; Output: 120

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published