still mess, probably obsolete anyways

This commit is contained in:
2025-09-20 12:15:59 +03:00
parent 8e4cc98522
commit fe69fce67b
9 changed files with 80 additions and 5 deletions

8
example/begin.sex Normal file
View File

@@ -0,0 +1,8 @@
(pub fn void other-fn ()
(begin (while true (begin 1 2 3 4)))
(switch a
((1) (begin
(var (const char *) str "121232132")
(puts "str")))
((2) (puts "2"))
(default (puts "more"))))

1
example/fn-no-args.sex Normal file
View File

@@ -0,0 +1 @@
(pub fn void no-args-fn () ())

View File

@@ -1,8 +1,8 @@
(include stdio.h)
(pub fn int main ((int argc) (char **argv))
(puts "Hello from Sex!")
(var (array char 512) name)
(puts "Hello from Sex!")
(puts "What is your name?")
(scanf "%s" (cast char* &name))
(printf "Hello, %s!\n" name)

25
example/polymorphism.sex Normal file
View File

@@ -0,0 +1,25 @@
(include stdint.h)
(struct vec2
((uint32_t x)
(uint32_t y)))
(trait gui
(fn void update ((float dt)))
(fn void render ())
(fn vec2 get-position ())
(fn void add-child ((gui *w))))
(struct button
((vector gui) children)
((vec2 pos)))
(impl gui button
(fn void update ((float dt))
())
(fn void render ()
())
(fn vec2 get-position ()
(return self->pos))
(fn void add-child ((gui *w))
(push self->children w)))