From 382dddfbdd49cc176744ec00ba57e5787cd94620 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Wed, 28 Apr 2021 16:00:43 -0400 Subject: =?UTF-8?q?Allow=20pr.bqn=20to=20emit=20a=20half=20runtime=20with?= =?UTF-8?q?=20=E2=80=A2args=200=20or=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pr.bqn | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src') 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 -- cgit v1.2.3