diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-16 14:23:48 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-16 14:23:48 -0500 |
| commit | 06ca057eeb92d072e705b7383bca3724e6f7d4fe (patch) | |
| tree | 0baa332662a96ec0fe988bc88b5c6b877ca061e8 | |
| parent | f8fe8c9e633212a96bf3761a7f1b09c6f4750979 (diff) | |
Token-based replacement in pr.bqn
| -rwxr-xr-x | src/pr.bqn | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -13,14 +13,16 @@ nc ← ≠¨chrs glyphs ⇐ chr ← ∾chrs itr ← 0⥊˜≠chr +idChars ← "_¯.π∞"∾∾"0aA"+⟜↕¨10‿26‿26 + init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"ABC"∾⌜•a) post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 -names ← init∾¨'0'∾¨post +out ← init∾¨'0'∾¨post Inc ← { i←⊑chr⊐𝕩 n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr - names↩((i⊑init)∾('0'+n)∾i⊑post)⌾(i⊑⊢)names + out↩((i⊑init)∾('0'+n)∾i⊑post)⌾(i⊑⊢)out } # Required functionality passed in as an argument @@ -31,13 +33,16 @@ ki ← chr⊐keep dt ← ⊔⟜⊒ (+´·∧`'_'=0‿¯1⊸⊏)¨ def ns ← » ne←+`nc kt ← ∾ (ns+≠¨dt) + ⊔⟜⊒ne⍋ki -names ↩ (⥊¨kt⊏chr)⌾(ki⊸⊏)names + +chrt ← ⥊¨chr +in ← chrt ∾ def +out ↩ ((kt⊏chrt)⌾(ki⊸⊏)out) ∾ (∾ns+dt)⊏chrt E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ -E_proc ← ({𝕨∘𝕩}´ def {𝕨•_R_𝕩}⟜⥊¨ chr⊏˜∾ns+dt)∘{ - l←≠chr +E_proc ← { q←≠`𝕩='"' ⋄ q∨↩≠`q<𝕩=''' ⋄ f←¬∨`q<𝕩='#' - ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩 + t ← (¯1+`·¬(»f/q)∨·»⊸∧∊⟜idChars)⊸⊔ f/𝕩 + ∾ (in⊸⊐ ⊑⟜out⍟(<⟜(≠in))¨ ⊢) t } E_redef ← { # handles [fmd] [←↩] tail ← E_proc 3↓𝕩 # must use old def |
