diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-02 17:08:51 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-02 17:08:51 -0400 |
| commit | e1ce7b201e662757b62c480c8ae1c76e41ad8a5f (patch) | |
| tree | eb419f56e2ca2654f4deb945c6b61f0eef1584db /src/pr.bqn | |
| parent | d2427937164a9f790ec08f9c14412472404d0afe (diff) | |
Add self-hosted Javascript script
Diffstat (limited to 'src/pr.bqn')
| -rwxr-xr-x | src/pr.bqn | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/pr.bqn b/src/pr.bqn new file mode 100755 index 00000000..d68b3453 --- /dev/null +++ b/src/pr.bqn @@ -0,0 +1,47 @@ +#!/usr/bin/env dbqn + +# Process BQN runtime + +impl ← •LNS •path∾"../impl.bqn" + +chrs←⟨ + "+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!" + "˜˘¨⌜⁼´˝`" + "∘○⊸⟜⌾⊘◶⎉⚇⍟" +⟩ +nc ← ≠¨chrs +chr ← ∾chrs +itr ← 0⥊˜≠chr + +init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"ABC"∾⌜•a) +post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 +names ← init∾¨(•UCS 48)∾¨post + +Inc ← { + i←⊑chr⊐𝕩 + n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr + names↩((i⊑init)∾(•UCS 48+n)∾i⊑post)⌾(i⊑⊢)names +} + +# Required functionality passed in as an argument +pnam ← ⟨"IsArray", "Type", "Log"⟩∾names⊏˜chr⊐"!+-×÷⋆⌊=≤≢⥊⊑↕⌜`" + + +E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ +E_proc ← { + l←≠chr + q←≠`𝕩∊"""'" ⋄ f←¬∨`q¬⊸∧𝕩='#' + ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩 +} +E_redef ← { # handles [fmd] [←↩] + tail ← E_proc 3↓𝕩 # must use old def + Inc ⊑𝕩 + (E_proc 1↑𝕩) ∾ "←" ∾ tail +} + +ref ← ∾ ∾⟜(•UCS 10)¨ ∾⟨ + ⟨"{"⟩ + ⟨"←𝕩"∾˜"⟨"∾"⟩"∾˜1↓∾","⊸∾¨pnam⟩ + E_isdef◶E_proc‿E_redef¨ impl∾<"⟨"∾"⟩"∾˜1↓⥊","⊸∾˘∾chrs + ⟨"}"⟩ +⟩ |
