Skip to content

Commit 9619cec

Browse files
committed
Fix Strings file parser to clearly keys, for avoid change them.
1 parent 011406a commit 9619cec

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

autocorrect/grammar/strings.pest

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ multiline_comment = _{ "/*" ~ (!("*/") ~ ANY)* ~ "*/"}
1010
string_type = _{
1111
("\"" ~ (!(newline | "\"") ~ ANY)* ~ "\"")
1212
}
13-
key = _{ string }
13+
key = @{ string }
1414
key_assigment = ${ (" ")* ~ "=" ~ (" ")* }
15-
string = ${ string_type }
16-
pair = ${ key ~ key_assigment ~ string }
15+
string = @{ string_type }
16+
pair = _{ key ~ key_assigment ~ string }
1717

1818
line = _{ pair | comment | space | other | newline }
1919
item = _{ SOI ~ line* ~ EOI }

autocorrect/src/code/strings.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ mod tests {
2626
2727
"NSCameraUsageDescription" = "开启Wi-Fi后继续使用";
2828
// 单行comment
29-
"中文key测试" = "开启定位权限";
29+
"中文key测试" = "开启GPS定位权限";
30+
"60分" = "60分";
3031
"###;
3132

3233
let expect = r###"
@@ -40,7 +41,8 @@ mod tests {
4041
4142
"NSCameraUsageDescription" = "开启 Wi-Fi 后继续使用";
4243
// 单行 comment
43-
"中文 key 测试" = "开启定位权限";
44+
"中文key测试" = "开启 GPS 定位权限";
45+
"60分" = "60 分";
4446
"###;
4547

4648
assert_eq!(expect, format_strings(example).to_string());

0 commit comments

Comments
 (0)