summaryrefslogtreecommitdiff
path: root/src/scope
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 06:00:47 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commite7679f416daeee551e81a592c7fe06b8d8f7b705 (patch)
tree5799b9d96e17679710ebe810ce7257d9dd7f3505 /src/scope
parent1637cf5efa338fee7797ba83f264dcab5bde4800 (diff)
downloadsketchbook-e7679f416daeee551e81a592c7fe06b8d8f7b705.tar.gz
sketchbook-e7679f416daeee551e81a592c7fe06b8d8f7b705.zip
examples/live: the language, text in, a tape and a problem out
Lang.compile reads lines of `name = expression` over t, x and y (+ - * /, unary minus, parentheses, numbers, # comments) and returns either a Program, the out and color tapes, or a Problem: a byte of the text and words. The builtins are one table, `builtins` (call, op, arity, value, doc): the survey's sin, cos, exp, log, pow, sqrt, abs, floor, fract, min, max, clamp, mix, step, smoothstep, atan2, noise, saw, sqr, tri, seq, hsv, rgb, tau and pi, and the inputs t, x, y. A name is defined once, before it is used; builtins cannot be renamed; hsv and rgb are colours, so only the whole color line can be one. Each tape is emitted from its line's root, depth first, each term once, so it holds only what the line reaches; t, x and y are a term each however often named, and a negative number is a number. seq's values go in registers side by side: as emitted when they are fresh numbers, else copied. noise's missing arguments are 0. Nothing is allocated: the compiler is a struct on the stack, 512 terms, 128 names, 32 levels of nesting, 17 arguments (seq's 16 values), 128 instructions a tape, about 28 KiB in all; past any of them is a problem in words ("the out line needs more than 128 instructions", at the line). vm.glsl's smoothstep is written out: GLSL leaves lo > hi undefined, and the survey's ring is smoothstep(0.03, 0, ...). Tests: a tone instruction by instruction; the survey's 20-line program (out 54 instructions, color 46, neither holding the other's terms, every operand an earlier register); every builtin; precedence, comments and numbers; 24 problems, each with its byte and words; each capacity, met and passed. zig build test: 6 of 6. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/scope')
0 files changed, 0 insertions, 0 deletions