ydr patch for rxgen compatibility

Love lha at stacken.kth.se
Tue Jan 18 23:50:03 CET 2000


Derrick J Brashear <shadow at dementia.org> writes:

> The attached patch causes ydr to accept e.g.
> enum foo {
>  BAR,
>  BAZ
> };
> 
> and implicitly assign BAR=0, BAZ=1, which is what rxgen does.
> 
> It will also pick up the numbering after the last explicitly numbered
> entry, deliberately. I didn't look to see what Transarc did in that case.

See what you mean, the patch wasn't complete, and I don't think it would
work for

enum foo { FOO };
enum bar { BAR };

BAR would get 2, wouldn't it ?

But that would be in the part of the patch that you didn't send.

Love

Index: parse.y
===================================================================
RCS file: /afs/stacken.kth.se/src/SourceRepository/arla/ydr/parse.y,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -u -w -r1.21 -r1.22
--- parse.y	1999/09/10 19:12:30	1.21
+++ parse.y	2000/01/18 22:48:19	1.22
@@ -52,6 +52,7 @@
 #include "lex.h"
 
 void yyerror (char *);
+int varcnt = 0;
 
 %}
 
@@ -181,7 +182,7 @@
 		{ error_function = $2; }
 		;
 
-enumbody:	'{' enumentries '}' { $$ = $2; }
+enumbody:	'{' enumentries '}' { $$ = $2; varcnt = 0; }
 		;
 
 enumentries:	{ $$ = listnew (); }
@@ -192,7 +193,9 @@
 		;
 
 enumentry:	T_IDENTIFIER '=' constant
-		{ $$ = createenumentry ($1, $3); }
+ 		{ $$ = createenumentry ($1, $3); varcnt = $3 + 1; }
+  		| T_IDENTIFIER
+  		{ $$ = createenumentry ($1, varcnt++); }
 		;
 
 memberdecl:	T_ASIS memberdecl2





More information about the Arla-drinkers mailing list