diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-27 15:25:40 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-27 16:05:28 -0500 |
| commit | b9a41bf4639343573dbd3b9a25ca3a6e3930cd6b (patch) | |
| tree | 40b75fb773f5b9ee41e057cdf05c74ffb0e9066e | |
| parent | 1741d5078e9ef8617c99f1fb9c98d1583e072df9 (diff) | |
Use pr.bqn for dz_rt instead of rewriting runtime code
| -rwxr-xr-x | dc.bqn | 2 | ||||
| -rwxr-xr-x | test/dz_rt | 65 |
2 files changed, 14 insertions, 53 deletions
@@ -13,7 +13,7 @@ prims ← (•Import "dzref"){𝔽} "⟨ special←<˘∘‿2⥊"𝕤𝕩𝕨𝕣𝕗𝕘" DCompile⇐{ - ⟨bc,o,fblk,ind⟩ ← 4 ↑ prims Compile 𝕩 + ⟨bc,o,fblk,ind⟩ ← 4 ↑ (𝕨⊣prims) Compile 𝕩 blk‿bdy ← <˘⍉>(↕≠fblk){ ⟨t,i,l,n⟩←𝕩 s←(3×i)↓(t⊑3‿5‿6)↑special @@ -2,59 +2,20 @@ # Compile and run the primitive implementations, and prim.bqn -impl ← •LNS "../src/r.bqn" - -⟨DRun⟩ ← •Import "../dc.bqn" - -chrs←⟨ - "!+-×÷⋆√⌊⌈∧∨¬|=≠≤<>≥≡≢⊣⊢⥊∾≍↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" - "˙˜˘¨⌜⁼´˝`" - "∘⊸⟜○⌾⎉⚇⍟◶⊘" +⟨ref⟩ ← •Import "../src/pr.bqn" +⟨DRun,DCompile⟩ ← •Import "../dc.bqn" + +provide ← ⟨ + 0≠≡ # IsArray + ⊑⟨⟩⥊0⊸⥊ # Type + ⋆⁼ # Log + ≠¨⊔ # GroupLen + ∾⊔∘⊢ # GroupOrd + !,+,-,×,÷,⋆,⌊,=,≤,≢,⥊,⊑,↕,⌜,`,⊘ ⟩ -nc ← ≠¨chrs -chr ← ∾chrs -itr ← 0⥊˜≠chr - -init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"ABC"∾⌜•a) -post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 -names ← init∾¨'0'∾¨post - -Inc ← { - i←⊑chr⊐𝕩 - n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr - names↩((i⊑init)∾('0'+n)∾i⊑post)⌾(i⊑⊢)names -} - -# built-in assumptions -Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} - -pre ← ⟨ - "IsArray ← 0≠≡" - "Type ← ⊑⟨⟩⥊0⊸⥊" - "Log ← ⋆⁼" - "GroupLen← ≠¨⊔" - "GroupOrd← ∾⊔∘⊢" - '!' Mod "{𝕩 ⋄ ≤1}⍟(1≢⊢)" -⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘" - - -# checks if line is a builtin redefinition -E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ - -# removes comments and replaces built-ins with names -E_proc ← { - l←≠chr - q←≠`𝕩='"' ⋄ q∨↩≠`q<𝕩=''' ⋄ f←¬∨`q<𝕩='#' - ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩 -} +rt ← •COMP provide⊸(⊣»«)⌾(1⊸⊑) DCompile ref -E_redef ← { # handles [fmd] [←↩] - tail ← E_proc 3↓𝕩 # must use old def - Inc ⊑𝕩 - (E_proc 1↑𝕩) ∾ "←" ∾ tail -} +t ← "¬⟨"‿"⟩" (1⌽⌽⊸∾) (¬∘⊑':'∊⊢)¨⊸/ •LNS "prim.bqn" +res ← rt DRun ∾ ∾⟜(@+10)¨ t -pre ∾↩ E_isdef◶E_proc‿E_redef¨ impl -t ← ⟨"¬⟨"⟩∾⟨"⟩"⟩∾˜ (¬∘⊑':'∊⊢)¨⊸/ •LNS "prim.bqn" -res ← DRun ∾ ∾⟜(@+10)¨ pre ∾ E_proc¨ t •Out ("All "∾(⍕≠res)∾" passed!")⍟(0=≠) /res |
