diff options
| -rwxr-xr-x | c.bqn | 23 | ||||
| -rwxr-xr-x | test/bt | 5 |
2 files changed, 15 insertions, 13 deletions
@@ -5,7 +5,7 @@ charSet←∾charGroups←⟨ chF←"+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!" # Function "˜˘¨⌜⁼´˝`" # Modifier "∘○⊸⟜⌾⊘◶⎉⚇⍟" # Composition - ¯1⊏˘10‿2⥊"𝕨𝕎𝕩𝕏𝕗𝔽𝕘𝔾𝕤𝕊" # Input (𝕣 pending; ℝ not allowed) + ¯1⊏˘10‿2⥊"𝕨𝕎𝕩𝕏𝕤𝕊𝕗𝔽𝕘𝔾" # Input (𝕣 pending; ℝ not allowed) nl∾"⋄," # Separator "←↩→" # Gets "(){}⟨⟩" # Bracket @@ -138,13 +138,16 @@ Compile←{ # Targetting dzaima/BQN bytecode: DParse ← {nv‿r𝕊𝕩: - g←⍋+`p←bB(⊣(≠⊸>ׯ1⋆2|⊢)⊐)𝕩 + g←⍋+`p←bB(⊣(≠⊸>ׯ1⋆2|⊢)⊐)𝕩⋄br←p×𝕩∊2‿3⊏bB sl←1⊸⌽⊸∨𝕩∊bL⋄sr←¯1⊸⌽⌾(g⊸⊏)sl⋄sa←sl∨sr g⊏˜↩⍋g⊏sl⋄r×↩¬sa⋄o←p>0 r+↩(sa<𝕩=1⊑bB)(⊣∧¬⊸∨=○(⌈`(1+↕∘≠)⊸×)⊢)(¯1⊸⌽⌾(g⊸⊏)3=r)∨1≤r rev←⍋+`1+¯1↓g((¯1∾⊣)(⊣⍋⊸⊏⊏˜-⊏˜⟜⍋)⟜⍋1(+`∘∾-∾˜)⊏)o∨sl∨𝕩∊bS - g↩⍋+`rev⊏p⋄gr←g⊏rev⋄sll←1+2÷˜0(<-○/>)gr⊏sr-sl - g⊏˜↩⍋gr⊏sl⋄gr↩g⊏rev⋄𝕩⊏˜↩gr⋄r⊏˜↩gr⋄o⊏˜↩gr⋄si←/gr⊏sr>sl + rev⊏˜↩⍋{+`⌾((⍋+`𝕩)⊸⊏)𝕩>0}rev⊏br + b←/rev⊏𝕩=3⊑bB + + g↩⍋+`rev⊏p-br⋄gr←g⊏rev⋄sll←1+2÷˜0(<-○/>)gr⊏sr-sl + g⊏˜↩⍋gr⊏sl⋄gr↩g⊏rev⋄𝕩⊏˜↩gr⋄r⊏˜↩gr⋄o⊏˜↩gr⋄si←/gr⊏sr>sl⋄b⊏↩⍋g s←𝕩∊bS⋄ps←s∨o∨gr⊏sl⋄a←𝕩∊2↑bG r-↩ps∨a⋄op←r≥2⋄ro←op∨1⌽r=3 tr←(⌈`↕∘≠⊸ׯ1⌽ps)⊏ro∨r≥1 @@ -154,11 +157,11 @@ DParse ← {nv‿r𝕊𝕩: dy←fa⊏1↓0∾˜(𝕩≠⊑bO)∧(tr∧r≥0)∨r=0 n←𝕩≥vi+nv⋄id←/n<𝕩≥vi⋄cn←/n∨𝕩≤¯1⊑bC⋄u←⍷ob←cn⊏𝕩 lo←(o/𝕩)=4⊑bB⋄l←/𝕩=5⊑bB⋄ll←1+lo/1(↓--⊸↓)(o∾1)/+`(s∾0)-(1∾o)∧ps∾1 - dr←/s>o+`⊸⊏0∾lo - or←⍋g⊏˜∾⟨cn,cn,id,id,1+/a,dr,l,l,si,si,oa+1⌈oa⊏os,(dy×⊏⟜os)⊸+fa+dy⟩ - bc←or⊏∾⟨0¨cn,u⊐ob,1+(id-1)⊏a,vi-˜id⊏𝕩,(11-⊑bG)+a/𝕩 + dr←/s>o+`⊸⊏0∾lo⋄rt←/𝕩=2⊑bB + or←g⊏˜∾⟨cn,cn,id,id,b,b,rt,1+/a,dr,l,l,si,si,oa+1⌈oa⊏os,(dy×⊏⟜os)⊸+fa+dy⟩ + bc←or⍋⊸⊏∾⟨0¨cn,u⊐ob,1+(id-1)⊏a,vi-˜id⊏𝕩,15¨b,1+↕≠b,25¨rt,(11-⊑bG)+a/𝕩 14¨dr,3¨l,ll,3¨si,sll,5+oa⊏r,5+dy+4×fa⊏tr⟩ - bc‿u + ⟨bc,u,/1∾bc=25⟩ } prims←⟨ @@ -168,9 +171,9 @@ prims←⟨ ⟩ DGenFn←{ ⟨t,r,nVar,lits⟩←Tokenize𝕩 - ⟨bc,u⟩←nVar‿r DParse t + ⟨bc,u,st⟩←nVar‿r DParse t o←(u-(vi+nVar-≠prims)×u≥vi)⊏prims∾LitVal¨lits - ⟨bc,o,nVar↑•a,⟨'f'‿1‿0⟩⟩ + ⟨bc,o,nVar↑•a,'f'‿1⊸∾¨st⟩ } DRun←{ •COMP DGenFn 𝕩 @@ -1,9 +1,8 @@ #! /usr/bin/env dbqn dRun ← ⟨"dRun"⟩ •EX •path∾"../cshim.bqn" -l ← ∾(•LNS •path∾∾⟜"cases.bqn")¨""‿"b" -{ l ∾↩ "1 %"⊸∾¨ (3≤≠)◶0‿(('#'≠2⊸⊑)∧" "≡2⊸↑)¨⊸/ •LNS •path∾"testref.bqn" }⍟⊢(<"-ref")∊•args -c ← (¬"{"⊑∘∊⊢)¨⊸/ l +c ← ∾(•LNS •path∾∾⟜"cases.bqn")¨""‿"b" +{ c ∾↩ (¬"{"⊑∘∊⊢)¨⊸/ "1 %"⊸∾¨ (3≤≠)◶0‿(('#'≠2⊸⊑)∧" "≡2⊸↑)¨⊸/ •LNS •path∾"testref.bqn" }⍟⊢(<"-ref")∊•args M ← {e‿b: (⍎e)⊸≢◶""‿{(•UCS 10)∾˜""""∾b∾""": expected "∾e∾" but received "∾⍕𝕩} DRun b} r ← '%' M∘((+`-2⊸×)∘=⊔⊢)¨ c • ← ("All "∾(⍕≠c)∾" passed!")⍟(0=≠) ∾r |
