Files
sex/example/test-list.sex
alex-eg 42d58d3359 split semantic processing and fmt-c code generation
Introducing Sex SEMantic ENgine: the semen.
Also split reader to other file (it can be replaced in the future).
Macro expansion inside Sex code doesn't work yet, and it must be done
in semen, not during fmt-c generation as before.
2025-09-24 20:12:08 +03:00

44 lines
1.0 KiB
Scheme

(include stdlib.h)
(include stddef.h)
(include stdio.h)
(import list)
(struct foo
((float a-field)
(int b)
((const char *) c)
((fn bool ((bool val))) not)))
(var (struct foo) f)
(list-T int)
(make-list-T int #f)
(add-value-list-T int #f)
(length-list-T int #f)
(is-empty-list-T int #f)
(extern fn void puk ((int a) (float b)))
(pub fn bool baz () (return true))
(extern var int i)
(var int j)
(pub var int k)
(pub fn int main ()
(var (struct list-int) *l (make-list-int))
(printf "Size of the list: %lu\n" (length-list-int l))
(add-value-list-int l 3)
(add-value-list-int l 4)
(printf "Size of the list: %lu\n" (length-list-int l))
(list-for-each (struct list-int) l int v
(printf "%d " v))
(printf "\n")
(printf "Size of the list: %lu\n" (length-list-int l))
(printf "%p\n" (cast void* l->next))
(return 0))
(pub fn void print-list (((const struct list-int) *l))
(list-for-each (const struct list-int) l int v (printf "%d " v))
(printf "\n"))