#! /usr/bin/env dbqn # Javascript/JSON formatting L ← "["∾"]"∾˜1↓·∾","⊸∾¨ # Native list/array Ind ← {∾𝕨‿"["‿𝕩‿"]"} # Native list/array indexing Cat ← {∾𝕨‿".concat("‿𝕩‿")"} # Native list/array concatenation (like ∾) # Escape the special characters that appear in BQN sources. Esc←{ in ← (@+0‿9‿10‿13)∾"'""" # Null, Tab, LF, CR, and quotes out ← "0tnr" # Whitespace characters changed to letters i ← in⊐𝕩 𝕩 ↩ i ⊏⟜out⌾((i<≠out)⊸/) 𝕩 # Replace ∾(i<≠in) /⟜"\"⊸∾¨ 𝕩 # Insert \ } Str ← "str("""∾Esc∾""")"˜ # A BQN string Char ← "'"(∾∾⊣)Esc∘⥊ # A BQN character F ← •Fmt # Native format FP ← ∞⊸=◶⟨F,"Infinity"⟩ # Format positive number Num ← 0⊸≤◶⟨"-"∾FP∘|,FP⟩ # Format number glyphs ← •Import "glyphs.bqn" compile ← glyphs •Import "c.bqn" useInd ← "-i"≡⊑args←•args ⋄ args↓˜↩useInd Comp ← (3+useInd) ↑ ((<"runtime" Ind F)¨↕62)⊸Compile J ← ∾∾⟜(@+10)¨ Fconst ← ≡◶⟨@⊸≤◶Num‿Char, Str, ⊑⟩ Fout ← (≠↑⟨F,Fconst,L F¨,F⟩˙) {L𝕎¨𝕩}¨ ⊢ Frun ← "provide"⊸Cat⌾(1⊸⊑) Fout Long ← ∾ (≠↑1‿3/⟨" "⊸∾⋄((@+10)∾" ,")⊸∾⟩˙) {𝕎𝕩}¨ ⊢ LFC ← Long∘Fout∘Comp SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿𝕩} CArg ← {J (¯5⊸↓∾𝕩˙)⌾⊑ •FLines "c.bqn"} •Out (⊑"r"‿"c"‿"cc"‿"f"‿"e"‿"p"⊐⊏)◶⟨ {𝕩⋄ref‿len←•Import"pr.bqn"⋄Long Frun len⊸↓⌾(1⊸⊑)Comp ref} {𝕩⋄LFC CArg "⟨"∾"⟩"«∾","⊸∾¨'"'(⊣∾∾˜)¨glyphs} {𝕩⋄LFC "{"∾"}"∾˜CArg"𝕩"} {𝕩⋄LFC •FChars "f.bqn"} {𝕩⋄LFC SVG "e"} {𝕩⋄LFC SVG "p"} ¯1 ↓ · J L∘Fout∘Comp¨ ⟩ args