aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bqn.bqn8
-rwxr-xr-xdc.bqn5
-rwxr-xr-xsrc/cjs.bqn13
-rwxr-xr-xsrc/pr.bqn14
4 files changed, 22 insertions, 18 deletions
diff --git a/bqn.bqn b/bqn.bqn
index 6f2eeb15..b40eb862 100644
--- a/bqn.bqn
+++ b/bqn.bqn
@@ -1,8 +1,10 @@
# BQN hosted in dzaima/BQN
# Result is a function that executes BQN code.
-⟨DRun,DCompile⟩ ← •Import "dc.bqn"
-⟨ref,glyphs⟩ ← •Import "src/pr.bqn"
+⟨ref,prims⟩ ← •Import "src/pr.bqn"
+⟨DRun⟩ ← •Import "dc.bqn"
+⟨DCompile⟩ ← prims •Import "dc.bqn"
+glyphs ← ∾ •Import "src/glyphs.bqn"
provide ← ⟨
•Type # Type
@@ -12,7 +14,7 @@ provide ← ⟨
∾⊔∘⊢ # GroupOrd
!,+,-,×,÷,⋆,⌊,=,≤,≢,⥊,⊑,↕,⌜,`,•_fillBy_,⊘,⎊
-rt‿SetPrims ← •COMP provide⊸(⊣»«)⌾(1⊸⊑) DCompile ref
+rt‿SetPrims ← •COMP provide DCompile ref
PrimInd ← rt⊸⊐⌾<
Decompose ← ((≠glyphs)>PrimInd)◶⟨•Decompose,0⊸≍⟩
SetPrims ⟨ Decompose, PrimInd ⟩
diff --git a/dc.bqn b/dc.bqn
index 2a41bbbb..6c286e82 100755
--- a/dc.bqn
+++ b/dc.bqn
@@ -4,13 +4,12 @@
# multiple bodies, and use variable names instead of counts.
# Rearrange and make up some names so the bytecode can be run.
-glyphs ← •Import "src/glyphs.bqn"
+glyphs ← •Import∘"src/glyphs.bqn"⍟(0=≠) •args
compile ← glyphs •Import "src/c.bqn"
-prims ← •BQN∘⥊¨ ∾glyphs
special←<˘∘‿2⥊"𝕤𝕩𝕨𝕣𝕗𝕘"
DCompile⇐{
- ⟨bc,o,fblk,ind⟩ ← 4 ↑ (𝕨⊣prims) Compile 𝕩
+ ⟨bc,o,fblk,ind⟩ ← 4 ↑ (𝕨 •BQN∘⥊¨∘∾⊘⊣ glyphs) Compile 𝕩
blk‿bdy ← <˘⍉>(↕≠fblk){
⟨t,i,l,n⟩←𝕩
s←(3×i)↓(t⊑3‿5‿6)↑special
diff --git a/src/cjs.bqn b/src/cjs.bqn
index efe6cb87..cb7b1a79 100755
--- a/src/cjs.bqn
+++ b/src/cjs.bqn
@@ -19,21 +19,24 @@ FP ← ∞⊸=◶⟨F,"Infinity"⟩ # Format positive number
Num ← 0⊸≤◶⟨"-"∾FP∘|,FP⟩ # Format number
glyphs ← •Import "glyphs.bqn"
-compile ← glyphs •Import "c.bqn"
+_getComp ← { (3+useInd) ↑ (𝕗 •Import "c.bqn"){𝔽} }
useInd ← "-i"≡⊑args←•args ⋄ args↓˜↩useInd
-Comp ← (3+useInd) ↑ ((<"runtime" Ind F)¨↕62)⊸Compile
+Comp ← ((<"runtime" Ind F)¨↕62) glyphs _getComp ⊢
J ← ∾∾⟜(@+10)¨
Fconst ← ≡◶⟨@⊸≤◶Num‿Char, Str, ⊑⟩
Fout ← (≠↑⟨F,Fconst,L F¨,F⟩˙) {L𝕎¨𝕩}¨ ⊢
-Frun ← "provide"⊸Cat⌾(1⊸⊑) Fout
Long ← ∾ (≠↑1‿3/⟨" "⊸∾⋄((@+10)∾" ,")⊸∾⟩˙) {𝕎𝕩}¨ ⊢
LFC ← Long∘Fout∘Comp
-SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿𝕩}
+RT ← {𝕩
+ prims‿ref←•Import"pr.bqn" ⋄ l←≠∾prims
+ Long "provide"⊸Cat⌾(1⊸⊑) Fout l⊸↓⌾(1⊸⊑) (↕l) prims _getComp ref
+}
CArg ← {J (¯5⊸↓∾𝕩˙)⌾⊑ •FLines "c.bqn"}
+SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿𝕩}
•Out (⊑"r"‿"c"‿"cc"‿"f"‿"e"‿"p"⊐⊏)◶⟨
- {𝕩⋄ref‿len←•Import"pr.bqn"⋄Long Frun len⊸↓⌾(1⊸⊑)Comp ref}
+ RT
{𝕩⋄LFC CArg "⟨"∾"⟩"«∾","⊸∾¨'"'(⊣∾∾˜)¨glyphs}
{𝕩⋄LFC "{"∾"}"∾˜CArg"𝕩"}
{𝕩⋄LFC •FChars "f.bqn"}
diff --git a/src/pr.bqn b/src/pr.bqn
index e918518e..29337498 100755
--- a/src/pr.bqn
+++ b/src/pr.bqn
@@ -4,20 +4,20 @@
# All primitives
chrs←•Import "glyphs.bqn"
-glyphs ⇐ ∾chrs
+glyphs ← ∾chrs
# Provided values, to be passed in through the constants array
-def ← ⟨"Type","Fill","Log","GroupLen","GroupOrd","_fillBy_"⟩
+alias‿def ← (⊑¨ ≍○< 1⊸↓¨) ⟨"?Type","∩Fill","⍣Log",
+ "$GroupLen","%GroupOrd","⍝_fillBy_"⟩
keep ← "!+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘⎊"
-len ⇐ def+○≠keep
+
+type ← ((+´·∧`'_'=0‿¯1⊸⊏)¨def) ∾ chrs((+`≠¨)∘⊣⍋∾⊸⊐)keep
+prims ⇐ type ⊔ alias∾keep
GetRepls ← {
c‿n ← 𝕩
ki ← (⊑¨c)⊐keep
- dt ← ⊔⟜⊒ (+´·∧`'_'=0‿¯1⊸⊏)¨ def
- ns ← » ne←+`≠¨chrs
- kt ← ∾ (ns+≠¨dt) + ⊔⟜⊒ne⍋ki
- ⟨c,(kt⊏c)⌾(ki⊸⊏)n⟩∾¨⟨def,(∾ns+dt)⊏c⟩
+ ⟨c,c⊣⌾(ki⊸⊏)n⟩∾¨⟨def,⥊¨alias⟩
}
⟨E_proc⟩ ← chrs‿GetRepls •Import "pp.bqn"