diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-11 20:57:23 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-06-11 20:57:26 -0400 |
| commit | f2fbf9dfc7955e655d59fc100a093598506762c5 (patch) | |
| tree | d4c5180abefa307ddca027e0d252767c758da1ce /c.bqn | |
| parent | 4966cfb61d7eb8b7e594ebb3ca09d3d2dc190d67 (diff) | |
Move parser from character to integer encoding
Diffstat (limited to 'c.bqn')
| -rwxr-xr-x | c.bqn | 53 |
1 files changed, 28 insertions, 25 deletions
@@ -3,21 +3,24 @@ ⊔↩((↕1+(>⌈´))=¨<)∘⊣ /¨⟜< ↕∘≠⍠⊢ lf‿tab←•UCS 10‿9 -chR←"⍝" ⍝ Remark -chD←•d ⍝ +⟜(↕10)⌾•UCS'0' ⍝ Digit -chN←"¯.π∞" ⍝ Numeric -chA←' '(⊢∾+)⌾•UCS•a ⍝ Alphabetic -chU←"_" ⍝ Underscore -chF←"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" ⍝ Function -chM←"˜˘¨⌜⁼´`" ⍝ Modifier -chC←"∘○⊸⟜⌾⎉⚇⍟" ⍝ Composition -chP←"𝕨𝕎𝕩𝕏𝕗𝔽𝕘𝔾" ⍝ Parameter -chW←" "∾tab ⍝ Whitespace -chS←"⋄,"∾lf ⍝ Separator -chG←"←↩→" ⍝ Gets -chB←"(){}⟨⟩" ⍝ Bracket -chL←"‿" ⍝ Ligature -chQ←"'""" ⍝ Quote +charSet←∾charGroups←⟨ + "⍝" ⍝ Remark + •d ⍝ +⟜(↕10)⌾•UCS'0' ⍝ Digit + "¯.π∞" ⍝ Numeric + ' '(⊢∾+)⌾•UCS•a ⍝ Alphabetic + "_" ⍝ Underscore + chF←"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" ⍝ Function + "˜˘¨⌜⁼´`" ⍝ Modifier + "∘○⊸⟜⌾⎉⚇⍟" ⍝ Composition + "𝕨𝕎𝕩𝕏𝕗𝔽𝕘𝔾" ⍝ Parameter + " "∾tab ⍝ Whitespace + lf∾"⋄," ⍝ Separator + "←↩→" ⍝ Gets + "(){}⟨⟩" ⍝ Bracket + "‿" ⍝ Ligature + "'""" ⍝ Quote +⟩ +bR‿bD‿bN‿bA‿bU‿bF‿bM‿bC‿bP‿bW‿bS‿bG‿bB‿bL‿bQ←↕∘≠⌾∾charGroups Hex←16⊥(•d∾"ABCDEF")⊸⊐ MakeTab←{(≠chF)↑⊑¨(chF⊐𝕨)⊔𝕩} @@ -25,12 +28,12 @@ tab1←"|-⌈⌊√÷" MakeTab (<(Hex"10")∾1)∾˜⥊¨(Hex"99")+((↕4)∾6) tab2←"⊣+-×÷⌊⌈" MakeTab ⥊¨(Hex"1A")∾(Hex"A0")+↕6 Parse←{ - ⟨⟩Parse𝕩;args←𝕨⋄x←𝕩 - x(/˜)↩¬(x∊chW)∨<○(⌈`↕∘≠⊸×)´(lf∾chR)=⌜x - x(/˜)↩¬(1⌾⊑1⌽1⌾⊑)⊸∧x∊chS - a←x∊"←↩"⋄at←1⌽a⋄vars←at/x⋄x(/˜)↩¬a⋄a(/˜)↩¬at - l←≠x⋄sep←x∊chS⋄x↩'⊣'¨⌾(sep⊸/)x - o←x='('⋄c←x=')'⋄v←a-˜x∊•d∾args∾vars⋄f←¬o∨c∨v∨sep + ⟨⟩Parse𝕩;args←charSet⊐𝕨⋄x←charSet⊐𝕩 + x(/˜)↩¬(x∊bW)∨<○(⌈`↕∘≠⊸×)´((⊑bS)∾bR)=⌜x + x(/˜)↩¬(1⌾⊑1⌽1⌾⊑)⊸∧x∊bS + a←x∊(2↑bG)⋄at←1⌽a⋄vars←at/x⋄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∾args∾vars⋄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 @@ -46,16 +49,16 @@ f64←127-3 GenFn←{ ⟨x‿na,vars,locs⟩←𝕩 fns←{ - n←•d⊐<𝕩 - n=≠•d:(Hex"20")∾vars⊐<𝕩 + 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⟩ }‿{ v←vars⊐<𝕩⋄v<≠vars:(Hex"22")∾v - tab1⊑˜chF⊐<𝕩 + tab1⊑˜bF⊐<𝕩 }‿{ - tab2⊑˜chF⊐<𝕩 + tab2⊑˜bF⊐<𝕩 } ((≠∾∾)⟨locs≠⊸∾f64⟩)∾(Hex"0B")∾˜∾na⊑⟜fns⊸{𝕎𝕩}¨x } |
