From f445d96f1e63f0b2673fda0cb03c0e5d3b5b0a3b Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Mon, 9 Sep 2019 15:11:56 -0700 Subject: [PATCH] fix parsing empty string literal (#409) * fix parsing empty string literal Signed-off-by: Dirk Thomas * add annotation with empty string literal parameter Signed-off-by: Dirk Thomas --- rosidl_parser/rosidl_parser/parser.py | 2 ++ rosidl_parser/test/msg/MyMessage.idl | 1 + 2 files changed, 3 insertions(+) diff --git a/rosidl_parser/rosidl_parser/parser.py b/rosidl_parser/rosidl_parser/parser.py index f9ab0549b..68890400f 100644 --- a/rosidl_parser/rosidl_parser/parser.py +++ b/rosidl_parser/rosidl_parser/parser.py @@ -589,6 +589,8 @@ def get_floating_pt_literal_value(floating_pt_literal): def get_string_literal_value(string_literal, *, allow_unicode=False): + if len(string_literal.children) == 0: + return '' assert len(string_literal.children) == 1 child = string_literal.children[0] assert isinstance(child, Token) diff --git a/rosidl_parser/test/msg/MyMessage.idl b/rosidl_parser/test/msg/MyMessage.idl index 9105e4f3c..451ca3882 100644 --- a/rosidl_parser/test/msg/MyMessage.idl +++ b/rosidl_parser/test/msg/MyMessage.idl @@ -20,6 +20,7 @@ module rosidl_parser { @key @range ( min=-10, max=10 ) long long_value; + @verbatim (language="comment", text="") unsigned long unsigned_long_value; long long long_long_value; unsigned long long unsigned_long_long_value;