What causes an “unexpected token” error when running rtiddsgen on an IDL?
Note: Applies to RTI Connext 4.5c and above.
This solution applies if you are seeing errors during rtiddsgen code-generation which look like the following (rtiddsgen used with –language java
for this example):
javax.xml.transform.TransformerException: org.xml.sax.SAXException: /p8core/interface/framework/msg-spec/../temp.idl:706:61:unexpected token: port at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502) at com.rti.ndds.nddsgen.transformation.IDLTransformer.obtainRawXMLFromIDL(IDLTransformer.java:451) at com.rti.ndds.nddsgen.Main.generateSourceCodeFiles(Main.java:1683) at com.rti.ndds.nddsgen.Main.main(Main.java:1090) Caused by: org.xml.sax.SAXException: /p8core/interface/framework/msg-spec/../temp.idl:706:61:unexpected token: port at com.rti.ndds.nddsgen.idlparser.IDLSAXParser.parse(IDLSAXParser.java:148) at com.rti.ndds.nddsgen.idlparser.IDLSAXParser.parse(IDLSAXParser.java:101) at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
As of version 4.5, RTI Connext uses IDL3+ (the new IDL grammar). In IDL3+, port
is a reserved word. So if you want to continue using the word "port" in the generated code, add an underscore ('_
') before "port" ( _port
) in the IDL; then use the rtiddsgen command-line option, -enableEscapeChar
. This option allows you to use '_
' as an escape character in IDL identifiers.
Note: The
-enableEscapeChar
option strips the '_
' character out of your IDL. So if you have other variables which use '_
', they will be affected as well.
IDL3+ adds the following new keywords:
alias
connector
mirrorport
port
porttype
typename
The OMG DDS4CCM specification can be found at http://www.omg.org/spec/dds4ccm/1.0/Beta2/.
For more information on rtiddsgen's -enableEscapeChar
option, see Section 3.3.5 in the RTI Connext Core Libraries and Utilities User's Manual.