188 Commits

Author SHA1 Message Date
ca88d9b386 implement compound and designated literals support
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m46s
Sex CI / build-linux (push) Successful in 4m50s
2026-09-27 19:35:37 +03:00
a9b00f2135 use true bool, since we target c99 onwards 2026-09-27 18:06:59 +03:00
26e8e6c374 fix lambdas and add a test to prevent rotting
Lambdas rotted because there wasn't any test for them, and after
return type moved to the end, lambdas stayed assumning it in the
front. We fix this and add test program
2026-09-27 16:11:05 +03:00
62316e1e3d enable includes to have multiple targets
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m47s
Sex CI / build-linux (push) Successful in 4m47s
2026-09-26 16:54:51 +03:00
Pavel Kulyov
b1ab18b9af dev: require make deps manually for dev & CI
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m50s
Sex CI / build-linux (push) Successful in 4m52s
2026-09-24 01:10:59 +03:00
e0987c1836 read the feature flags in sextest in the way sexc does
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m54s
Sex CI / build-linux (push) Successful in 4m48s
sextest resolves #+ and #- itself -- it reads the program and prints
what survives to sexc -- so a flag spelling it does not recognise
decides which branch gets compiled
2026-09-23 14:35:56 +03:00
ee053e35c9 look past comments in a public form's header 2026-09-23 14:35:55 +03:00
534e9ef56b say what is wrong with a pointer type, and stop mangling fn ones
The guard against nested pointer chains searched every sublist for a
`*', including the ones that hold a type of their own.

A function type with a pointer parameter, while the same type with an int
parameter passed. (* [char 4]) was let through as well and came out
as `vector-ref char 4 * p'.

A `*' inside an array or a function type belongs to that type, so the
search stops there. What the flat conversion cannot express is now
named: a fn type is a function pointer already, and a pointer to an
array is not supported.

Parameters of a function type are walked without their names. C writes
a parameter name into a declarator and a type has none, so fmt-c prints
whatever it is handed there as a type: `(s (* char))' came out as
`char(*) s'.

fmt-c printed a nameless array declarator's #f into the C, which showed
up in these parameters.
2026-09-23 14:31:41 +03:00
381ad21d8b separate tags and typedefs
C has two namespaces and the database had one. A typedef of a tag's
name wiped it.

Tags, i.e. struct, enum and union, share one namespace; they move to a
table of their own. A name resolves the way C does: the ordinary
identifier first, the tag when that leads nowhere.

While resolving a typedef, the target was taken apart with cadr
whatever it was, so (typedef points (¤ point 4)) reported point's
fields as its own -- an array of four points claiming to be a point,
and a macro reaching through it with v->x. Only a name and
(struct|union|enum NAME) name a type now.
2026-09-23 14:31:41 +03:00
e0a228c66e make feature guard produce nothing on eof/closing bracket/paren
A dropped datum is replaced by whatever follows it, but what follows
may be the end of the file or the paren closing the list we are
in. Hand the token back to the caller instead: read-list closes its
list with it and the toplevel loop stops.

A `;' comment between a guard and the form it guards was also taken for
the guarded datum, so the form stayed unconditional and the guard did
nothing. Skip comments when reading the guard.

comment-form? was defined three times over; it moves to utils.
2026-09-23 14:31:38 +03:00
Pavel Kulyov
d0e2c699e3 semen: fix premature negative cases merge hehe
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m47s
Sex CI / build-linux (push) Successful in 4m50s
2026-09-22 23:40:16 +03:00
Pavel Kulyov
434086ade8 tests: add docstring cases
Some checks failed
Sex CI / build-linux (pull_request) Failing after 4m47s
Sex CI / build-linux (push) Failing after 4m50s
2026-09-21 22:24:47 +03:00
Pavel Kulyov
1685b0c31f semen: process fn docstrings 2026-09-21 22:24:04 +03:00
Pavel Kulyov
720bff3437 semen: add and use fn core prototype getter 2026-09-20 15:40:29 +03:00
Pavel Kulyov
8588f5a531 semen: extract counting header length into a function 2026-09-20 15:33:09 +03:00
Pavel Kulyov
05929951cb modules: save fn docstring in prototype 2026-09-20 00:39:05 +03:00
Pavel Kulyov
ca71ae6e91 ci: drop manual eggs installation
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m45s
Sex CI / build-linux (push) Successful in 4m47s
2026-09-18 00:43:29 +03:00
Pavel Kulyov
0256aa8a22 deps: lock versions 2026-09-18 00:43:13 +03:00
Pavel Kulyov
c0a34fc64c readme: update installation docs 2026-09-18 00:43:13 +03:00
Pavel Kulyov
94c4a7008f infra: pepper some GNU on top of Makefile 2026-09-18 00:43:13 +03:00
Pavel Kulyov
e2fb4adae5 readme: add docs about static compilation 2026-09-18 00:26:17 +03:00
Pavel Kulyov
e3da2a1e79 Update gitignore 2026-09-18 00:26:17 +03:00
Pavel Kulyov
79ce3dace2 Add project-local dependencies installation 2026-09-18 00:26:16 +03:00
a221e0f8ea build the triangle on Linux too
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m44s
Sex CI / build-linux (push) Successful in 5m18s
<OpenGL/gl3.h> does not exist there and -framework is not a gcc flag,
so the documented build line failed with no hint why. #+macosx picks
the header now, and both build lines are in the file -- pkg-config
carries the flags on either platform, apart from Apple's GL framework,
which has no pkg-config file to carry.
2026-09-16 18:01:02 +03:00
bf83baa508 read-time feature expressions
'#+' and '#-' introduce conditional compilation: the form that follows
is kept only when the feature expression is true, and otherwise is read
and thrown away.  An expression is a feature name, or and / or / not
of them.

