From 8c870c3d707763e197538c0aedc67f940fbd5587 Mon Sep 17 00:00:00 2001 From: Hans-Joachim Krauch Date: Tue, 14 May 2024 09:22:33 -0300 Subject: [PATCH] support `include` as a field name (#166) ### 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. --- packages/omgidl-parser/src/idl.ne | 1 - packages/omgidl-parser/src/parseIDL.test.ts | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/omgidl-parser/src/idl.ne b/packages/omgidl-parser/src/idl.ne index aa541c1..595d280 100644 --- a/packages/omgidl-parser/src/idl.ne +++ b/packages/omgidl-parser/src/idl.ne @@ -7,7 +7,6 @@ const keywords = [ , "module" , "enum" , "const" - , "include" , "typedef" , "union" , "switch" diff --git a/packages/omgidl-parser/src/parseIDL.test.ts b/packages/omgidl-parser/src/parseIDL.test.ts index a0458e9..eeeffcb 100644 --- a/packages/omgidl-parser/src/parseIDL.test.ts +++ b/packages/omgidl-parser/src/parseIDL.test.ts @@ -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", + }, + ], + }, + ]); + }); });