aboutsummaryrefslogtreecommitdiff
path: root/test/dc.bqn
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:22:09 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:30:33 -0400
commit10b72d3a9a74cda526219bdc149dac8feb3f25e4 (patch)
treef6cd814796e5396677e5626f1beae2925fb02a1a /test/dc.bqn
parent0a5ec5b2c31eccda5e00239df80ae3675a51b0a2 (diff)
Move all dzaima/BQN-specific tools into test/
Diffstat (limited to 'test/dc.bqn')
-rwxr-xr-xtest/dc.bqn18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/dc.bqn b/test/dc.bqn
new file mode 100755
index 00000000..5a0ccae8
--- /dev/null
+++ b/test/dc.bqn
@@ -0,0 +1,18 @@
+#! /usr/bin/env dbqn
+
+# dzaima/BQN block headers have a different format to account for
+# multiple bodies, and use variable names instead of counts.
+# Rearrange and make up some names so the bytecode can be run.
+
+glyphs ← •Import∘"../src/glyphs.bqn"⍟(0=≠) •args
+compile ← glyphs •Import "../src/c.bqn"
+
+special←<˘∘‿2⥊"𝕤𝕩𝕨𝕣𝕗𝕘"
+DCompile⇐{
+ ⟨bc,o,fblk,fbdy,ind,tok⟩ ← 6 ↑ (𝕨 •BQN∘⥊¨∘∾⊘⊣ glyphs) Compile 𝕩
+ name ← ⊑2⊑tok
+ blk ← 2(↑∾≍˜∘⊑)¨fblk
+ bdy ← {⟨l,n,d,e⟩←𝕩 ⋄ ⟨l,((<"")⥊˜n-≠d)∾d⊏name,n-⊸↑e⟩}¨fbdy
+ ⟨bc,o,blk,⊑blk,bdy,name,⊑ind,1⊑ind,𝕩⟩
+}
+DRun⇐•COMP∘DCompile