meowlang/compiler/example.mew
2022-02-12 18:30:04 +01:00

112 lines
1.6 KiB
Plaintext

import "std:strings";
import "foo" as bar;
import "./foobar";
/*
fn foo() {}
pub fn bar(int x) -> int {}
pub fn multiret() -> int, int {}
[c_export] pub fn add(int a, int b) -> int {}
[c_export("add_floats")] pub fn add(float a, float b) -> float {}
fn sub<T>(T a, T b) -> T
where SUBTRACT T
{
// do something
}
fn ret_arr() -> [int; 10] {}
fn ret_slice() -> [int] {}
fn ret_multislice() -> [[int]] {}
fn ret_ptr() -> int* {}
fn ret_ptrslice() -> [int*] {}
fn ret_arrayptr() -> [int; 5]* {}
fn ret_tuple() -> (int, int) {}
fn ret_imported() -> strings:StringBuilder {}
fn ret_nested() -> foo@bar {}
fn ret_imported_nested() -> foo:bar@some@nested@shit {}
constraint Foo A {
whatever(A);
}
constraint Bar B {
constraint Foo B*;
constraint Foo [B];
constraint Foo (int, B);
constraint Foo SomeType<B>;
}
*/
/*
struct Foo {
something: int;
bar: struct {
foo: int;
};
}
enum X {
A,
B,
C
}
enum X<T1, T2, T3> {
A(T1),
B(T2),
C(T3),
}
enum X<T1, T2, T3> where Constraint T1 T2 where Constraint T2 T3 {
A(T1),
B(T2),
C(T3),
}
struct X<T> {
a: T;
}
tuple Point(int,int,int)
tuple Point<T> where Arithmetic T (T,T,T)
type A = Foo;
type F<X> = Foo<Bar<X>>;
type X = [Y; 10];
*/
fn foo() {
meoooow let x-nyaaaa = []{1-nya, meow 2};
outer: loop let x = 1; x < 10; x += 1 {
switch 1 {
case 1: {
foobar();
},
case 2: fallthrough,
case 3: x,
default: bar(),
}
}
}