Skip to content

Commit

Permalink
go/ros: ros1msg parser accepts fields separated by tabs and spaces (#843
Browse files Browse the repository at this point in the history
)
  • Loading branch information
james-rms authored Mar 2, 2023
1 parent 4f55815 commit 9db6781
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion go/ros/ros1msg/ros1msg_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

// Field names are restricted to "an alphabetical character followed by any mixture of alphanumeric and underscores",
// per http://wiki.ros.org/msg#Fields
var fieldMatcher = regexp.MustCompile(`([^ ]+) +([a-zA-Z][a-zA-Z0-9_]*)`)
var fieldMatcher = regexp.MustCompile(`([^ \t]+)[ \t]* [ \t]*([a-zA-Z][a-zA-Z0-9_]*)`)

type Type struct {
BaseType string
Expand Down
27 changes: 27 additions & 0 deletions go/ros/ros1msg/ros1msg_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,33 @@ func TestROS1MSGParser(t *testing.T) {
},
},
},
{
"two primitive fields with type and name separated by tab and space",
"",
`string foo
int32 bar
float32 baz`,
[]Field{
{
Name: "foo",
Type: Type{
BaseType: "string",
},
},
{
Name: "bar",
Type: Type{
BaseType: "int32",
},
},
{
Name: "baz",
Type: Type{
BaseType: "float32",
},
},
},
},
{
"primitive variable-length array",
"",
Expand Down

0 comments on commit 9db6781

Please sign in to comment.