Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idl-parser 3.0.0: idl parse error observed when idl contains a struct which references an array typedef #150

Closed
srchaitu2008 opened this issue Jul 8, 2024 · 3 comments · Fixed by #151

Comments

@srchaitu2008
Copy link

srchaitu2008 commented Jul 8, 2024

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
Copy link
Author

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 added a commit that referenced this issue Jul 11, 2024
Signed-off-by: Ricardo González Moreno <[email protected]>
richiware added a commit that referenced this issue Jul 11, 2024
Signed-off-by: Ricardo González Moreno <[email protected]>
@srchaitu2008
Copy link
Author

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
Copy link
Author

Hi @richiware ,

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

richiware added a commit that referenced this issue Jul 26, 2024
Signed-off-by: Ricardo González Moreno <[email protected]>
richiware added a commit that referenced this issue Jul 26, 2024
* Refs #21343. Fixes #150

Signed-off-by: Ricardo González Moreno <[email protected]>

* Apply suggestion

Co-authored-by: Eduardo Ponz Segrelles <[email protected]>

---------

Signed-off-by: Ricardo González Moreno <[email protected]>
Co-authored-by: Eduardo Ponz Segrelles <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant