leader->group_name = name;
 }
 
-/* list_event is assumed to point to malloc'ed memory */
-void parse_events_update_lists(struct list_head *list_event,
-                              struct list_head *list_all)
-{
-       /*
-        * Called for single event definition. Update the
-        * 'all event' list, and reinit the 'single event'
-        * list, for next event definition.
-        */
-       list_splice_tail(list_event, list_all);
-       free(list_event);
-}
-
 struct event_modifier {
        int eu;
        int ek;
 
                                        void *loc_);
 
 void parse_events__set_leader(char *name, struct list_head *list);
-void parse_events_update_lists(struct list_head *list_event,
-                              struct list_head *list_all);
 void parse_events_evlist_error(struct parse_events_state *parse_state,
                               int idx, const char *str);
 
 
 }
 %%
 
+ /*
+  * Entry points. We are either parsing events or terminals. Just terminal
+  * parsing is used for parsing events in sysfs.
+  */
 start:
 PE_START_EVENTS start_events
 |
 
 start_events: groups
 {
+       /* Take the parsed events, groups.. and place into parse_state. */
+       struct list_head *groups  = $1;
        struct parse_events_state *parse_state = _parse_state;
 
-       /* frees $1 */
-       parse_events_update_lists($1, &parse_state->list);
+       list_splice_tail(groups, &parse_state->list);
+       free(groups);
 }
 
-groups:
+groups: /* A list of groups or events. */
 groups ',' group
 {
-       struct list_head *list  = $1;
-       struct list_head *group = $3;
+       /* Merge group into the list of events/groups. */
+       struct list_head *groups  = $1;
+       struct list_head *group  = $3;
 
-       /* frees $3 */
-       parse_events_update_lists(group, list);
-       $$ = list;
+       list_splice_tail(group, groups);
+       free(group);
+       $$ = groups;
 }
 |
 groups ',' event
 {
-       struct list_head *list  = $1;
+       /* Merge event into the list of events/groups. */
+       struct list_head *groups  = $1;
        struct list_head *event = $3;
 
-       /* frees $3 */
-       parse_events_update_lists(event, list);
-       $$ = list;
+
+       list_splice_tail(event, groups);
+       free(event);
+       $$ = groups;
 }
 |
 group
 events:
 events ',' event
 {
+       struct list_head *events  = $1;
        struct list_head *event = $3;
-       struct list_head *list  = $1;
 
-       /* frees $3 */
-       parse_events_update_lists(event, list);
-       $$ = list;
+       list_splice_tail(event, events);
+       free(event);
+       $$ = events;
 }
 |
 event