Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pilota-thrift-parser): compatible with separators after syntax item blocks in idl #284

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 pilota-thrift-parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pilota-thrift-parser"
version = "0.11.3"
version = "0.11.4"
edition = "2021"
description = "Pilota thrift Parser."
documentation = "https://docs.rs/pilota"
Expand Down
3 changes: 1 addition & 2 deletions pilota-thrift-parser/src/parser/enum_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ impl Parser for EnumValue {
opt(blank),
opt(Annotations::parse),
opt(list_separator),
opt(blank),
)),
|(name, _, value, _, annotations, _, _)| EnumValue {
|(name, _, value, _, annotations, _)| EnumValue {
name,
value,
annotations: annotations.unwrap_or_default(),
Expand Down
3 changes: 2 additions & 1 deletion pilota-thrift-parser/src/parser/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ impl Parser for Service {
tag("}"),
opt(blank),
opt(Annotations::parse),
opt(list_separator),
)),
|(_, _, name, extends, _, _, functions, _, _, _, annotations)| Service {
|(_, _, name, extends, _, _, functions, _, _, _, annotations, _)| Service {
name,
extends,
functions,
Expand Down
3 changes: 2 additions & 1 deletion pilota-thrift-parser/src/parser/struct_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ impl Parser for StructLike {
tag("}"),
opt(blank),
opt(Annotations::parse),
opt(list_separator),
)),
|(name, _, _, fields, _, _, _, annotations)| StructLike {
|(name, _, _, fields, _, _, _, annotations, _)| StructLike {
name,
fields,
annotations: annotations.unwrap_or_default(),
Expand Down
27 changes: 27 additions & 0 deletions pilota-thrift-parser/src/parser/thrift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,31 @@ mod tests {
"#;
let (_remain, _res) = File::parse(body).unwrap();
}

#[test]
fn test_separator() {
let body = r#"typedef i32 MyInt32
typedef string MyString;

struct TypedefTestStruct {
1: MyInt32 field_MyInt32;
2: MyString field_MyString;
3: i32 field_Int32;
4: string field_String;
};

typedef TypedefTestStruct MyStruct,

const list<string> TEST_LIST = [
"hello",
"world",
];

service Service {
MyStruct testEpisode(1:MyStruct arg)
},"#;
let (remain, res) = File::parse(body).unwrap();
assert!(remain.is_empty());
assert_eq!(res.items.len(), 6);
}
}
3 changes: 2 additions & 1 deletion pilota-thrift-parser/src/parser/typedef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ impl Parser for Typedef {
Ident::parse,
opt(blank),
opt(Annotations::parse),
opt(list_separator),
)),
|(_, _, r#type, _, alias, _, annotations)| Typedef {
|(_, _, r#type, _, alias, _, annotations, _)| Typedef {
r#type,
alias,
annotations: annotations.unwrap_or_default(),
Expand Down
Loading