From 75b10f6dd0cc458a615da983f4e8f43708839eb2 Mon Sep 17 00:00:00 2001 From: A4-Tacks Date: Tue, 12 Dec 2023 23:34:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86Ignore=E7=9A=84=E6=BA=90=E7=A0=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=94=B9=E4=B8=BA=E7=A9=BA=E5=9D=97,=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=A9=BA=E5=9D=97=E5=92=8C=E5=86=85=E8=81=94?= =?UTF-8?q?=E5=9D=97=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/syntax/mod.rs | 22 +++++++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 965ac5e..a66d53f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -288,7 +288,7 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mindustry_logic_bang_lang" -version = "0.13.3" +version = "0.13.4" dependencies = [ "display_source", "lalrpop", diff --git a/Cargo.toml b/Cargo.toml index 98ab2c9..98637d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mindustry_logic_bang_lang" -version = "0.13.3" +version = "0.13.4" edition = "2021" authors = ["A4-Tacks "] diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index af1db57..56699d0 100644 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -2271,23 +2271,27 @@ impl DisplaySource for LogicLine { match self { Self::Expand(expand) => { meta.push("{"); - meta.add_lf(); - meta.do_block(|meta| { - expand.display_source(meta); - }); + if !expand.is_empty() { + meta.add_lf(); + meta.do_block(|meta| { + expand.display_source(meta); + }); + } meta.push("}"); }, Self::InlineBlock(block) => { meta.push("inline"); meta.add_space(); meta.push("{"); - meta.add_lf(); - meta.do_block(|meta| { - block.display_source(meta); - }); + if !block.is_empty() { + meta.add_lf(); + meta.do_block(|meta| { + block.display_source(meta); + }); + } meta.push("}"); }, - Self::Ignore => meta.push("# ignore line"), + Self::Ignore => meta.push("{} # ignore line"), Self::NoOp => meta.push("noop;"), Self::Label(lab) => { meta.push(":");