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

Fails to parse our IDL files. #9

Open
r-owen opened this issue Aug 8, 2019 · 1 comment
Open

Fails to parse our IDL files. #9

r-owen opened this issue Aug 8, 2019 · 1 comment

Comments

@r-owen
Copy link

r-owen commented Aug 8, 2019

We have IDL files that we use with OpenSplice DDS. We were hoping to use this parser to parse them, but it doesn't seem to like our data, though the files are simple. Here is one example snippet that fails to parse (which attempts to use all data types, but simpler examples also fail):

module Test {
struct arrays_8dd2d413 {
	  long	TestID;
	  string<8>	private_revCode; //private
	  double	private_sndStamp; //private
	  double	private_rcvStamp; //private
	  long		private_seqNum; //private
	  long		private_origin; //private
	  long		private_host; //private
	  boolean	boolean0[5];
	  octet	byte0[5];
	  string	char0;
	  short	short0[5];
	  long	int0[5];
	  long	long0[5];
	  long long	longLong0[5];
	  octet	octet0[5];
	  unsigned short	unsignedShort0[5];
	  unsigned long	unsignedInt0[5];
	  unsigned long	unsignedLong0[5];
	  float	float0[5];
	  double	double0[5];
	};
#pragma keylist arrays_8dd2d413 TestID
};

The error I see is:

Parsing /home/saluser/tsrepos/ts_idl/idl/sal_revcoded_minimal.idl
Can not find Data Type ()

Traceback (most recent call last):
  File "./parse_one_file.py", line 31, in <module>
    main()
  File "./parse_one_file.py", line 27, in main
    parse_one_idl_str(idl_str)
  File "./parse_one_file.py", line 10, in parse_one_idl_str
    global_module = parser.load(idl_str)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/parser.py", line 71, in load
    self.parse_lines(lines, filepath=filepath)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/parser.py", line 117, in parse_lines
    self._global_module.parse_tokens(self._token_buf, filepath=filepath)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/module.py", line 82, in parse_tokens
    m.parse_tokens(token_buf, filepath=filepath)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/module.py", line 100, in parse_tokens
    s.parse_tokens(token_buf, filepath=filepath)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 133, in parse_tokens
    self._post_process()
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 141, in _post_process
    self.forEachMember(lambda m : m.post_process())
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 155, in forEachMember
    func(m)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 141, in <lambda>
    self.forEachMember(lambda m : m.post_process())
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 72, in post_process
    self._type._name = self.refine_typename(self.type)
  File "/home/saluser/tsrepos/idl_parser/idl_parser/struct.py", line 53, in type
    raise exception.InvalidDataTypeException()
idl_parser.exception.InvalidDataTypeException

This is using Python 3.7.2, in case that is relevant.
Any idea what we'd need to do to make this work?

Also, if that can be fixed, do you have any interest in a pull request for full Python 3 compatibility? (Most of the code seems to work but example.py does not and there is other code that uses print without parenthesis).

@r-owen
Copy link
Author

r-owen commented Aug 12, 2019

There are at least two problems:

  • tabs such as the tab between long and TestID;.
  • The <n> suffix on string.

If I change tabs to spaces and remove the <n> suffix then the file is parsed.

Also we encode enums using pragma and multi-line pragmas are giving problems. Perhaps we should specify enums in a more standard fashion. Here is an example:

struct logevent_heartbeat_407c55f4 {
	  long	WatcherID;
	  string<8>	private_revCode; //private
	  double	private_sndStamp; //private
	  double	private_rcvStamp; //private
	  long		private_seqNum; //private
	  long		private_origin; //private
	  long		private_host; //private
	  boolean	heartbeat;
	  long	priority;
	};
#pragma keylist logevent_heartbeat_407c55f4 WatcherID
		const long Watcher_shared_AlarmSeverity_None=1;
		const long Watcher_shared_AlarmSeverity_Warning=2;
		const long Watcher_shared_AlarmSeverity_Serious=3;
		const long Watcher_shared_AlarmSeverity_Critical=4;
struct logevent_logLevel_df5f83b3 {
	  long	WatcherID;
	  string<8>	private_revCode; //private
	  double	private_sndStamp; //private
	  double	private_rcvStamp; //private
	  long		private_seqNum; //private
	  long		private_origin; //private
	  long		private_host; //private
	  long	level;
	  long	priority;
	};
#pragma keylist logevent_logLevel_df5f83b3 WatcherID

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

No branches or pull requests

1 participant