Skip to content

Commit

Permalink
完成条件表达式(与或非)的编写,
Browse files Browse the repository at this point in the history
并且修复构建过程中申请的临时标记与编译过程中申请的临时标记重复
  • Loading branch information
A4-Tacks committed Jul 31, 2023
1 parent e413fc7 commit 4dfadc2
Show file tree
Hide file tree
Showing 5 changed files with 462 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mindustry_logic_bang_lang"
version = "0.6.2"
version = "0.7.0"
edition = "2021"

authors = ["A4-Tacks <[email protected]>"]
Expand Down
24 changes: 24 additions & 0 deletions examples/cmps.mdtlbl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#* 这里是介绍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 等地方编写它
Loading

0 comments on commit 4dfadc2

Please sign in to comment.