Expand description
S-expression reader and name-resolution lowering to Exp.
Source text passes through up to three stages here:
- Reading (
parse_one/parse_all): text toSexptrees. Comments (;to end of line) are dropped; the quote-family reader macros (',`,,,,@) becomequote/quasiquote/unquotelist heads. - Surface desugaring, applied only at source boundaries:
sugrewrites thecadrfamily into car/cdr chains everywhere, including inside quoted data (Pink source is quoted data);expand_qqturns quasiquote in loaded files into plain cons/quote source. - Lowering (
lower):SexptoExp, resolving each name to an environment index against a compile-time name stack. Special forms are matched by head symbol and shape here; a list that matches nothing becomes a (curried) application.
Values entered at a REPL prompt follow 1–3; data read by the read
primitive stops after 1 and is converted directly to a value with
sexp_to_val.
Enums§
- Sexp
- A read s-expression — the concrete syntax tree, before lowering.
Functions§
- expand_
qq - Expand quasiquote in loaded
.najsource into plain cons/quote source. - lower
- Lower a read s-expression to an
Exp, resolving names againstnames— the compile-time stack of binders in scope, which mirrors the runtime environment slot-for-slot. Innermost binding wins (rposition), so shadowing works; an unresolved name is an error at lowering time, not runtime. - parse_
all - Parse every top-level form in
src. String-error twin ofrepl::parse_all, callable from the evaluator (read-file) without a layering inversion. - parse_
one - Read the first complete form from
src, ignoring anything after it. - sexp_
to_ val - Convert a read s-expression directly into a runtime value — lists
become
Tupchains, no lowering, no name resolution. This is how thereadandread-fileprimitives hand parsed input to the evaluator as data. - sug
- pink.scm’s
sugpre-pass (pink.scm:11): desugarcadr/caddr/cadddrinto car/cdr chains over the whole surface tree — including quoted data, since Pink source is itself a quoted list. Oracle under Chez:(sug '(quote (cadr x)))=>(quote (car (cdr x))).