glisp/parser

// Parses a list of tokens into an abstract syntax tree expression.

Values

pub fn parse(tokens: List(String)) -> Result(Expr, String)

This function takes a list of string tokens and attempts to parse them into a structured expression according to a simple Lisp-like syntax. It can recognize atoms, numbers, and nested lists.

Examples

parse(["(", "hello", "world", ")"])
// -> Ok(List([Atom("hello"), Atom("world")]))

parse(["42"])
// -> Ok(Number(42))

parse(["missing_paren", "("])
// -> Error("Unclosed list")
Search Document