Skip to content

Commit 4bb3d1b

Browse files
committed
fix(pilota-thrift-parser): allow annotation list splited by white space chars
1 parent f6aa3f6 commit 4bb3d1b

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed

Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pilota-thrift-parser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pilota-thrift-parser"
3-
version = "0.13.1"
3+
version = "0.13.2"
44
edition.workspace = true
55
homepage.workspace = true
66
repository.workspace = true

pilota-thrift-parser/src/parser/annotation.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl Annotation {
2323
Components::list_separator().padded_by(Components::blank_with_comments().or_not());
2424

2525
let annotation_list = annotation
26-
.separated_by(separator)
27-
.allow_trailing()
26+
.then_ignore(separator.or_not())
27+
.repeated()
2828
.collect::<Vec<Annotation>>()
2929
.padded_by(Components::blank_with_comments().or_not());
3030

@@ -65,7 +65,7 @@ mod tests {
6565
);
6666

6767
let input = r#"(
68-
cpp.type = "DenseFoo",
68+
cpp.type = "DenseFoo"
6969
python.type ="DenseFoo",
7070
go.type ="DenseFoo";
7171
java.final=""
@@ -84,7 +84,7 @@ mod tests {
8484
let input = r#"(
8585
// comment before first annotation
8686
cpp.type = "DenseFoo"; // cpp.type
87-
python.type ="DenseFoo", go.type ="DenseFoo";
87+
python.type ="DenseFoo" go.type ="DenseFoo";
8888
java.final="")"#;
8989
let res = Annotation::get_parser().parse(input).unwrap();
9090
assert_eq!(res.len(), 4);
@@ -106,6 +106,19 @@ mod tests {
106106
assert_eq!(res[0].key, "cpp.type");
107107
assert_eq!(res[0].value.to_string(), "DenseFoo");
108108

109+
let input = r#"(
110+
cpp.type = "DenseFoo" go.type ="DenseFoo"
111+
python.type = "DenseFoo"
112+
)"#;
113+
let res = Annotation::get_parser().parse(input).unwrap();
114+
assert_eq!(res.len(), 3);
115+
assert_eq!(res[0].key, "cpp.type");
116+
assert_eq!(res[0].value.to_string(), "DenseFoo");
117+
assert_eq!(res[1].key, "go.type");
118+
assert_eq!(res[1].value.to_string(), "DenseFoo");
119+
assert_eq!(res[2].key, "python.type");
120+
assert_eq!(res[1].value.to_string(), "DenseFoo");
121+
109122
let input = r#"(
110123
cpp.type = "DenseFoo";
111124
python.type ="DenseFoo", go.type ="DenseFoo"; /* go.type */

0 commit comments

Comments
 (0)