aboutsummaryrefslogtreecommitdiff
path: root/src/cjs.bqn
blob: 0646fa626c47245b681cf2722351969f11f767b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /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  (@+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  "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"
_getComp  { (3+useInd)  (𝕗 •Import "c.bqn"){𝔽} }
useInd  "-i"≡⊑args•args  args˜useInd
Comp  ((<"runtime" Ind F)¨62) glyphs _getComp 
J  ∾∾(@+10)¨
Fconst  @NumChar, Str, 
Fout  (≠↑F,Fconst,L F¨,F˙) {L𝕎¨𝕩}¨ 
Long   (≠↑13/"  "((@+10)" ,")˙) {𝕎𝕩}¨ 
LFC  LongFoutComp

RT  {
  srcneedinputs𝕩•Import"pr.bqn"
  pr"runtime_0""provide"{(𝕨<(<IndF¨)(↕≠)¨𝕩)˜(𝕩)⊐∾need}((-1+1=𝕩))inputs
  Long Fout pr need _getComp src
}
CArg  {J (¯5↓∾𝕩˙) •FLines "c.bqn"}
SVG  {"Modify←GetHighlights←⊢⋄" •FChars".bqn"¨ "../svg"𝕩}

•Out ("r""r0""r1""c""cc""f""e""p"⊐⊏)
  RT2, RT0, RT1
  {𝕩LFC CArg "⟨""⟩"«∾","¨'"'(⊣∾∾˜)¨glyphs}
  {𝕩LFC "{""}"˜CArg"𝕩"}
  {𝕩LFC •FChars "f.bqn"}
  {𝕩LFC SVG "e"}
  {𝕩LFC SVG "p"}
  ¯1  · J LFoutComp¨
 args