Summary: | tao_idl fails to generate code for bound strings with subtraction operator | ||
---|---|---|---|
Product: | TAO | Reporter: | robert.a.boag |
Component: | IDL Compiler | Assignee: | DOC Center Support List (internal) <tao-support> |
Status: | ASSIGNED --- | ||
Severity: | minor | ||
Priority: | P3 | ||
Version: | 1.4.1 | ||
Hardware: | All | ||
OS: | All | ||
Bug Depends on: | 2821 | ||
Bug Blocks: |
In the IDL compiler front end, the lexer has regular expressions for the usual stuff, including integers with a possible leading '-'. The arithemetic and logical operators are in the parser, as grammar rules for the different types of expressions. So when the lexer sees a '-' and an integer with no whitespace separator, it returns the negative integer as a token, eating up the '-' so the grammar cannot use it. If there is whitespace, then the lexer cannot match the lone '-' to anything so it just passes it through, and the parser can then pick it up. This problem could be fixed by either: - moving the expression operators into the lexer as tokens - removing the optional leading '-' for integer tokens. Then the IDL compiler would have to add negative integers to the tree as unary expressions. This would probably have some consequences that would have to be dealt with Either of these is doable I think, but not trivial, and I'm not sure when there will be time for it. At any rate, I'm assigning the bug to myself. accepted again. Adding a dependency on a new bug entry by Jules Colding. These two bugs are very closely related, since they both revolve around the parsing of the '-' token in expressions. I've tried TAO 1.5.6 on FC6 with the same unfortunate result. The error message is: syntax error tao_idl: "./defines.idl", line 15: Illegal component in scoped name terminate called after throwing an instance of 'FE_Bailout' Just compile the following IDL with tao_idl (without any options) to confirm the error. ############### Sample IDL ################## #ifndef _DEFINES_DEF_ #define _DEFINES_DEF_ #pragma prefix "omc.brutus" module BRUTUS { typedef unsigned long BDEFINE; typedef BDEFINE PT_TYPE; const PT_TYPE BRUTUS_PT_LONG = 0x00000004; const BDEFINE BRUTUS_pidExchangeXmitReservedMin = 0x3FE0; const BDEFINE BRUTUS_PR_AUTO_RESPONSE_SUPPRESS = BRUTUS_PT_LONG | ((BRUTUS_pidExchangeXmitReservedMin - 0x01)<<16); }; // End of module BRUTUS #endif ####################### END ########################## I have a hunch the problem may be in the regular expressions. When the lexer tries to match the input with one of the regular expressions that accepts a leading '-', it will (if I remember correctly) try to match as long a string as possible, and also ignore whitespace, so the expression 5 - 2 is going to cause the tokens IDL_UINTEGER and IDL_INTEGER to be returned, while 5 - - 2 will return IDL_UINTEGER, '-', IDL_INTEGER and will parse correctly (I've tried it). I'm sure there's a way to fix the first case above, but I don't see it at the moment. I'll wait for help or more time to focus on it. Changed host and compiler values above to All. OK. I'm trying to see when to problem arose... TAO 1.5.3 is OK. TAO 1.5.4 is OK. TAO 1.5.5 is NOT OK. so the problem started with 1.5.5. All of my IDL files now compiles with tao_idl from TAO 1.5.7. |
The tao_idl compiler generates syntax errors for strings with lengths defined using a subtraction, "-", operation. As long as the resulting length is positive, this should be legal IDL. The other arithmetic operations are handled correctly. The following code sample illustrates the bug: --- #ifndef BUG_IDL #define BUG_IDL const long MY_STRING_LENGTH = 40; typedef string<MY_STRING_LENGTH-1> MyStringType; #endif // !BUG_IDL --- tao_idl generates the following error messages for this code: --- syntax error tao_idl: "bug.idl", line 6: Illegal syntax or missing '>' after size expr in string tao_idl: "bug.idl", line 6: Illegal syntax or missing '>' after size expr in string tao_idl: "bug.idl", line 6: Illegal syntax or missing '>' after size expr in string tao_idl: "bug.idl", line 6: Illegal syntax or missing '>' after size expr in string tao_idl: bug.idl: found 4 errors Fatal Error - Aborting --- Workaround: Change < typedef string<MY_STRING_LENGTH-1> MyStringType; to > typedef string<MY_STRING_LENGTH - 1> MyStringType; and tao_idl will successfully generate the C++ code.