-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcmps.mdtlbl
More file actions
33 lines (29 loc) · 1.03 KB
/
cmps.mdtlbl
File metadata and controls
33 lines (29 loc) · 1.03 KB
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
#* 这里是介绍0.7.0版本加入的重要语法
cmps, 这个语法内部依照以前的命名JumpCmp, 然后被连接到CmpTree,
是可以通过短路与, 短路或, 单目非将多个条件(JumpCmpBody)组织起来的语法
这可以使得我们写多条件运算变得很容易,
无需像以前一样插入DExp并且不满足条件跳走来实现
短路与的符号为`&&`, 短路或的符号为`||`, 单目非的符号为`!`
注意, 优先级严格递增为`||` < `&&` < `!`
也就是说`a && b || !c && d`被加上等价的括号后为`(a && b) || ((!c) && d)`
*#
do {
op i i + 1;
} while i < 10 && (read $ cell1 i;) != 0;
end;
#* >>>
op add i i 1
jump 4 greaterThanEq i 10
read __0 cell1 i
jump 0 notEqual __0 0
end
*#
# 可以看到, 我们的多条件正确的生成了.
# 我们可以在while skip goto do_while 等地方编写它
# 在0.19.3版本中, 可以使用or and not 来表示 || && !
:x
goto :x a<b and c>d or not e!=2;
#* A >>>
:x
goto :x ((a < b && c > d) || e == 2);
*#