aboutsummaryrefslogtreecommitdiff
path: root/tutorial/evalexp.bqn
blob: eff3aad2f1962d0ad89e8e63f46784aeb9b6d2d6 (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
48
49
50
51
52
53
54
wh  10.7524
pad wh×21
to  1+wh÷23
t   10

ps  At "class=Paren|stroke=currentColor|fill=none|stroke-width=1"
rc  At "class=code|stroke-width=1|rx=10"
gr  "g" At "font-family=BQN,monospace|font-size=18px"
gt  "g" At "text-anchor=middle"
gb  "g" At "class=codeCover|stroke-width=6|stroke-linejoin=round"
gf  "g" At "font-size=15px|opacity=0.9"
Shadow  {
  t  (0,0¯2+𝕨) ("text" Attr Pos)Enc¨ (⊢≍Highlight¨) ¨𝕩
  gt Enc gb,gf Enc¨<˘ t
}

Compile  (62)(•Import "../src/c.bqn")
DrawEval{
  bconstblki  Compile 𝕩
  babcbobp  '0'-˜ # For each instruction, number of:
    "11111000000000010000022000"  # Arguments
    "000//232323223102303200121"  # Stack values consumed
    "11111111111111011101111111"  # Stack values output
    "00000110111001001101000100"  # Position determiner
  
  m  { # Mask of instruction starts
    a  ba(⊣⊏˜>×⊢)b
    na  (≠-(1+↕)(»·`×)) <128 b
    n  1+{(𝕩=a) +˝× >⊏na𝕩↕≠a}3
    ! ´ < n
    Se{(˜𝕨)Se 1¨((𝕩/𝕨))𝕩}(0=¯1⊑⊢)
    (≠↑∾≠Se 10¨) n
  }
  mbmi  m/¨ bi
  mi˜¯1

  r+`(mbbo)-nambbc
  ! 1=¯1r
  p((¯1r)(r+⊒))⊏/na
  j¯1mi˜˜{s𝕩˜g𝕩(g/˜(s)=smbbp)((s))↕≠mb}p
  jej¯1.25
  d+`×f0<na
  f˜p
  q(/fjpje) (⊏≍⊣) p

  pd  <˘˜˝ q  wh×0.60.1+jed
  dim (wh×𝕩,2+⌈´d)+20×pad
  (5120(⊣∾˜(t+pad)-˜-˜÷2˙)dim+2×t) SVG gr Enc ∾⥊¨
    <"rect" Elt rc(Pos-pad)"width""height"˘FmtNum¨dim
    <"text" Enc Highlight 𝕩
    (<"path" Elt ps"d"<·"MVH"Fmt¨)˘ pd
    mi ((to+wh×≍)¨Shadow⊏𝕩)(d)((¬f)/) p
  
}