OpenGL and Vulkan examples; ptr(int)/int(ptr); trailing commas in calls; drop .fn hint

- examples/opengl.fch: OpenGL 3.3 core, shaders, VAO/VBO, a spinning triangle (checked offscreen)
- examples/vulkan.fch: instance, GPUs with properties/memory/queues, logical device and queue
- ptr(n) and int(p) conversions for C APIs that pass offsets as pointers
- .ptr works on string literals; a comma after the last call argument is allowed
- a missing header included by an imported header is now named in the error
- the old .fn extension hint is gone (Finch is new, there are no old files)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-08 19:37:34 +02:00
commit 8497251dc5
22 changed files with 357 additions and 26 deletions

View file

@ -1,3 +0,0 @@
// expect: but Finch files now end in .fch
import oldmodule
fn main() {}

View file

@ -1,2 +0,0 @@
fn hi() {
}

View file

@ -38,7 +38,6 @@ for f in run/*.fch; do
done
for f in fail/*.fch; do
grep -q "^// expect:" "$f" || continue
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
got=$("$FINCH" run "$f" < /dev/null 2>&1)
status=$?

22
tests/run/c_pointers.fch Normal file
View file

@ -0,0 +1,22 @@
import "string.h"
struct Point {
int x
int y
}
fn main() {
p := Point(
x: 1,
y: 2,
)
print(p)
c := "finch".ptr
print(c[1], strlen("finch"))
q := ptr(4096)
print(int(q), int(ptr(0)) == 0, q != null)
a := [10, 20, 30]
address := int(a.ptr)
ptr[int] second = ptr(address + 8)
print(second.value)
}

4
tests/run/c_pointers.out Normal file
View file

@ -0,0 +1,4 @@
Point(x: 1, y: 2)
i 5
4096 true true
20