From 702b0289b311ffe970ef976c40260db373186b62 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Sat, 28 Jan 2023 10:34:32 -0500 Subject: boot3 parsing simplifications --- src/bootstrap/boot3.bqn | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'src/bootstrap/boot3.bqn') diff --git a/src/bootstrap/boot3.bqn b/src/bootstrap/boot3.bqn index abfb09a4..bc912bc2 100644 --- a/src/bootstrap/boot3.bqn +++ b/src/bootstrap/boot3.bqn @@ -19,7 +19,6 @@ cm←⋈¨˜⟜(0»+`)cgl←≠¨chars bS←3⊑cm⋄bG←4⊑cm⋄bB←5⊑cm⋄bI←6⊑cm⋄bN←7⊑cm⋄bA←9⊑cm⋄bW←10⊑cm M←1⊸⊑(0⊸≤∧>)-⟜⊑ # ∊ for an init,length pair 𝕩 as above - sep←⊑bS vi←⊑bN # Start of identifier numbering charRole←∾cgl⥊¨⟨1,2,3,¯1,¯3,⟨¯1,0⟩,⟨1,0,0⟩,0,0,26/⟨0,1⟩,4,0⟩ TT←⌈`× ⋄ IT←↕∘≠⊸TT @@ -51,14 +50,13 @@ ki←(wi⍒⊸⊏/w)∾(ci∾/ss)⊏+`»f # Indices in t k←⟨ide,⟨⟩,num,chr,str⟩ # Constants k↩k(⊢>¯1»⌈`)⊸/¨˜j←⊐¨k # IDs j into uniques k - wr←w∨¬l∨t M bW⋄r↩wr/r - t↩wr/(∾j++`vi»≠¨k)⌾(ki⊸⊏)t # Add IDs; remove words/whitespace - t↩t-t(M×-⟜⊑)bS # Separators are equivalent - pb←≠`1¨sb←¯1↓1↓/1(∾≠∾˜)t=sep # Separator group boundaries (excludes leading and trailing) + wr←w∨¬l∨t M bW⋄r↩wr/r # Remove words/whitespace + t↩wr/(∾j++`vi»≠¨k)⌾(ki⊸⊏)t # Add IDs + pb←≠`1¨sb←¯1↓1↓/1(∾≠∾˜)ts←t M bS # Separator group boundaries (excludes leading and trailing) eb←⟨3,5⟩+⊑bB # End brackets that allow separators sk←sb/˜pb>∨⟜«eb∊˜pb+(sb-pb)⊏t # Keep the first of each group that's not just inside a bracket - sr←(t≠⊸↑/⁼sk)∨t≠sep⋄r↩sr/r⋄t↩sr/t # Remove the rest - 𝕩↩t⋄nv←≠⊑k + sr←ts≤t≠⊸↑/⁼sk⋄r↩sr/r⋄t↩sr/t # Remove the rest + 𝕩↩t⋄ev←vi+≠⊑k # End of tokenization! # Bracket roles @@ -74,7 +72,7 @@ # Lexical resolution, no nesting rx←rev⊏𝕩 - iv←/(rx≥⊑bI)∧rx∨|)ps(⊢-TT)+`¬op # Train argument (first-level) fa←/(ta∨op∨aa)<(r=1)∨»op # Active functions + os←⌽↕∘≠⊸(⊣-TT)⌽¬op # Operator skip: distance rightward to derived function start dy←fa⊏«(tr∧r≥0)∨opls⋄rt←/fo # Drop (block separator) and return - os←⌽↕∘≠⊸(⊣-TT)⌽¬op # Operator skip: distance rightward to derived function start - fl←(dy×⊏⟜os)⊸+fa+dy # Function application site # Object code generation: numbers oc ordered by source location (after rev) oi fsc←3×fx←↕2 # Body immediacy ¬fx, special name count - or←⍋idor∾g⊏˜∾⟨cn,cn,bk,bk,2/lb,at,dr,oa+1⌈oa⊏os,fl,rt⟩ - oc←or⊏∾idoc∾⟨0¨cn,ob,1¨bk,1+↕≠bk,⥊⍉(11+lb⊏aa)≍ll,48+ao,6¨dr + or←⍋idor∾g⊏˜∾⟨cn,cn,bk,bk,lb,lb,at,dr,oa+1⌈oa⊏os,fl,rt⟩ + oc←or⊏∾idoc∾⟨0¨cn,ob,1¨bk,1+↕≠bk,11+lb⊏aa,ll,48+ao,6¨dr 24+oa⊏r,16+dy+4×fa⊏tr,¯1↓rc←7¨fx⟩ # Output fz←⟨0¨fx,¬fx,↕≠fx⟩ # Per-function data -- cgit v1.2.3