let sizeof take a type that looks like an expression

(* char) is a pointer type and (* p) a dereference, and only the names
in scope tell them apart, so semen decides and marks a type for the
writer. Before, both were walked as expressions: sizeof(*char).

Fixes #52.
This commit is contained in:
2026-10-09 16:04:00 +03:00
parent f0a1b6712f
commit ab4fdc54f3
5 changed files with 59 additions and 2 deletions

View File

@@ -201,6 +201,9 @@ forms, and what remains."
;; path lowers to where the thing it reads from is a pointer
(('%-> . rest) (cons '%-> (map walk-expr rest)))
(('var . _) (walk-var form))
;; semen has told a type from an expression; only it knows the names
;; in scope that make `(* p)' one or the other
(('sizeof ('%type type)) `(%sizeof-type ,(walk-type type)))
;; semen has already put the target first, the way C writes it
(('typedef type name)
`(typedef ,(walk-type type) ,(atom-to-fmt-c name)))