From a0c4516e2faf2ff864899f91daa808f855b66455 Mon Sep 17 00:00:00 2001 From: Marko Durkovic Date: Fri, 23 Sep 2022 12:15:08 +0200 Subject: [PATCH] Fix parsing of members starting with `string` --- src/rosbags/typesys/idl.py | 2 +- tests/test_parse.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/rosbags/typesys/idl.py b/src/rosbags/typesys/idl.py index cd8d3b47..8fee131b 100644 --- a/src/rosbags/typesys/idl.py +++ b/src/rosbags/typesys/idl.py @@ -169,7 +169,7 @@ octet_type string_type = 'string' '<' expression '>' - / 'string' + / 'string\b' scoped_name = identifier '::' scoped_name diff --git a/tests/test_parse.py b/tests/test_parse.py index 129f16d2..49e6f1b4 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -154,6 +154,17 @@ module test_msgs { }; """ +IDL_STRINGARRAY = """ +module test_msgs { + module msg { + typedef string string__3[3]; + struct Strings { + string__3 values; + }; + }; +}; +""" + def test_parse_empty_msg() -> None: """Test msg parser with empty message.""" @@ -291,6 +302,13 @@ def test_parse_idl() -> None: assert fields[0][0] == 'i' assert fields[0][1][1] == 'int' + ret = get_types_from_idl(IDL_STRINGARRAY) + consts, fields = ret['test_msgs/msg/Strings'] + assert consts == [] + assert len(fields) == 1 + assert fields[0][0] == 'values' + assert fields[0][1] == (Nodetype.ARRAY, ((Nodetype.NAME, 'string'), 3)) + def test_register_types() -> None: """Test type registeration."""