macroctx: pass ctx JSON (caps) to user macros; add demo macro; docs: MacroCtx section and sandbox Box API; golden for for/foreach normalized AST

This commit is contained in:
Selfhosting Dev
2025-09-20 09:11:52 +09:00
parent daa5309ea9
commit 497da75f90
14 changed files with 188 additions and 506 deletions

View File

@ -0,0 +1,8 @@
{"kind":"Program","statements":[
{"kind":"Local","variables":["i"],"inits":[{"kind":"Literal","value":{"type":"int","value":0}}]},
{"kind":"Loop","condition":{"kind":"BinaryOp","op":"<","left":{"kind":"Variable","name":"i"},"right":{"kind":"Literal","value":{"type":"int","value":3}}},"body":[
{"kind":"Print","expression":{"kind":"Variable","name":"i"}},
{"kind":"Assignment","target":{"kind":"Variable","name":"i"},"value":{"kind":"BinaryOp","op":"+","left":{"kind":"Variable","name":"i"},"right":{"kind":"Literal","value":{"type":"int","value":1}}}}
]}
]}