Module sexpr

Module sexpr 

Source
Expand description

The S-expression reader — the canonical surface.

docs/02-syntax.md §2.8: “The S-expression reader is ~300 lines and should exist from week one: it lets you write compiler tests against canonical ASTs without depending on the Python surface being finished, and it is how you’ll dump intermediate state for the rest of the project’s life.”

It reads the notation the original sketch is written in. (def toggle (params (: t Todo)) ...) is a Node with head def and three arguments, and nothing is desugared on the way in — the Python parser’s job is to arrive at exactly the same tree.

Functions§

atom_node
Classify an atom. Shared with the Python surface so that true means the same thing in both.
read_all
Read every form in a source string.
read_one
Read exactly one form; anything after it is an error. Used by tests and by beck ast.