They are read time, not compile time.

Default features are the host's software-version, software-type and
machine-type as CHICKEN reports them, plus what --features flag adds.
2026-09-16 17:59:37 +03:00
6e4cb80424 make sextest's (compilation ...) form work
1. Look for `compilation', not `compile' among the source
2. Read the file with provided --features from the (compilation ...)
form, then handle resulting file to sexc
2026-09-16 17:48:44 +03:00
294a275905 fail when the C compiler fails, and clean up when we do
compile-to-file returned process-wait's values and main dropped them,
so cc errors were printed, but then main compiler exited 0.

Also cleanup tmp C files when compilation failed.
2026-09-16 17:34:24 +03:00
9763f5fa8d export explicitly from the test build's types module 2026-09-16 17:29:53 +03:00
97ef62b7f4 resolve typedefs in get-fields and map-fields
Now these macro helpers take in account the possibility of typedefing
one type to another, and correctly find the one intended
2026-09-16 17:07:21 +03:00
847bb14340 accept pub enum, and enums used as types
Implement pub support for enums, and also anonymous enums declared
in-place.

Also give the cdr of a `pub' form the form's own location, so a
error about what follows `pub' can say where it was written
2026-09-16 17:02:45 +03:00
d0d0ea8e84 process imported forms as toplevel, not as text
1. register imported types
2. protect against multiple imports (diamond, circular)
2026-09-16 16:57:34 +03:00
85bf1c163c generate temp .c files instead of passing to compiler's stdin
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m44s
For a clearer architecture
2026-09-15 21:28:41 +03:00
0b2b97a0c6 add type database and compile-time reflection 2026-09-15 21:28:41 +03:00
dae19715df add module testing
Also fix module import
2026-09-15 21:28:41 +03:00
522c5a2c01 reject nested pointer types with proper error message 2026-09-15 21:28:41 +03:00
28ad33ca38 add sex-error reporting 2026-09-15 21:28:41 +03:00
e751ce2cb9 add sdl3 triangle example 2026-09-15 21:28:41 +03:00
Pavel Kulyov
df5a933f01 ci: use gitea actions platform without access to github
All checks were successful
Sex CI / build-linux (pull_request) Successful in 4m38s
Sex CI / build-linux (push) Successful in 4m39s
Fortunately Gitea actions runner is not too tied to GHA, so
just eliminating `uses:` clauses we can get a little more freedom
in sex.
2026-09-15 20:47:40 +03:00
5f9f90ef37 support || | |= operators, since we now have our own parser
Some checks failed
Sex CI / build-linux (pull_request) Failing after 3m1s
Sex CI / build-linux (push) Failing after 3m1s
Sex CI / build-macos (push) Has been cancelled
Sex CI / build-macos (pull_request) Has been cancelled
2026-09-15 20:18:20 +03:00
7e6e32488b fix stray commas and add comment packing
Some checks failed
Sex CI / build-linux (pull_request) Failing after 3m1s
Sex CI / build-macos (pull_request) Has been cancelled
2026-09-15 16:32:55 +03:00
fa4ad5acee fix comments inside statements shifting their meaning 2026-09-15 16:32:55 +03:00
36932fb480 add codegen and args tests, fix couple of bugs in C generation 2026-09-15 16:32:55 +03:00
d609a0c591 begin -> do
Shorter and doesn't imply existence of `end'
2026-09-15 16:32:55 +03:00
af6e778185 pass all args after '--' to C compiler verbatim 2026-09-15 16:32:55 +03:00
0db4a11a2b add `comments' test program 2026-09-15 16:32:55 +03:00
d83ee32f12 add source line number preservation
Some checks failed
Sex CI / build-macos (pull_request) Has been cancelled
Sex CI / build-linux (pull_request) Failing after 3m34s
For source-level debug. Add --line-directives option, defaulted to
statement. Disabled when used with -C. Explicit non-none value
overrides disabling when -C is present
2026-09-09 14:16:32 +03:00
528f26b7ef migrate to Chicken 6 2026-09-09 12:45:12 +03:00
9903cae3f7 reuse sex reader in sextest 2026-09-09 12:45:12 +03:00
f6ec07a4b5 fix sex-tests and sextest not rebuilding 2026-09-09 12:45:12 +03:00
543a333165 fix tests/Makefile not cleaning up .o files 2026-09-09 12:45:12 +03:00