aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xc.bqn43
-rw-r--r--test/cases.bqn4
2 files changed, 28 insertions, 19 deletions
diff --git a/c.bqn b/c.bqn
index d0d9de40..668aeb61 100755
--- a/c.bqn
+++ b/c.bqn
@@ -22,18 +22,6 @@ charSet←∾charGroups←⟨
bR‿bD‿bN‿bA‿bF‿bM‿bC‿bP‿bW‿bS‿bG‿bB‿bL‿bQ←↕∘≠⌾∾charGroups
vi←≠charSet
-Hex←16⊥(•d∾"ABCDEF")⊸⊐
-MakeTab←{{(≠chF)↑⊑¨(chF⊐𝕨)⊔𝕩}○∾⟜(⥊¨∘⥊¨)´⍉(2(÷˜∾⊣)≢)⊸⥊𝕩}
-tab1←MakeTab⟨
- "|-⌈⌊√" , (Hex"99")+(↕4)∾6
- "÷" , <(Hex"10")∾1
- "⊣⊢" , 2⥊<⟨⟩
-⟩
-tab2←MakeTab⟨
- "⊣" , Hex"1A"
- "+-×÷⌊⌈", (Hex"A0")+↕6
-⟩
-
Tokenize←{
args←charSet⊸⊐¨𝕨⋄c←charSet⊐𝕩
c(/˜)↩¬<○(⌈`↕∘≠⊸×)´((⊑bS)∾bR)=⌜c
@@ -60,18 +48,34 @@ Parse←{
sel⊸⊏¨𝕩‿na
}
-GenNum←{
- n←10⊥bD⊐𝕩
- n=0:8⥊0
- l←2(⌊⋆⁼)n
- (Hex"44")∾2⊥˘⌽8‿8(⊣⥊×´⊸↑)∾⟨⥊0,(11⥊2)⊤1023+l,(2⥊˜0⌈l)⊤n⟩
+Hex←16⊥(•d∾"ABCDEF")⊸⊐
+
+ReadNum←10⊥bD⊸⊐
+GenF64←{
+ 𝕩=0:8⥊0
+ l←2(⌊⋆⁼)𝕩
+ (Hex"44")∾2⊥˘⌽8‿8(⊣⥊×´⊸↑)∾⟨⥊0,(11⥊2)⊤1023+l,(2⥊˜0⌈l)⊤𝕩⟩
}
+MakeTab←{{(≠chF)↑⊑¨(chF⊐𝕨)⊔𝕩}○∾⟜(⥊¨∘⥊¨)´⍉(2(÷˜∾⊣)≢)⊸⥊𝕩}
+tab1←MakeTab⟨
+ "⊣⊢" , 2⥊<⟨⟩
+ "|-⌈⌊√" , (Hex"99")+(↕4)∾6
+ "÷" , <(Hex"10")∾1
+ "¬" , <∾⥊¨⟨Hex"9A",GenF64 1,Hex"A0"⟩
+⟩
+tab2←MakeTab⟨
+ "⊣" , Hex"1A"
+ "+-×÷⌊⌈∧", (Hex"A0")+(↕6)∾2
+ "¬" , <∾⥊¨⟨Hex"A1",GenF64 1,Hex"A0"⟩
+ "∨" , <(Hex"10")∾2
+⟩
f64←127-3
+
GenFn←{
⟨⟩GenFn𝕩;
⟨tok,nVar,nLoc,nums⟩←𝕨Tokenize𝕩
⟨x,na⟩←Parse tok
- load←((Hex"20")∾¨↕nVar)∾GenNum¨nums
+ load←((Hex"20")∾¨↕nVar)∾GenF64∘ReadNum¨nums
fns←{
(𝕩-vi)⊑load
}‿{
@@ -102,5 +106,6 @@ Gen←{
Compile←{
body←GenFn 𝕩
rcp←⟨"x"⟩ GenFn "1÷x"
- Gen ⟨⟨0‿1,1‿1⟩/¨¨f64 ⋄ ⥊<"fn" ⋄ ⟨body,rcp⟩⟩
+ or←⟨"w","x"⟩ GenFn "(w+x)-w∧x"
+ Gen ⟨⟨0‿1,1‿1,2‿1⟩/¨¨f64 ⋄ ⥊<"fn" ⋄ ⟨body,rcp,or⟩⟩
}
diff --git a/test/cases.bqn b/test/cases.bqn
index 60fda216..baae0ba5 100644
--- a/test/cases.bqn
+++ b/test/cases.bqn
@@ -12,3 +12,7 @@
3.1415 % t←2×5⋄3+(1+(4+(1+5÷t)÷t)÷t)÷t
3.1415 % 3+(1+(4+(1+5÷10)÷10)÷10)÷10
3 % √25-16
+0.25 % ¬15÷20
+0 % (3∧4)-¬(¬3)∨(¬4)
+1 % p←¬q←÷4⋄(q∧q)+(p∨p)
+109 % 105¬-3