diff --git a/Cargo.lock b/Cargo.lock index 12f86c1..0d03c2c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -884,7 +884,7 @@ dependencies = [ [[package]] name = "pilota-thrift-parser" -version = "0.11.3" +version = "0.11.4" dependencies = [ "nom", ] diff --git a/pilota-thrift-parser/Cargo.toml b/pilota-thrift-parser/Cargo.toml index 6d88345..2fde13b 100644 --- a/pilota-thrift-parser/Cargo.toml +++ b/pilota-thrift-parser/Cargo.toml @@ -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" diff --git a/pilota-thrift-parser/src/parser/enum_.rs b/pilota-thrift-parser/src/parser/enum_.rs index 1a20a90..ee82fdf 100644 --- a/pilota-thrift-parser/src/parser/enum_.rs +++ b/pilota-thrift-parser/src/parser/enum_.rs @@ -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(), diff --git a/pilota-thrift-parser/src/parser/service.rs b/pilota-thrift-parser/src/parser/service.rs index 9550e92..9bc26a9 100644 --- a/pilota-thrift-parser/src/parser/service.rs +++ b/pilota-thrift-parser/src/parser/service.rs @@ -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, diff --git a/pilota-thrift-parser/src/parser/struct_.rs b/pilota-thrift-parser/src/parser/struct_.rs index ca13ec2..9a8e310 100644 --- a/pilota-thrift-parser/src/parser/struct_.rs +++ b/pilota-thrift-parser/src/parser/struct_.rs @@ -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(), diff --git a/pilota-thrift-parser/src/parser/thrift.rs b/pilota-thrift-parser/src/parser/thrift.rs index 8389dc4..edbf6b9 100644 --- a/pilota-thrift-parser/src/parser/thrift.rs +++ b/pilota-thrift-parser/src/parser/thrift.rs @@ -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 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); + } } diff --git a/pilota-thrift-parser/src/parser/typedef.rs b/pilota-thrift-parser/src/parser/typedef.rs index b19d6bc..32e20b6 100644 --- a/pilota-thrift-parser/src/parser/typedef.rs +++ b/pilota-thrift-parser/src/parser/typedef.rs @@ -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(),