Skip to content

otherfunc/otherfunc-lisp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

otherfunc-lisp

Bytecode-compiled Scheme-like Lisp with symbol interning, tail call optimization, and HTTP/KV outbound.

Implementation

  • Pipeline: Source -> Tokenizer -> Parser -> AST -> Compiler -> Bytecode -> Stack VM
  • Symbol interning via Interner (string -> u32 id) for fast comparisons
  • Lexical addressing resolved at compile time; dedicated TailCall opcode for TCO
  • 29 built-in functions: arithmetic, comparison, list ops, I/O, type predicates, HTTP, env, KV
  • Special forms: quote, define (with function sugar), lambda, if, and, or, begin, let, set!
  • HTTP outbound via coroutine/yield: (http-get url), (http-post url body), (env "KEY")
  • KV storage via coroutine/yield: (kv-get "key"), (kv-set "key" "value"), (kv-del "key")
  • Default instruction limit: 10,000,000 (configurable via with_instruction_limit())

Install

cargo install --path .

Usage

# Inline code
lisp "(+ 1 2)"

# From file
lisp -f program.scm

# Piped input
echo "hello" | lisp "(display (read-line))"

As a Library

use otherfunc_lisp::LispInterpreter;
use otherfunc_core::Interpreter;

let mut lisp = LispInterpreter::new();
let output = lisp.execute("(+ 1 2)", "").unwrap();
assert_eq!(output, "3");

Tests

cargo test -p otherfunc-lisp    # 33 tests

About

Bytecode-compiled Scheme-like Lisp interpreter

Topics

Resources

License

Stars

Watchers

Forks

Languages