-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmdlang.r
70 lines (43 loc) · 937 Bytes
/
cmdlang.r
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
rebol []
m: make object! [
r1: 0
r2: 0
r3: 0
]
instructions: [ add-cmd | mul-cmd | clr-cmd | rot-cmd | put-cmd | display-cmd ]
add-cmd: [ 'add set n integer! ( m/r1: m/r1 + n ) ]
mul-cmd: [ 'mul set n integer! ( m/r1: m/r1 * n ) ]
clr-cmd: [ 'clr ( m/r1: 0 ) ]
rot-cmd: [ 'rot ( tmp: m/r1
m/r1: m/r2
m/r2: m/r3
m/r3: tmp ) ]
put-cmd: [ 'put set n integer! set x integer!
( blk: reduce [ to set-path! rejoin [ "m r" n ] x]
bind blk 'm
do blk ) ]
display-cmd: [ 'display ( print rejoin [ "R1: " m/r1 " R2: " m/r2 " R3: " m/r3 ] ) ]
prog: [ add 100
display
rot
display
add 200
display
rot
mul 10
display
rot
display
add 1
mul 3
rot
put 2 27
display
put 3 78
display
put 1 101
display
clr
display
]
parse prog [ some instructions ]