[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Demexp-dev] XDR file compilation issue

From: Thomas Petazzoni
Subject: [Demexp-dev] XDR file compilation issue
Date: Sun, 17 Apr 2005 15:45:51 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050331)


I've tried to compile the messages.xdr file of DemExp with an other RPC Generator, and ran into problems :

Syntax error at 'question_status_e' (lineno 85)
Syntax error at 'info_on_participant_t' (lineno 119)
Syntax error at 'info_on_tag_t' (lineno 139)
Syntax error at 'question_tag_set_t' (lineno 149)

I've traced down the problem, and found that it came from the use of «enum type» instead of «type» when declaring types using a previously defined type.

Example of what contains messages.xdr :

 enum { b = 1, c = 1 } mytype;

 struct blabla {
   enum mytype m;

 struct toto {
   struct blabla meuh;

First of all, I thought it was a bug of my RPC Generator. In fact, after reading RFC 1014 (, I think the problem is a laxism in the Ocaml RPC Generator : «struct blabla meuh» should not be allowed.

In section 5.3 of the RFC, you'll find the BNF grammar of the XDR language. Let's take the example of the definition of structure «blabla».

It is a type definition, so we'll start at «type-def» in the grammar. Then it's the definition of the structure, so we have «struct», followed by an identifier, followed by the struct-body, and finally by a «;».

A struct-body is a list of declaration separated by «;», and enclosed in braces. A declaration might be many things.

Our XDR file contains «enum mytype m» as declaration. Suppose it matches the «type-specifier identifier» entry of the declaration: list.

A type-specifier can be an «enum-type-spec», but an enum-type-spec is the string «enum», followed by an enum-body. In our case, the enum body is not inside the declaration of «struct blabla». So it's not the «enum-type-spec» rule that matches in the type-specifier: list. So, I think it is not possible to use «enum mytype m» inside the declaration of a structure.

The correct syntax seems to be :
 struct blabla {
   mytype m;

In this case, the «type-specifier» is simply «identifier», and it works.

Similarly, one should write :

 struct toto {
   blabla meuh;

I am not completely sure of this, since I'm not a BNF expert, but it seems to be confirmed by the example in section 6 of the RFC. In this example, a «union filetype» is defined, and then used directly as «filetype» in the definition of «struct file».

The attached dpatch fixes the problem. The XDR file still compiles with ocamlrpcgen, and DemExp still compiles with it. And my RPC Generator also compiles it ! ;-)

If I'm right, it may be a good idea to report a bug to the developers of ocamlrpcgen to tell them that their RPC generator is too laxist.


PETAZZONI Thomas - address@hidden - Jabber: address@hidden
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7
#! /bin/sh /usr/share/dpatch/dpatch-run
## xdr-conformance.dpatch by  <address@hidden>
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

diff -urNad demexp-0.4/net/messages.xdr.nw 
--- demexp-0.4/net/messages.xdr.nw      2005-03-15 18:50:27.000000000 +0100
+++ /tmp/dpep.sl3ozH/demexp-0.4/net/messages.xdr.nw     2005-04-17 
15:12:00.649797208 +0200
@@ -155,7 +155,7 @@
   question_desc_t q_desc;
   login_t q_info_author;
   date_t q_info_limit_date;
-  enum question_status_e q_info_status;
+  question_status_e q_info_status;
   response_t q_info_responses<MAX_NUMBER_RESPONSES>;
   int q_info_elected_responses<MAX_NUMBER_RESPONSES>;
@@ -199,7 +199,7 @@

 struct participant_info_return_t {
   return_code_t participant_info_rc;
-  struct info_on_participant_t participant_info<MAX_NUMBER_IDS>;
+  info_on_participant_t participant_info<MAX_NUMBER_IDS>;

@@ -227,7 +227,7 @@

 struct tag_info_return_t {
   return_code_t tag_info_rc;
-  struct info_on_tag_t tag_info<MAX_NUMBER_IDS>;
+  info_on_tag_t tag_info<MAX_NUMBER_IDS>;

@@ -241,7 +241,7 @@

 struct tag_set_group_t {
   return_code_t tag_set_group_rc;
-  struct question_tag_set_t tag_set_group<MAX_NUMBER_IDS>;
+  question_tag_set_t tag_set_group<MAX_NUMBER_IDS>;

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]