#include "std/io.toc"; a ::= struct { foo: File; } main ::= fn() { x: &a; k := x.foo; } main(); /* #include "std/io.toc", io; #include "std/types.toc"; write_type ::= fn(f : &File, t :: Type) { k ::= t._kind; use TypeKind; #if k == UNKNOWN { io.fwrites(f, "???"); } elif k == BUILTIN { b ::= t._builtin; use BuiltinType; #if b == I8 { io.fwrites(f, "i8"); } elif b == U8 { io.fwrites(f, "u8"); } elif b == I16 { io.fwrites(f, "i16"); } elif b == U16 { io.fwrites(f, "u16"); } elif b == I32 { io.fwrites(f, "i32"); } elif b == U32 { io.fwrites(f, "u32"); } elif b == I64 { io.fwrites(f, "i64"); } elif b == U64 { io.fwrites(f, "u64"); } elif b == F32 { io.fwrites(f, "f32"); } elif b == F64 { io.fwrites(f, "f64"); } elif b == CHAR { io.fwrites(f, "char"); } elif b == BOOL { io.fwrites(f, "bool"); } elif b == TYPE { io.fwrites(f, "Type"); } elif b == VARARGS { io.fwrites(f, ".."); } elif b == NMS { io.fwrites(f, "Namespace"); } elif b == VOID { io.fwrites(f, "void"); } else { io.fwrites(f, ""); } } elif k == FN { #if t._is_template { io.fwrites(f, ""); } else { io.fwrites(f, "fn("); param_types ::= t._of; for i ::= 0.,param_types.len { #if i > 0 { io.fwrites(f, ", "); } write_type(f, param_types[i]); } io.fwritec(f, ')'); ret ::= t._returns; if ret != void { io.fwritec(f, ' '); write_type(f, ret); } } } elif k == TUPLE { io.fwritec(f, '('); sub_types ::= t._of; for i ::= 0.,sub_types.len { #if i > 0 { io.fwrites(f, ", "); } write_type(f, sub_types[i]); } io.fwritec(f, ')'); } elif k == ARR { io.fwritec(f, '['); io.writei(t._n); io.fwritec(f, ']'); write_type(f, t._of); } elif k == PTR { io.fwritec(f, '&'); write_type(f, t._of); } elif k == SLICE { io.fwrites(f, "[]"); write_type(f, t._of); } elif k == EXPR { io.fwrites(f, ""); } elif k == STRUCT { if t._is_template { io.fwrites(f, ""); } else { io.fwrites(f, "struct "); name ::= t._name; if name { io.fwrites(f, name); io.fwritec(f, ' '); } io.fwrites(f, "{ "); member_names ::= t._member_names; member_types ::= t._member_types; for i ::= 0.,member_names.len { io.fwrites(f, member_names[i]); io.fwrites(f, ": "); write_type(f, member_types[i]); io.fwrites(f, "; "); } io.fwritec(f, '}'); } } else { io.fwrites(f, ""); } } put_type ::= fn(t :: Type) { write_type(&std_out, t); writec('\n'); } print_typeof ::= fn (t ::=, x : t) { put_type(t); } some_fn ::= fn(a,b,c: int, d,e,f := 3.0) y : f64 = 3.111 { } main ::= fn() { foo0 := int == int; bar0 := int == float; foo1 := &&&int == &&&u8; bar1 := &&&int != &&∫ io.putb(foo0); io.putb(bar0); io.putb(foo1); io.putb(bar1); x ::= 4 as u64; y := 7.3432; z := "foo"; w := &z; t : [x*x]int; u := &t; v : &void; p: Point(u8); print_typeof(x); print_typeof(y); print_typeof(z); print_typeof(w); print_typeof(t); print_typeof(u); print_typeof(v); print_typeof(main); print_typeof(some_fn); print_typeof(xx); print_typeof(p); xx ::= fn() (int, int) { return 3, 5; } Point ::= struct(t :: Type) { use p: Point2D(t); z: float; } } main(); Point2D ::= struct(t :: Type) { x, y : t; } */