diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-12 11:36:01 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-12 11:36:01 -0400 |
| commit | 90e53efa1b5d7b8ed3b8aace100eca4c0134178a (patch) | |
| tree | cac609bf1d0d978bce59b25c4377c82e25c7a29b | |
| parent | 0d7b0af37e163a075b798feda130879c27a31dd1 (diff) | |
Support multi-digit numbers in the parser (not the generator yet)
| -rwxr-xr-x | c.bqn | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -36,14 +36,14 @@ tab2←MakeTab⟨ Parse←{ ⟨⟩Parse𝕩;args←charSet⊸⊐¨𝕨⋄x←charSet⊐𝕩 x(/˜)↩¬<○(⌈`↕∘≠⊸×)´((⊑bS)∾bR)=⌜x - w←(<´≠↕0∾⊢)wc←x∊bA - id←∪args∾ids←(1-˜wc×+`w)⊔x - vi←≠charSet⋄vars←vi+↕≠id + w←(<´≠↕0∾⊢)wc←x∊∾bD‿bN‿bA + id←∪args∾(bA∊˜w/x)⍒⊸⊏ids←(1-˜wc×+`w)⊔x + vi←≠charSet⋄nVar←>+´bA∊˜⊑¨id x↩(w∨¬wc∨x∊bW)/(vi+id⊐ids)⌾(w⊸/)x x(/˜)↩¬(1⌾⊑1⌽1⌾⊑)⊸∧x∊bS a←x∊(2↑bG)⋄at←1⌽a⋄x(/˜)↩¬a⋄a(/˜)↩¬at l←≠x⋄sep←x∊bS⋄x↩(bF⊑˜chF⊐<'⊣')¨⌾(sep⊸/)x - o←x=0⊑bB⋄c←x=1⊑bB⋄v←a-˜x∊bD∾vars⋄f←¬o∨c∨v∨sep + o←x=0⊑bB⋄c←x=1⊑bB⋄v←a-˜x≥vi⋄f←¬o∨c∨v∨sep na←(2×sep)+f×1+l↑0∾c∨v e←/c⋄d←+`o-c ed←e⊏d⋄b←(⍋⍋ed)⊏(⍋⊏⟜d)⊸⊏/o @@ -52,25 +52,29 @@ Parse←{ fe⌊↩(l-1)-l↑(⌈`↕∘≠⊸×)⌾⌽1∾˜sep ia←+`l↑0∾f-l↑/⁼∧f/fe sel←¬∘⊏⟜(o∨c)⊸/⍋(fe⌈↕l)-ia - ⟨sel⊸⊏¨x‿na,vars,args≠⊸↓vars⟩ + ⟨sel⊸⊏¨x‿na,nVar,nVar-≠args,nVar↓id⟩ } +GenNum←{ + n←⊑bD⊐𝕩 + n=0:8⥊0 + l←2(⌊⋆⁼)n + (Hex"44")∾2⊥˘⌽8‿8(⊣⥊×´⊸↑)∾⟨⥊0,(11⥊2)⊤1023+l,(2⥊˜0⌈l)⊤n⟩ +} f64←127-3 GenFn←{ - ⟨x‿na,vars,locs⟩←𝕩 + ⟨x‿na,nVar,nLoc,nums⟩←𝕩 + vi←≠charSet + load←((Hex"20")∾¨↕nVar)∾GenNum¨nums fns←{ - n←bD⊐<𝕩 - n=≠bD:(Hex"20")∾vars⊐<𝕩 - n=0:8⥊0 - l←2(⌊⋆⁼)n - (Hex"44")∾2⊥˘⌽8‿8(⊣⥊×´⊸↑)∾⟨⥊0,(11⥊2)⊤1023+l,(2⥊˜0⌈l)⊤n⟩ + (𝕩-vi)⊑load }‿{ - v←vars⊐<𝕩⋄v<≠vars:(Hex"22")∾v - tab1⊑˜bF⊐<𝕩 + 𝕩≥vi:(Hex"22")∾𝕩-vi + (𝕩-⊑bF)⊑tab1 }‿{ - tab2⊑˜bF⊐<𝕩 + (𝕩-⊑bF)⊑tab2 } - ((≠∾∾)⟨locs≠⊸∾f64⟩)∾(Hex"0B")∾˜∾na⊑⟜fns⊸{𝕎𝕩}¨x + ((≠∾∾)⟨nLoc∾f64⟩)∾(Hex"0B")∾˜∾na⊑⟜fns⊸{𝕎𝕩}¨x } Gen←{ |
