blob: 18933755f1f3a62b611d910789305d8d78aa74de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# BQN runtime hosted in BQN
⟨src,need⟩ ← •Import "src/pr.bqn"
compile ← need •Import "src/c.bqn"
glyphs ← ∾ •Import "src/glyphs.bqn"
vm ← •Import "vm.bqn"
FillFn ← (⊑1↑0↑⥊)⊘{𝕩⌾(⊢¨)𝕩≢⊸⥊<𝕨}
_fillBy_ ← {
r←𝕨𝔽x←𝕩 ⋄ G←𝔾
𝕨({
_f ← {(3⌊•Type)◶⟨𝔽,0,' ',⊢⟩}
(FillFn⎊(!˙)_f 𝕨) G FillFn _f x
}FillFn⊢)⎊⊢⍟(0=•Type∘⊢) r
}
GroupLen ← {(𝕨⌈≠)⊸↑0 FillFn≠¨⊔𝕩}
extra ← ⟨ •Type, FillFn, ⋆⁼, GroupLen, ∾⊔∘⊢, _fillBy_ ⟩
provide ← { g←𝕩∊glyphs ⋄ (⍋⍋g)⊏extra∾•BQN∘⥊¨g/𝕩 } ∾need
rt‿SetPrims‿SetInv ← VM ⟨provide,!∘0¨⟩ Compile src
PrimInd ← rt⊸⊐⌾<
Decompose ← ((≠glyphs)>PrimInd)◶⟨•Decompose,0⊸≍⟩
SetPrims ⟨ Decompose, PrimInd ⟩
rt
|