- //event can have STRUCT, TYPEREF or NOTHING
- getLAnglebracket(in);
-
- token = getToken(in);
- if(in->type == FORWARDSLASH){ //</event> NOTHING
- ev->type = NULL;
- }else if(in->type == NAME){
- if(strcmp("struct",token)==0 || strcmp("typeref",token)==0){
- ungetToken(in);
- ev->type = parseType(in,NULL, unnamed_types, named_types);
- if(ev->type->type != STRUCT && ev->type->type != NONE)
- in->error(in,"type must be a struct");
- }else in->error(in, "not a valid type");
-
- getLAnglebracket(in);
- getForwardslash(in);
- }else in->error(in,"not a struct type");
-
- token = getName(in);
- if(strcmp("event",token))in->error(in,"not an event definition");
- getRAnglebracket(in); //</event>
+ int got_end = 0;
+ /* Events can have multiple fields. each field form at least a function
+ * parameter of the logging function. */
+ while(!got_end) {
+ getLAnglebracket(in);
+ token = getToken(in);
+
+ switch(in->type) {
+ case FORWARDSLASH: /* </event> */
+ token = getName(in);
+ if(strcmp("event",token))in->error(in,"not an event definition");
+ getRAnglebracket(in); //</event>
+ got_end = 1;
+ break;
+ case NAME: /* a field */
+ if(strcmp("field",token))in->error(in,"expecting a field");
+ f = (field_t *)memAlloc(sizeof(field_t));
+ sequence_push(&(ev->fields),f);
+ parseFields(in, f, unnamed_types, named_types);
+ break;
+ default:
+ in->error(in, "expecting </event> or <field >");
+ break;
+ }
+ }
+#if 0
+ if(in->type == FORWARDSLASH){ //</event> NOTHING
+ ev->type = NULL;
+ }else if(in->type == NAME){
+ if(strcmp("struct",token)==0 || strcmp("typeref",token)==0){
+ ungetToken(in);
+ ev->type = parseType(in,NULL, unnamed_types, named_types);
+ if(ev->type->type != STRUCT && ev->type->type != NONE)
+ in->error(in,"type must be a struct");
+ }else in->error(in, "not a valid type");
+
+ getLAnglebracket(in);
+ getForwardslash(in);
+ }else in->error(in,"not a struct type");
+ getLAnglebracket(in);
+ getForwardslash(in);
+ token = getName(in);
+ if(strcmp("event",token))in->error(in,"not an event definition");
+ getRAnglebracket(in); //</event>
+#endif //0