designate an initializer's element by its index
[3] in braces reached the writer as a subscript of one operand, and sexc died taking the second.
This commit is contained in:
@@ -378,7 +378,7 @@ forms, and what remains."
|
||||
(let loop ((es elements) (acc (list)))
|
||||
(match es
|
||||
(() (reverse acc))
|
||||
(((? designator? d))
|
||||
(((or (? designator? d) (and ('¤ _) d)))
|
||||
(sex-error elements "designated initializer without a value" d))
|
||||
(((? designator? d) value . rest)
|
||||
(loop rest
|
||||
@@ -386,6 +386,12 @@ forms, and what remains."
|
||||
(atom-to-fmt-c (designator-field d))
|
||||
(walk-expr value))
|
||||
acc)))
|
||||
;; [3] 1: an element named by its index. A subscript has two
|
||||
;; operands, so one alone can be nothing else
|
||||
((('¤ index) value . rest)
|
||||
(loop rest
|
||||
(cons (list '%designate-index (walk-expr index) (walk-expr value))
|
||||
acc)))
|
||||
((e . rest) (loop rest (cons (walk-expr e) acc))))))
|
||||
|
||||
(define (designator? x)
|
||||
|
||||
Reference in New Issue
Block a user