aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-28 15:16:31 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-28 15:16:31 -0400
commit038066e41e654b1288939a38af6da9329a26f4bf (patch)
tree3a782266065433044438a265e9af9e1c68bb9928
parent5199bc3835b6509f01560660750cd102cd5cf033 (diff)
Get provided primitives from needed names in bqn.bqn
-rw-r--r--bqn.bqn22
-rwxr-xr-xsrc/cjs.bqn4
-rwxr-xr-xsrc/pr.bqn6
3 files changed, 14 insertions, 18 deletions
diff --git a/bqn.bqn b/bqn.bqn
index e51c809f..254c8a7b 100644
--- a/bqn.bqn
+++ b/bqn.bqn
@@ -1,20 +1,16 @@
# BQN hosted in dzaima/BQN
# Result is a function that executes BQN code.
-⟨ref,prims⟩ ← •Import "src/pr.bqn"
-⟨DRun⟩ ← •Import "dc.bqn"
-⟨DCompile⟩ ← prims •Import "dc.bqn"
-glyphs ← ∾ •Import "src/glyphs.bqn"
+⟨src,need⟩ ← •Import "src/pr.bqn"
+⟨DRun⟩ ← •Import "dc.bqn"
+⟨DCompile⟩ ← need •Import "dc.bqn"
+glyphs ← ∾ gl ← •Import "src/glyphs.bqn"
-provide ← ⟨
- •Type # Type
- •FillFn # Fill
- ⋆⁼ # Log
- {(𝕨⌈≠)⊸↑≠¨⊔𝕩} # GroupLen
- ∾⊔∘⊢ # GroupOrd
- !,+,-,×,÷,⋆,⌊,=,≤,≢,⥊,⊑,↕,⌜,`,•_fillBy_,⊘,⎊
-⟩
-rt‿SetPrims ← •COMP ⟨provide,(•BQN"•"⊸∾)¨⟩ DCompile ref
+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 ⟩
diff --git a/src/cjs.bqn b/src/cjs.bqn
index cb7b1a79..ecdb2990 100755
--- a/src/cjs.bqn
+++ b/src/cjs.bqn
@@ -29,8 +29,8 @@ Long ← ∾ (≠↑1‿3/⟨" "⊸∾⋄((@+10)∾" ,")⊸∾⟩˙) {𝕎𝕩}
LFC ← Long∘Fout∘Comp
RT ← {𝕩
- prims‿ref←•Import"pr.bqn" ⋄ l←≠∾prims
- Long "provide"⊸Cat⌾(1⊸⊑) Fout l⊸↓⌾(1⊸⊑) (↕l) prims _getComp ref
+ src‿need←•Import"pr.bqn" ⋄ l←≠∾need
+ Long "provide"⊸Cat⌾(1⊸⊑) Fout l⊸↓⌾(1⊸⊑) (↕l) need _getComp src
}
CArg ← {J (¯5⊸↓∾𝕩˙)⌾⊑ •FLines "c.bqn"}
SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿𝕩}
diff --git a/src/pr.bqn b/src/pr.bqn
index df1b1ac8..f83558d2 100755
--- a/src/pr.bqn
+++ b/src/pr.bqn
@@ -12,7 +12,7 @@ alias‿def ← (⊑¨ ≍○< 1⊸↓¨) ⟨"?Type","∩Fill","⍣Log",
keep ← "!+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘⎊"
type ← ((+´·∧`'_'=0‿¯1⊸⊏)¨def) ∾ chrs((+`≠¨)∘⊣⍋∾⊸⊐)keep
-prims ⇐ type ⊔ alias∾keep
+need ⇐ type ⊔ alias∾keep
GetRepls ← {
c‿n ← 𝕩
@@ -25,5 +25,5 @@ GetRepls ← {
gd ← "glyphs←"""∾glyphs∾"%"""
rslt ← "⟨"∾"⟩"«∾","⊸∾¨glyphs # Output all primitives
rr ← •FLines¨ "r0.bqn"‿"r1.bqn"
-src ← ∾⟨⟨gd⟩,∾rr,⟨"{PrimInd↩⊑𝕩⊐<⋄𝕩‿SetPrims}"∾rslt⟩⟩
-ref ⇐ ∾∾⟜(@+10)¨ E_proc¨ src
+raw ← ∾⟨⟨gd⟩,∾rr,⟨"{PrimInd↩⊑𝕩⊐<⋄𝕩‿SetPrims}"∾rslt⟩⟩
+src ⇐ ∾∾⟜(@+10)¨ E_proc¨ raw