aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/pr.bqn33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/pr.bqn b/src/pr.bqn
index f83558d2..d8d1c8e6 100755
--- a/src/pr.bqn
+++ b/src/pr.bqn
@@ -1,29 +1,32 @@
#!/usr/bin/env dbqn
# Process BQN runtime
+rtt ← ('0'-˜⊑)⍟= ⊑ •args∾2 # Runtime type: 0, 1, or all
+rtn ← 2⊸≤◶⥊‿↕ rtt # File numbers included
-# All primitives
-chrs←•Import "glyphs.bqn"
-glyphs ← ∾chrs
+glyphs ← •Import "glyphs.bqn"
# Provided values, to be passed in through the constants array
alias‿def ← (⊑¨ ≍○< 1⊸↓¨) ⟨"?Type","∩Fill","⍣Log",
"$GroupLen","%GroupOrd","⍝_fillBy_"⟩
keep ← "!+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘⎊"
+chrext ← glyphs ∾¨ ((+´·∧`'_'=0‿¯1⊸⊏)¨def) ⊔ alias
-type ← ((+´·∧`'_'=0‿¯1⊸⊏)¨def) ∾ chrs((+`≠¨)∘⊣⍋∾⊸⊐)keep
-need ⇐ type ⊔ alias∾keep
-
-GetRepls ← {
- c‿n ← 𝕩
- ki ← (⊑¨c)⊐keep
- ⟨c,c⊣⌾(ki⊸⊏)n⟩∾¨⟨def,⥊¨alias⟩
+in‿out ← rtt ⊑ {
+ in0‿out0 ← ⟨"∩⍝+-×⌊=≤≢⥊⊑↕⌜", "⌊⌈|<>≠≥⊢⊣∾↑↓⊏˙˜´∘○⊸⟜◶⍟"⟩
+ in1 ← ⍷ out0 ∾˜ in2 ← alias∾keep
+ out2 ← ∾glyphs
+ ⟨ in0‿out0, in1‿out2, in2‿out2 ⟩
}
-⟨E_proc⟩ ← chrs‿GetRepls •Import "pp.bqn"
+need ⇐ chrext⊸((+`≠¨)∘⊣⍋∾⊸⊐)⊸⊔ in
+
+GetRepls ← { c‿n←𝕩 ⋄ ⟨c,c⊣⌾((c∊⥊¨in)⊸/)n⟩∾¨⟨def,⥊¨alias⟩ }
+
+⟨E_proc⟩ ← glyphs‿GetRepls •Import "pp.bqn"
-gd ← "glyphs←"""∾glyphs∾"%"""
-rslt ← "⟨"∾"⟩"«∾","⊸∾¨glyphs # Output all primitives
-rr ← •FLines¨ "r0.bqn"‿"r1.bqn"
-raw ← ∾⟨⟨gd⟩,∾rr,⟨"{PrimInd↩⊑𝕩⊐<⋄𝕩‿SetPrims}"∾rslt⟩⟩
+rslt ← "⟨"∾"⟩"«∾","⊸∾¨out # Output all primitives
+raw ← ∾ (•FLines "r"∾'0'⊸+∾".bqn"˙)¨ rtn
+{𝕤⋄ raw∾˜↩⟨"glyphs←"""∾out∾"%"""⟩ ⋄ rslt∾˜↩"{PrimInd↩⊑𝕩⊐<⋄𝕩‿SetPrims}"}⍟⊢ ∨´1=rtn
+raw ∾↩ ⟨rslt⟩
src ⇐ ∾∾⟜(@+10)¨ E_proc¨ raw