uCBQN/cc.bqn
2021-04-08 03:26:25 +03:00

43 lines
2.1 KiB
BQN
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /usr/bin/env dbqn
args•args
return 1args
args˜ return
"call with argument specifying path of mlochbaum/BQN!"!2args
path(args)"/src/"
args˜1
L {"m_caB(" (𝕩)",(B[]){" (1","¨𝕩)"})"}
LI {"m_cai32("(𝕩)",(i32[]){"(1","¨𝕩)"})"}
# Escape the special characters that appear in BQN sources.
Esc{
in (@+091013)"'""" # Null, Tab, LF, CR, and quotes
out "0tnr" # Whitespace characters changed to letters
i in𝕩
𝕩 i out((i<out)/) 𝕩 # Replace
(i<in) /"\"¨ 𝕩 # Insert \
}
Str "m_str32(U"""Esc""")"˙ # A BQN string
Char {"m_c32(U'"(Esc𝕩)"')"} # A BQN character
Num {s"-"/˜𝕩<0 =|"m_f64("")"˜s| "m_f64("s"1.0/0.0)"𝕩} # Format number
F # Format number
Import •Import path
FChars •FChars path
compile Import "c.bqn"
useInd "-i"args args˜useInd
Comp (3+useInd) ((<"inc(runtime[""])"˙)¨62)Compile
J \n¨
Fconst @NumChar, Str,
prov {"inc("𝕩")"}¨"bi_type""bi_fill""bi_log""bi_grLen""bi_grOrd""bi_asrt""bi_add""bi_sub""bi_mul""bi_div""bi_pow""bi_floor""bi_eq""bi_le""bi_fne""bi_shape""bi_pick""bi_ud""bi_tbl""bi_scan""bi_fillBy""bi_val"
Fout {((𝕩)LI F¨,L ·prov(𝕨0) Fconst¨,L (LI F¨)¨,L (L F¨)¨) {𝕎𝕩}¨ 𝕩}
Frun 1Fout
Long {¯2𝕩¨<","\n}
•Out(¬return) ("r""c""f""e")
{𝕩reflenImport "pr.bqn"Long Frun len(1)Comp ref}
{𝕩Long Fout Comp FChars "c.bqn"}
{𝕩Long Fout Comp FChars "f.bqn"}
{𝕩Long Fout Comp "Modify←GetHighlights←⊢⋄" (FChars )".bqn"¨ "../svg""e"}
¯1 · J LFoutComp¨
args