THE FOLD / SPAWN / THE TOOLCHAIN / THE SHUNTING YARD
THE SHUNTING YARD
infix to RPN in one pass — precedence resolved once
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Dijkstra’s shunting-yard algorithm converts an infix expression like
Postfix then evaluates trivially with a value stack, no precedence rules needed. It is how calculators and compilers turn human math into machine-executable order, in O(n) with no recursion.
LIT verified live: for 500 random expressions, evaluating the shunting-yard postfix gives the same value as an independent recursive-descent evaluator (window.__shuntingyard). FIG no framing; exact expression evaluation.
3+4*2 into postfix (Reverse Polish) 3 4 2 * + in one left-to-right pass, using an operator stack that respects precedence and parentheses — named for the railway yard that reorders cars.Postfix then evaluates trivially with a value stack, no precedence rules needed. It is how calculators and compilers turn human math into machine-executable order, in O(n) with no recursion.
LIT verified live: for 500 random expressions, evaluating the shunting-yard postfix gives the same value as an independent recursive-descent evaluator (window.__shuntingyard). FIG no framing; exact expression evaluation.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-toolchain — the compiler’s front-end that turns source into order. Shunting-yard is the first tool in that chain: parse the grammar into a stream a machine can run. AVAN (AI) built the instrument: the operator stack with precedence, the postfix output, the stack evaluator, the reference check.
Credit as content: Edsger W. Dijkstra (1961), who named it for the railway shunting yard. The weave: David names the toolchain; I shunt operators through a stack to produce postfix, evaluate it on a value stack, and confirm the answer matches a recursive-descent parser.
Credit as content: Edsger W. Dijkstra (1961), who named it for the railway shunting yard. The weave: David names the toolchain; I shunt operators through a stack to produce postfix, evaluate it on a value stack, and confirm the answer matches a recursive-descent parser.
3 ONE DIMENSION
The operator stack shunts tokens: numbers flow straight to output, operators wait on the stack until a lower-or-equal-precedence one arrives, and parentheses open and close sub-yards. Precedence is resolved once, here.
4 TWO DIMENSIONS · INTERACTIVE
Enter an expression; watch tokens shunt to the output stream and the operator stack. The postfix result is evaluated on a value stack, and checked against a recursive-descent evaluator.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the postfix stream and the operator stack that produced it, precedence resolved into pure order.
AVAN’s addition (the inverse-companion): postfix needs no parentheses and no precedence rules — the order encodes everything, so evaluation is a trivial stack machine that never looks ahead. The inverse of ‘operator precedence’ is ‘a fixed evaluation order that makes precedence disappear.’ Shunting-yard moves the complexity once, at parse time, so it never recurs at eval time — you pay for the grammar a single time and hand the interpreter a flat stream it runs blindly. Magenta is the parentheses and precedence, gone from the output; green is the postfix a dumb stack evaluates left to right. Encode the grammar into the order, and the interpreter becomes trivial.
LIT Genuine shunting-yard algorithm (Dijkstra 1961). Verified live: for 500 random arithmetic expressions (+,-,*,parentheses, integer division), evaluating the shunting-yard postfix on a value stack gives the same result as an independent recursive-descent parser (window.__shuntingyard.postfixMatchesRef); 3+4*2 -> 11.
FIG No framing: the operator-stack conversion, the postfix evaluation, and the recursive-descent reference all run in-browser and agree exactly. The AVAN inverse is honest — postfix needs no parentheses or precedence because the order encodes everything, so shunting-yard moves the grammar complexity once (parse time) and hands the interpreter a flat stream; magenta is the vanished parentheses/precedence, green the postfix.
FIG No framing: the operator-stack conversion, the postfix evaluation, and the recursive-descent reference all run in-browser and agree exactly. The AVAN inverse is honest — postfix needs no parentheses or precedence because the order encodes everything, so shunting-yard moves the grammar complexity once (parse time) and hands the interpreter a flat stream; magenta is the vanished parentheses/precedence, green the postfix.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE TOOLCHAIN · David Lee Wise (ROOT0), with AVAN