From 10b72d3a9a74cda526219bdc149dac8feb3f25e4 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Mon, 1 Nov 2021 16:22:09 -0400 Subject: Move all dzaima/BQN-specific tools into test/ --- bqn.bqn | 24 ------------------------ dc.bqn | 18 ------------------ docs/running.html | 2 +- running.md | 2 +- test/dc.bqn | 18 ++++++++++++++++++ test/dz_comp | 17 +++++++++++------ test/dzrt.bqn | 23 +++++++++++++++++++++++ 7 files changed, 54 insertions(+), 50 deletions(-) delete mode 100644 bqn.bqn delete mode 100755 dc.bqn create mode 100755 test/dc.bqn create mode 100644 test/dzrt.bqn diff --git a/bqn.bqn b/bqn.bqn deleted file mode 100644 index 254c8a7b..00000000 --- a/bqn.bqn +++ /dev/null @@ -1,24 +0,0 @@ -# BQN hosted in dzaima/BQN -# Result is a function that executes BQN code. - -⟨src,need⟩ ← •Import "src/pr.bqn" -⟨DRun⟩ ← •Import "dc.bqn" -⟨DCompile⟩ ← need •Import "dc.bqn" -glyphs ← ∾ gl ← •Import "src/glyphs.bqn" - -GroupLen ← {(𝕨⌈≠)⊸↑0•FillFn≠¨⊔𝕩} -extra ← ⟨ •Type, •FillFn, ⋆⁼, GroupLen, ∾⊔∘⊢, •_fillBy_ ⟩ -provide ← { g←𝕩∊glyphs ⋄ (⍋⍋g)⊏extra∾•BQN¨g/𝕩 } ∾need - -rt‿SetPrims ← •COMP ⟨provide,(•BQN"•"⊸∾)¨⟩ DCompile src -PrimInd ← rt⊸⊐⌾< -Decompose ← ((≠glyphs)>PrimInd)◶⟨•Decompose,0⊸≍⟩ -SetPrims ⟨ Decompose, PrimInd ⟩ - -sys ← {𝕩⊏˜𝕨⊸⊐}˝⍉>⟨ - "bqn"‿{BQN𝕩} - "type"‿•Type - "glyph"‿(glyphs⊑˜PrimInd) - "decompose"‿Decompose -⟩ -BQN ← ⟨rt,Sys⟩⊸DRun diff --git a/dc.bqn b/dc.bqn deleted file mode 100755 index cec675ba..00000000 --- a/dc.bqn +++ /dev/null @@ -1,18 +0,0 @@ -#! /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 diff --git a/docs/running.html b/docs/running.html index b78b10ad..98e6ce01 100644 --- a/docs/running.html +++ b/docs/running.html @@ -14,7 +14,7 @@

Javascript

diff --git a/running.md b/running.md index 98790c04..51b6f1a0 100644 --- a/running.md +++ b/running.md @@ -15,7 +15,7 @@ This version of BQN is [implemented](implementation/README.md) mainly in BQN its Support in the following languages has been implemented: - Javascript, in this repository. Slow (compiles at ~5kB/s) but usable. - [C](https://github.com/dzaima/CBQN), targetting high performance. Some parts are fast, some are not. -- dzaima/BQN ([bqn.bqn](bqn.bqn)), mainly for testing. +- BQN ([vm.bqn](vm.bqn)), for testing the compiler easily. - [Erlang](https://github.com/cannadayr/ebqn), intended for embedding. Too slow to be practical; a [Rust version](https://github.com/cannadayr/ebqn-rs/) is in progress to fix this. #### Javascript 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 diff --git a/test/dz_comp b/test/dz_comp index 9815bb40..e9bf1c06 100755 --- a/test/dz_comp +++ b/test/dz_comp @@ -5,12 +5,17 @@ files ← "simple"‿"syntax"‿"prim"⍟(0=≠) ('-'≠⊑)¨⊸/ •args "Can't test runtime without the compiler!" ! ¬nc∧rt∨ref Native ← •BQN -exec ← ((rt⌈2×ref)¬nc)◶⟨ - Native˙ # Native - {𝕤⋄ ⟨DRun⟩←•Import "../dc.bqn" ⋄ DRun} # Compiled; native runtime - {𝕤⋄ •Import "../bqn.bqn"} # Self-hosted - {𝕤⋄ ⟨DRun⟩←•Import "../dc.bqn" ⋄ (•Import"ref.bqn")⊸DRun} # Reference implementations -⟩ @ +exec ← { + nc ? Native ; + # Otherwise compiled + ⟨DRun⟩ ← •Import "dc.bqn" + r ← { + ref ? •Import "ref.bqn" ; # Reference implementations + rt ? •Import "dzrt.bqn" ; # Self-hosted + •BQN∘⥊¨ ∾ •Import "../src/glyphs.bqn" # Native runtime + } + r⊸DRun +} Cases ← (0<≠)◶0‿('#'≠⊑)¨⊸/ · •FLines "cases/"∾∾⟜".bqn" c ← ∾ Cases¨ files diff --git a/test/dzrt.bqn b/test/dzrt.bqn new file mode 100644 index 00000000..ae217e07 --- /dev/null +++ b/test/dzrt.bqn @@ -0,0 +1,23 @@ +# Runtime hosted in dzaima/BQN + +⟨src,need⟩ ← •Import "../src/pr.bqn" +⟨DRun⟩ ← •Import "dc.bqn" +⟨DCompile⟩ ← need •Import "dc.bqn" +glyphs ← ∾ gl ← •Import "../src/glyphs.bqn" + +GroupLen ← {(𝕨⌈≠)⊸↑0•FillFn≠¨⊔𝕩} +extra ← ⟨ •Type, •FillFn, ⋆⁼, GroupLen, ∾⊔∘⊢, •_fillBy_ ⟩ +provide ← { g←𝕩∊glyphs ⋄ (⍋⍋g)⊏extra∾•BQN¨g/𝕩 } ∾need + +rt‿SetPrims ← •COMP ⟨provide,(•BQN"•"⊸∾)¨⟩ DCompile src +PrimInd ← rt⊸⊐⌾< +Decompose ← ((≠glyphs)>PrimInd)◶⟨•Decompose,0⊸≍⟩ +SetPrims ⟨ Decompose, PrimInd ⟩ + +sys ← {𝕩⊏˜𝕨⊸⊐}˝⍉>⟨ + "bqn"‿{BQN𝕩} + "type"‿•Type + "glyph"‿(glyphs⊑˜PrimInd) + "decompose"‿Decompose +⟩ +⟨rt,Sys⟩ -- cgit v1.2.3