Skip to main content

Week 3 Studio: Assignment and a symbol table

Implementing assignment statements over a single flat symbol table — variables as SNOBOL4 actually has them, not as most languages have them

8 March 2027

Before the session

Bring week 2’s parser and evaluator. This week extends the expression grammar with variable references and adds the first statement form.

In the session

Sample transcript

Genuine captured output from this course’s own week-3 reference evaluator, run against a short sequence of assignments:

$ dune exec bin/main.exe -- examples/vars.sno
11

9

The blank middle line is worth tracing by hand, not a rendering glitch: Z = UNSET assigns Z the value of UNSET, a variable that has itself never been assigned, so it evaluates to the null string per this week’s spec — that null string is what gets printed, not an error.

This week’s real starter — the symbol table wired up, with assignment and lookup themselves stubbed out — is downloadable at week-03-starter.zip.

Afterwards

The symbol table you build this week is the one the rest of the course reuses without redesigning it — this is the one place “everything is global” pays off as a simplification rather than a constraint.

The spec

What you bring to the session. Written so a reader can tell whether it has been met without asking you.

Teaching team