eProsima / Fast-DDS-Gen

Fast-DDS IDL code generator tool. Looking for commercial support? Contact info@eprosima.com
Apache License 2.0
77 stars 59 forks source link

fast-dds-gen-3.3.0 with idl-parser 3.0.0 : idl parse error observed when idl contains a struct which references an array typedef [21343] #373

Closed srchaitu2008 closed 3 days ago

srchaitu2008 commented 2 weeks ago

The below mentioned idl file parsing fails with below mentioned error (idl-parser 3.0.0 is used alongwith fast-dds-gen 3.3.0) :

IDL file:

module module1 { enum mod1_enum_val { value1, //1 value2 //2 }; //mod1_enum_val }; //module1 const module1::mod1_enum_val enum1 = module1::mod1_enum_val::value1; typedef string StringU; typedef int32 IntArray[23]; struct SampleStruct { StringU stringU; IntArray ArrayInt32; }; //SampleStruct

Error:

Processing the file /tmp/IdlParseError.idl... /tmp/IdlParseError.idl:11:26: error: Error evaluating array dimension: ;enum1=module1::mod1_enum_val::value1;enum1=module1::mod1_enum_val::value1;(23) | 0 /tmp/IdlParseError.idl:15:3: error: 'IntArray' was not defined previously

In the above idl file, there is a struct which tries to declare an int array as typedef. One observation is that when the enum declaration (const module1::mod1_enum_val enum1 = module1::mod1_enum_val::value1;) is removed/commented, the parsing works fine.

Below command is used :

\<Path to java11 exe> -jar \<path to fastddsgen.jar> -replace -ppDisable -d \<path to folder where files should be generated> \<path to IdlParseError.idl file>

For example:

"/home/user/java11/jre/bin/java" -jar "/home/user/fastddsgen.jar" -replace -ppDisable -d "/home/user/SampleFolder" "/home/user/IdlParseError.idl"

srchaitu2008 commented 2 weeks ago

Additionally, please check the below IDL file as well:

module Top { const uint32 MAXLEN = 64; const uint32 SeqLenAssumingThisModule = MAXLEN; const uint32 SeqLen = Top::MAXLEN; }; //Top struct Sub { int32 userID; double f64Data; uint8 vChar; }; //Sub typedef Sub SubSequence[Top::SeqLen]; struct AllSubs { SubSequence Subs; }; //AllSubs

Similar error is encountered:

Processing the file /tmp/IdlParseError_2.idl... /tmp/IdlParseError_2.idl:13:36: error: Error evaluating array dimension: ;Top_MAXLEN=64;Top_SeqLenAssumingThisModule=MAXLEN;Top_SeqLen=Top::MAXLEN;(Top_SeqLen) | 0 /tmp/IdlParseError_2.idl:16:3: error: 'SubSequence' was not defined previously

richiware commented 2 weeks ago

Thanks for the report. We will take it into a look.

srchaitu2008 commented 2 weeks ago

Hi @richiware ,

I have tried the fix and the previously mentioned IDL files are processing successfully.

Given below is another IDL file for which the processing fails with this fix as well:

module module1 { enum mod1_enum_val { value1, value2 }; //mod1_enum_val
}; //module1
const int32 myValUsingFullPathAsInt32 = module1::mod1_enum_val::value1; const module1::mod1_enum_val myValUsingFullPath = module1::mod1_enum_val::value1; const module1::mod1_enum_val myVal = module1::mod1_enum_val::value2; module Top { const uint32 MAXLEN = 64; const uint32 SeqLenAssumingThisModule = MAXLEN; const uint32 SeqLen = Top::MAXLEN; }; //Top
struct Sub { int32 userID; double f64Data; uint8 vChar; }; //Sub
enum Modes { MODE1, //11
MODE2, //20
MODE3 //200
}; //Modes
const int32 myDefaultModeAsInt32 = Modes::MODE3; const Modes myDefaultMode = Modes::MODE3; const Modes myDefaultMode1 = Modes::MODE2; typedef Sub SubSequence[Top::SeqLen]; struct AllSubs { SubSequence Subs; }; //AllSubs

Error

Processing the file /tmp/IdlError3.idl... /tmp/IdlError3.idl:9:70: error: Error evaluating expression: ;(module1_mod1_enum_val_value1) | 0 /tmp/IdlError3.idl:30:47: error: Error evaluating expression: ;Top_MAXLEN=64;Top_SeqLenAssumingThisModule=64;Top_SeqLen=64;(Modes_MODE3) | 0

Requesting you to take a look at this as well.

srchaitu2008 commented 2 weeks ago

Hi @richiware ,

Can you please take a look at the above IDL file as well?

richiware commented 1 week ago

I was testing your last IDL file. The failure is caused by the integer constant that is set with a enumeration value. This corner case will be more difficult to be supported and right now I don't have that time.

I propose you to open a new issue for this new case and we will fix it when we have time and this issue could be closed automatically when the related PR are merged.

srchaitu2008 commented 3 days ago

Hi @richiware ,

As requested in earlier comments, raised issue 385 for IDL parse error when integer constant is set with enum value.

Thanking you, S.Ravi.Chaitanya