Skip to content

Commit

Permalink
support include as a field name (#166)
Browse files Browse the repository at this point in the history
### Changelog
support `include` as a field name

### Docs
None

### Description
We were treating `include` as a keyword in our nearly grammar even
though it is not considered a keyword in the OMGIDL spec. This PR fixes
this which allows to use `include` as a regular field name.
  • Loading branch information
achim-k authored May 14, 2024
1 parent fa6ff16 commit 8c870c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/omgidl-parser/src/idl.ne
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const keywords = [
, "module"
, "enum"
, "const"
, "include"
, "typedef"
, "union"
, "switch"
Expand Down
20 changes: 20 additions & 0 deletions packages/omgidl-parser/src/parseIDL.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2674,4 +2674,24 @@ module rosidl_parser {
};`;
expect(() => parse(msgDef)).toThrow(/unexpected RCBR token: "}"/i);
});
it("supports 'include' as a field name", () => {
const msgDef = `
struct SomeStruct {
boolean include;
};`;
const ast = parseIDL(msgDef);
expect(ast).toEqual([
{
name: "SomeStruct",
aggregatedKind: "struct",
definitions: [
{
name: "include",
isComplex: false,
type: "bool",
},
],
},
]);
});
});

0 comments on commit 8c870c3

Please sign in to comment.