From 0dff9871abb061ee72daa2ec1f6820d42098a2d6 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Thu, 9 Sep 2021 17:40:56 -0400 Subject: Basic undo header support --- src/c.bqn | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/c.bqn') diff --git a/src/c.bqn b/src/c.bqn index 33514908..11c0ad0e 100644 --- a/src/c.bqn +++ b/src/c.bqn @@ -30,6 +30,7 @@ CharCode←charSet{ Chk ← ⊢⊣ErrUnknownChars∘(≠/⊣)⍟≢⟜(⊏⟜𝕗) g←⍋𝕗 ⋄ ⊢ Chk g⊏˜1-˜1⌈(g⊏𝕗)⍋⊢ } +swap_undo←CharCode∊⟜mod1⊸/"˜⁼" vd←1+vi←⊑bN # Start of identifier numbering (plus dot) charRole←4∾˜∾⥊¨˜⟜(≠↑cgl˙)⟨1,2,3,¯1,¯1,¯3,¯1‿0,¯2,0,¬/5‿6⟩ # For first vd chars @@ -169,6 +170,9 @@ Parse ← {r‿vn‿i‿e‿def←𝕨⋄nv←≠vn "At most two header-less bodies allowed"_err_(/CB) »⊸∧co>¯1↓ch cc←(⍋⍋«co)⊏c∾/cs # Case close hi←/hf←hh⊏˜⟜IT⌾((⌽g)⊸⊏)cb∨hh # Header component indices + un←0=us←swap_undo(≠∘⊣-⊐)hi⊏𝕩 + "Invalid Undo header syntax"_err_(HI) un<(»⊸≥∨(1»un)∧2⊸=)us + ut←un/»us⋄hi/˜↩0=us hr←(⊏⟜ns×⊏⟜r)rev⊏˜hi # And their roles hl←2=hn←(1⊸»+«)hc←¯1=hr # hl: is label, hc: is : "Only one header per body allowed"_err_(hc/HI) (1+hc/hi)⊏hf @@ -182,8 +186,10 @@ Parse ← {r‿vn‿i‿e‿def←𝕨⋄nv←≠vn "Incorrect special name"_err_(HI) (0=hk)∧ht≠hv+⊑bI hk×↩¬hc∨hl∧0=hr # Treat subject labels like special names hm>↩hc⋄hr/˜↩hm⋄hx←(1»hc)/ha # Header-derived role hr and immediacy ¬hx - cw←1+-⟜«(»ch)<1(⊢<«)cf # Body 𝕨: 0 no, 1 allowed, 2 required - cw↩(hc/»hla¬⊸×hl⌈ha×1+he←0≠hk)⌾(ch⊸/)cw + cw←1+-⟜«(»ch)<1(⊢<«)cf + cw↩(hc/»hla¬⊸×hl⌈ha×1+he←0≠hk)⌾(ch⊸/)cw # Body 𝕨: 0 no, 1 allowed, 2 required + "Invalid Undo header syntax"_err_(HI) hm<×ut + cu←(hm/ut)⌾(ch⊸/)0¨cw⋄cw⌈↩2×2=cu "Header left argument without right"_err_(HI) ha>hc+`⊸⊏hx∾0 "Header operation must be a plain name"_err_(HI) hma>hk≠2 hx∨↩1=hr⋄hu←(¬he)⌾(hi⊸⊏)hf @@ -291,7 +297,7 @@ Parse ← {r‿vn‿i‿e‿def←𝕨⋄nv←≠vn fa←/(fe←hg∨ta∨ro∨«⊸∨psfe∨ff dy←2≠ny←fa⊏2«no⌈2׬(tr∧r≥0)∨ro