Skip to content

Commit

Permalink
添加对条件多次取反的功能
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks committed Jul 30, 2023
1 parent 861699a commit e413fc7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 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.1"
version = "0.6.2"
edition = "2021"

authors = ["A4-Tacks <[email protected]>"]
Expand Down
9 changes: 9 additions & 0 deletions src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,15 @@ mod tests {
[r#"goto :a ! x;"#, r#"goto :a x == false;"#],
[r#"goto :a ! _;"#, r#"goto :a 0 != 0;"#],
[r#"goto :a lnot _;"#, r#"goto :a 0 != 0;"#],
// 多次取反
[r#"goto :a !!! x == y;"#, r#"goto :a x != y;"#],
[r#"goto :a !!! x != y;"#, r#"goto :a x == y;"#],
[r#"goto :a !!! x < y;"#, r#"goto :a x >= y;"#],
[r#"goto :a !!! x > y;"#, r#"goto :a x <= y;"#],
[r#"goto :a !!! x <= y;"#, r#"goto :a x > y;"#],
[r#"goto :a !!! x >= y;"#, r#"goto :a x < y;"#],
[r#"goto :a !!! x;"#, r#"goto :a x == false;"#],
[r#"goto :a !!! _;"#, r#"goto :a 0 != 0;"#],
];
for [src, dst] in datas {
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/syntax_def.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ JumpCmpBody: JumpCmp = {

pub JumpCmp: JumpCmp = {
JumpCmpBody,
Or<"lnot", "!"> <JumpCmpBody> => <>.reverse(),
Or<"lnot", "!"> <JumpCmp> => <>.reverse(),
}

pub Op: Op = {
Expand Down

0 comments on commit e413fc7

Please sign in to comment.