Skip to content

Commit 941d1d7

Browse files
committed
添加在原始标识符内将双引号转换为单引号
1 parent b903329 commit 941d1d7

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mindustry_logic_bang_lang"
3-
version = "0.6.0"
3+
version = "0.6.1"
44
edition = "2021"
55

66
authors = ["A4-Tacks <wdsjxhno1001@163.com>"]

examples/value.mdtlbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ set int 123_456;
4141
set n_int -123_456;
4242
set bin 0b1001_0010;
4343
set n_bin 0b-1001_0010;
44+
set x 'abc"def'; # 其中的双引号会被替换为单引号

src/syntax.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,7 @@ mod tests {
11581158
assert_eq!(parse!(parser, "@abc-def").unwrap(), "@abc-def");
11591159
assert_eq!(parse!(parser, "@abc-def_30").unwrap(), "@abc-def_30");
11601160
assert_eq!(parse!(parser, "@abc-def-34").unwrap(), "@abc-def-34");
1161+
assert_eq!(parse!(parser, r#"'abc"def'"#).unwrap(), "abc'def"); // 双引号被替换为单引号
11611162

11621163
assert!(parse!(parser, "'ab cd'").is_err());
11631164
assert!(parse!(parser, "ab-cd").is_err());

src/syntax_def.lalrpop

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ pub OIdent: Var = r"@[_\p{XID_Start}][\p{XID_Continue}\-]*" => <>.into(); // `@a
5858
pub Number: Var = r"(?:0(?:x-?[\da-fA-F][_\da-fA-F]*|b-?[01][_01]*)|-?\d[_\d]*(?:\.\d[\d_]*)?)"
5959
=> <>.chars().filter(|&c| c != '_').collect();
6060
pub OtherValue: Var = r"'[^'\s]+'" => {
61-
let mut res: Var = <>.chars().skip(1).collect();
62-
res.pop().unwrap();
63-
res
64-
}; // 特殊格式的值, 如`'@abc-def'`
61+
<>[1..<>.len()-1].replace('"', "\'")
62+
}; // 特殊格式的值, 如`'@abc-def'`, 其中双引号会被替换为单引号
6563

6664
// 逻辑里面一个单元
6765
// 例如`0x50` `'@alpha'` `add` `'a-b-c'`

0 commit comments

Comments
 (0)