From 48d917f2f18f91e418189b7fc41f7a9651e40b42 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 10 Apr 2020 10:37:51 -0700 Subject: parser: eliminate struct list_accum. As a final round of this recent work, we observe that since the accumulator structure has been reduced to two members, we can eliminate one of them by using a cons cell as the accumulator, and threading the second value through the cdr. That is to say, the listacc grammar rule's semantic value will now be the tail cons of the list being constructed. The cdr of this cons will, temporarily, be a back pointer to the head (making the list temporarily circular). The n_exprs reduction will fix this up; it will put the correct terminating atom in place of the head (either nil, or the dotted item if there is one), and yield the head as the semantic value. * lib.h (struct list_accum): Removed. (Thus, finding a better home for this would, after all, have been a waste of time). * parser.y (lacc, splacc): Static functions removed. (union YYSTYPE): lacc membber removed. (n_exprs): Adjust to new semantic value coming from listacc. (listacc): Now of type val again. Yields pointer to tail cons as semantic value, whose cdr points to the head of the list. --- lib.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 9002fd11..f039568f 100644 --- a/lib.h +++ b/lib.h @@ -337,11 +337,6 @@ union obj { struct dyn_args a; }; -struct list_accum { - obj_t *head; - obj_t *tail; -}; - #if CONFIG_GEN_GC typedef struct { val *ptr; -- cgit v1.2.3